Taplinx iOS appcrash on tag response

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Taplinx iOS appcrash on tag response

Jump to solution
2,321 Views
DamianD
Contributor III

Hi, i followed UG10045.pdf and created ios application. I created ApduExchangeWithByteArray method and implemented its contents. However when send back response from tag back to taplinx library, application crashes with following entries from device log:

Time	Device Name	Type	PID	Tag	Message
Nov  6 20:44:31	iPhone	Notice	5223	MobileFacilityApp	Command Set - 1
Nov  6 20:44:31	iPhone	Notice	5223	MobileFacilityApp	Command Set - Native
Nov  6 20:44:31	iPhone	Error	0	kernel(Sandbox)	Sandbox: MobileFacilityApp(5223) deny(1) sysctl-read kern.bootargs
Nov  6 20:44:38	iPhone	Notice	5223	MobileFacilityApp(UIKitCore)	Received memory warning.
Nov  6 20:44:38	iPhone	Notice	5223	MobileFacilityApp(UIKitCore)	Received memory warning.
Nov  6 20:44:40	iPhone	Notice	0	kernel	EXC_RESOURCE -> MobileFacilityApp[5223] exceeded mem limit: InactiveHard 3072 MB (fatal)
Nov  6 20:44:40	iPhone	Notice	0	kernel	memorystatus: killing process 5223 [MobileFacilityApp] in high band FOREGROUND (100) - memorystatus_available_pages: 44859

 

When i sent back empty response back to taplinx library (just TL_TagAPDUResponse without setting ResponseData) - app does not crash and i get error about incomplete response (which is expected). What am i doing wrong?  

0 Kudos
Reply
1 Solution
2,280 Views
DamianD
Contributor III

apparently included headers in TapLinx-v2.0.0 are all wrong. In TapLinxApduHandler.h we see declaration:

- (nullable TL_TagAPDUResponse *)apduExchangeWithByteArray:(NSData *_Nonnull)apduData;

but in reality we should return IOSByteArray*, otherwise app will crash with aforementioned symptoms

View solution in original post

0 Kudos
Reply
6 Replies
2,222 Views
ukcas
NXP Employee
NXP Employee

Hello Damian,

Maybe the cause of the error is some exceeding memory limit and not TapLinx library?

MobileFacilityApp[5223] exceeded mem limit: InactiveHard 3072 MB (fatal)

 

The application which integrates TapLinx Library can be used as following (no need for ApduExchange implementation on top)

Set the delegate to the APDUHandler

let reader = TL_IOSNFCReader(uid: tag.identifier, historicalBytes: tag.historicalBytes ?? Data())

handler = TapLinxApduHandler(reader: reader)

handler.delegate = self

                

libraryManager?.setApduHandlerWithApduHandler(handler)

 

Next Step will be to implement the protocol method inside the application

 

func apduExchange(withByteArray apduData: Data) -> TL_TagAPDUResponse? {

        var tagAPDUResponse: TL_TagAPDUResponse?

       

        if connectedTag != nil {

            // Send Tag Type Native of ISO and the apdu as NFCISO7816APDU

            executeAPDUCommandOn7816Tag(tagType: tagtype, apdu: apdu) { data in

                let appendedData = data


                tagAPDUResponse = TL_TagAPDUResponse(responseData: appendedData, tag: self.currentTag)

                semaphore.signal()

            }

            let _ = semaphore.wait(timeout: .now() + 3.0)

        } else if connectedMifareTag != nil {

            let semaphore = DispatchSemaphore(value: 0)

           

            print("MIFARE CAPDU -> \(apduData.hex)")

           

            executeAPDUCommandOnMIFARETag(apdu: apduData) { data in

                print("RAPDU <- Data: \(data.hex)")

                tagAPDUResponse = TL_TagAPDUResponse(responseData: data, tag: self.currentTag)

                semaphore.signal()

            }

            let _ = semaphore.wait(timeout: .now() + 3.0)

        }

        print("Tag Response \(String(describing: tagAPDUResponse))")

        return tagAPDUResponse

    }

 

Hope this simplification would help you.

 

Best regards,

TapLinx team

0 Kudos
Reply
2,219 Views
DamianD
Contributor III

@ukcas - what version of taplinx ios library is 'current'? Because i have 2.0.0 and it definitely crashes when i return TL_TagAPDUResponse from apduExchange method, it has to be raw IOSByteArray from j2objc library. I'm using c# bindings for taplinx library, but it does not matter in this problem.

0 Kudos
Reply
2,220 Views
DamianD
Contributor III
hi
the crash definietly comes from taplinx library because when i changed
- (nullable TL_TagAPDUResponse *)apduExchangeWithByteArray:(NSData *_Nonnull)apduData;
to actually:
- (nullable IOSByteArray*)apduExchangeWithByteArray:(IOSByteArray*_Nonnull)apduData;
It started working

0 Kudos
Reply
2,212 Views
DamianD
Contributor III
followup - when i changed my implementation to use provided TapLinxApduHandler instead of providing my own - then apduExchangeWithByteArray does conform to contract - (nullable TL_TagAPDUResponse *)apduExchangeWithByteArray:(NSData *_Nonnull)apduData;
0 Kudos
Reply
2,277 Views
DamianD
Contributor III

one more thing - apduData is really also IOSByteArray, not NSData

0 Kudos
Reply
2,281 Views
DamianD
Contributor III

apparently included headers in TapLinx-v2.0.0 are all wrong. In TapLinxApduHandler.h we see declaration:

- (nullable TL_TagAPDUResponse *)apduExchangeWithByteArray:(NSData *_Nonnull)apduData;

but in reality we should return IOSByteArray*, otherwise app will crash with aforementioned symptoms

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-1989340%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ETaplinx%20iOS%20appcrash%20on%20tag%20response%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1989340%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%20i%20followed%20%3CSPAN%3EUG10045.pdf%20and%20created%20ios%20application.%20I%20created%26nbsp%3BApduExchangeWithByteArray%20method%20and%20implemented%20its%20contents.%20However%20when%20send%20back%20response%20from%20tag%20back%20to%20taplinx%20library%2C%20application%20crashes%20with%20following%20entries%20from%20device%20log%3A%3C%2FSPAN%3E%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-csharp%22%3E%3CCODE%3ETime%09Device%20Name%09Type%09PID%09Tag%09Message%0ANov%20%206%2020%3A44%3A31%09iPhone%09Notice%095223%09MobileFacilityApp%09Command%20Set%20-%201%0ANov%20%206%2020%3A44%3A31%09iPhone%09Notice%095223%09MobileFacilityApp%09Command%20Set%20-%20Native%0ANov%20%206%2020%3A44%3A31%09iPhone%09Error%090%09kernel(Sandbox)%09Sandbox%3A%20MobileFacilityApp(5223)%20deny(1)%20sysctl-read%20kern.bootargs%0ANov%20%206%2020%3A44%3A38%09iPhone%09Notice%095223%09MobileFacilityApp(UIKitCore)%09Received%20memory%20warning.%0ANov%20%206%2020%3A44%3A38%09iPhone%09Notice%095223%09MobileFacilityApp(UIKitCore)%09Received%20memory%20warning.%0ANov%20%206%2020%3A44%3A40%09iPhone%09Notice%090%09kernel%09EXC_RESOURCE%20-%26gt%3B%20MobileFacilityApp%5B5223%5D%20exceeded%20mem%20limit%3A%20InactiveHard%203072%20MB%20(fatal)%0ANov%20%206%2020%3A44%3A40%09iPhone%09Notice%090%09kernel%09memorystatus%3A%20killing%20process%205223%20%5BMobileFacilityApp%5D%20in%20high%20band%20FOREGROUND%20(100)%20-%20memorystatus_available_pages%3A%2044859%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CP%3EWhen%20i%20sent%20back%20empty%20response%20back%20to%20taplinx%20library%20(just%26nbsp%3BTL_TagAPDUResponse%20without%20setting%20ResponseData)%20-%20app%20does%20not%20crash%20and%20i%20get%20error%20about%20incomplete%20response%20(which%20is%20expected).%20What%20am%20i%20doing%20wrong%3F%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1991088%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Taplinx%20iOS%20appcrash%20on%20tag%20response%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1991088%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Efollowup%20-%20when%20i%20changed%20my%20implementation%20to%20use%20provided%20TapLinxApduHandler%20instead%20of%20providing%20my%20own%20-%20then%20apduExchangeWithByteArray%20does%20conform%20to%20contract%20-%20(nullable%20TL_TagAPDUResponse%20*)apduExchangeWithByteArray%3A(NSData%20*_Nonnull)apduData%3B%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1991063%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Taplinx%20iOS%20appcrash%20on%20tag%20response%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1991063%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F169705%22%20target%3D%22_blank%22%3E%40ukcas%3C%2FA%3E%26nbsp%3B-%20what%20version%20of%20taplinx%20ios%20library%20is%20'current'%3F%20Because%20i%20have%202.0.0%20and%20it%20%3CSPAN%3Edefinitely%20crashes%20when%20i%20return%26nbsp%3BTL_TagAPDUResponse%20from%26nbsp%3BapduExchange%20method%2C%20it%20has%20to%20be%20raw%20IOSByteArray%20from%20j2objc%20library.%20I'm%20using%20c%23%20bindings%20for%20taplinx%20library%2C%20but%20it%20does%20not%20matter%20in%20this%20problem.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1991041%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Taplinx%20iOS%20appcrash%20on%20tag%20response%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1991041%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Ehi%3CBR%20%2F%3Ethe%20crash%20definietly%20comes%20from%20taplinx%20library%20because%20when%20i%20changed%3CBR%20%2F%3E-%20(nullable%20TL_TagAPDUResponse%20*)apduExchangeWithByteArray%3A(NSData%20*_Nonnull)apduData%3B%3CBR%20%2F%3Eto%20actually%3A%3CBR%20%2F%3E-%20(nullable%20IOSByteArray*)apduExchangeWithByteArray%3A(IOSByteArray*_Nonnull)apduData%3B%3CBR%20%2F%3EIt%20started%20working%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1991020%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Taplinx%20iOS%20appcrash%20on%20tag%20response%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1991020%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%20Damian%2C%3C%2FP%3E%0A%3CP%3EMaybe%20the%20cause%20of%20the%20error%20is%20some%20exceeding%20memory%20limit%20and%20not%20TapLinx%20library%3F%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20%20language-csharp%22%3E%3CCODE%3EMobileFacilityApp%5B5223%5D%20exceeded%20mem%20limit%3A%20InactiveHard%203072%20MB%20(fatal)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CBR%20%2F%3E%0A%3CP%3EThe%20application%20which%20integrates%20TapLinx%20Library%20can%20be%20used%20as%20following%20(no%20need%20for%20ApduExchange%20implementation%20on%20top)%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ESet%20the%20delegate%20to%20the%20APDUHandler%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-java%22%3E%3CCODE%3Elet%20reader%20%3D%20TL_IOSNFCReader(uid%3A%20tag.identifier%2C%20historicalBytes%3A%20tag.historicalBytes%20%3F%3F%20Data())%0A%0Ahandler%20%3D%20TapLinxApduHandler(reader%3A%20reader)%0A%0Ahandler.delegate%20%3D%20self%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%0AlibraryManager%3F.setApduHandlerWithApduHandler(handler)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CBR%20%2F%3E%0A%3CP%3E%3CSTRONG%3ENext%20Step%20will%20be%20to%20implement%20the%20protocol%20method%20inside%20the%20application%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-java%22%3E%3CCODE%3Efunc%20apduExchange(withByteArray%20apduData%3A%20Data)%20-%26gt%3B%20TL_TagAPDUResponse%3F%20%7B%0A%0A%20%20%20%20%20%20%20%20var%20tagAPDUResponse%3A%20TL_TagAPDUResponse%3F%0A%0A%20%20%20%20%20%20%20%0A%0A%20%20%20%20%20%20%20%20if%20connectedTag%20!%3D%20nil%20%7B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%2F%2F%20Send%20Tag%20Type%20Native%20of%20ISO%20and%20the%20apdu%20as%20NFCISO7816APDU%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20executeAPDUCommandOn7816Tag(tagType%3A%20tagtype%2C%20apdu%3A%20apdu)%20%7B%20data%20in%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20let%20appendedData%20%3D%20data%0A%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tagAPDUResponse%20%3D%20TL_TagAPDUResponse(responseData%3A%20appendedData%2C%20tag%3A%20self.currentTag)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20semaphore.signal()%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20let%20_%20%3D%20semaphore.wait(timeout%3A%20.now()%20%2B%203.0)%0A%0A%20%20%20%20%20%20%20%20%7D%20else%20if%20connectedMifareTag%20!%3D%20nil%20%7B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20let%20semaphore%20%3D%20DispatchSemaphore(value%3A%200)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20print(%22MIFARE%20CAPDU%20%3CLI-EMOJI%20id%3D%22lia_mobile-phone%22%20title%3D%22%3Amobile_phone%3A%22%3E%3C%2FLI-EMOJI%3E-%26gt%3B%3CLI-EMOJI%20id%3D%22lia_credit-card%22%20title%3D%22%3Acredit_card%3A%22%3E%3C%2FLI-EMOJI%3E%20%5C(apduData.hex)%22)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20executeAPDUCommandOnMIFARETag(apdu%3A%20apduData)%20%7B%20data%20in%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20print(%22RAPDU%20%3CLI-EMOJI%20id%3D%22lia_mobile-phone%22%20title%3D%22%3Amobile_phone%3A%22%3E%3C%2FLI-EMOJI%3E%26lt%3B-%3CLI-EMOJI%20id%3D%22lia_credit-card%22%20title%3D%22%3Acredit_card%3A%22%3E%3C%2FLI-EMOJI%3E%20Data%3A%20%5C(data.hex)%22)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tagAPDUResponse%20%3D%20TL_TagAPDUResponse(responseData%3A%20data%2C%20tag%3A%20self.currentTag)%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20semaphore.signal()%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20let%20_%20%3D%20semaphore.wait(timeout%3A%20.now()%20%2B%203.0)%0A%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20print(%22Tag%20Response%20%5C(String(describing%3A%20tagAPDUResponse))%22)%0A%0A%20%20%20%20%20%20%20%20return%20tagAPDUResponse%0A%0A%20%20%20%20%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CBR%20%2F%3E%0A%3CP%3EHope%20this%20simplification%20would%20help%20you.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EBest%20regards%2C%3C%2FP%3E%0A%3CP%3ETapLinx%20team%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1990546%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Taplinx%20iOS%20appcrash%20on%20tag%20response%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1990546%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3Eone%20more%20thing%20-%20apduData%20is%20really%20also%20IOSByteArray%2C%20not%20NSData%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1990544%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Taplinx%20iOS%20appcrash%20on%20tag%20response%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1990544%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3Eapparently%20included%20headers%20in%26nbsp%3BTapLinx-v2.0.0%20are%20all%20wrong.%20In%26nbsp%3BTapLinxApduHandler.h%20we%20see%20declaration%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%3E-%20(nullable%20TL_TagAPDUResponse%20*)apduExchangeWithByteArray%3A(NSData%20*_Nonnull)apduData%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3Ebut%20in%20reality%20we%20should%20return%20IOSByteArray*%2C%20otherwise%20app%20will%20crash%20with%20aforementioned%20symptoms%3C%2FP%3E%3C%2FLINGO-BODY%3E