Adyen / adyen-3ds2-ios

Other
18 stars 12 forks source link

ADYService initialization doesn't return on simulator #2

Closed booranger closed 5 years ago

booranger commented 5 years ago

I'm trying to init the service after calling the first auth call but it never returns. As I write this I realise its going be simulator issues.

ADYServiceParameters *serviceParameters = [[ADYServiceParameters alloc] init];

[serviceParameters setDirectoryServerIdentifier:paymentResponse.paymentAuthData.directoryServerId]; // Retrieved from the additionalData.
[serviceParameters setDirectoryServerPublicKey:paymentResponse.paymentAuthData.directoryServerPublicKey]; // Retrieved from the additionalData.

self.service = [[ADYService alloc] initWithParameters:serviceParameters appearanceConfiguration:appearanceConfiguration];

P.S podspec ios not on master cocoapods spec repo .

booranger commented 5 years ago

Yes as I said issue was because I was running in the simulator.

joostvandijk commented 5 years ago

Hey @booranger,

Can you clarify on what the issue was? The SDK should work fine in the iOS simulator.

Thanks!

Joost

joostvandijk commented 5 years ago

Also, we just pushed the podspec to the master repo. Thanks for the reminder!

booranger commented 5 years ago

@joostvandijk I just setup with the code above (working on a real device) but on the simulator self.service = [[ADYService alloc] initWithParameters:serviceParameters appearanceConfiguration:appearanceConfiguration]; never returns. Basically it just blocks the thread and nothing after that line is called.

Simulator: iPhone 8 iOS 12.1 Lib: Adyen3DS2 0.9.1 (off 'head' installed today using cocoapods)

joostvandijk commented 5 years ago

I see, that shouldn't happen. Are you calling it on the main thread or a separate thread?

booranger commented 5 years ago

Calling it from the main thread.

On Thu, Nov 15, 2018 at 12:32 PM Joost van Dijk notifications@github.com wrote:

I see, that shouldn't happen. Are you calling it on the main thread or a separate thread?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Adyen/adyen-3ds2-ios/issues/2#issuecomment-439024919, or mute the thread https://github.com/notifications/unsubscribe-auth/ABiXCAxTWU3jaSgP5094HGJjKDMxZmwoks5uvV7mgaJpZM4Yfkue .

joostvandijk commented 5 years ago

Can you try calling it from a different thread? Note that it's recommended to call the ADYService initialization and the ADYTransaction creation on a background thread, as both could take some time to complete. Nevertheless, it shouldn't completely freeze on the main thread, so we'll work on fixing that.

booranger commented 5 years ago

I'm now dispatching from a background thread and I'm still facing the issues. I now see the issue when I tested on a iPhone X. On my iPhone 6s I've gone through the whole flow without issue. Both are on iOS 12.1.

Here's the stack trace I'm seeing for it.

* thread #8, queue = 'com.apple.root.background-qos'
  * frame #0: 0x00000001aeda79fc libsystem_kernel.dylib`__ulock_wait + 8
    frame #1: 0x0000000109d5985c libdispatch.dylib`_dispatch_ulock_wait + 56
    frame #2: 0x0000000109d5a25c libdispatch.dylib`_dispatch_group_wait_slow + 40
    frame #3: 0x0000000102072720 Adyen3DS2`-[ADYService initWithParameters:appearanceConfiguration:] + 372
    frame #4: 0x0000000100a674a4 myapp`-[EJ3DPaymentAuthViewController buildAdyanService:](self=0x000000010db0be10, _cmd="buildAdyanService:", paymentResponse=0x0000000282806f70) at EJ3DPaymentAuthViewController.m:102
    frame #5: 0x0000000100a66d4c myapp`__52-[EJ3DPaymentAuthViewController makePaymentRequest:]_block_invoke_2(.block_descriptor=0x0000000282806a60) at EJ3DPaymentAuthViewController.m:58
    frame #6: 0x0000000109d57824 libdispatch.dylib`_dispatch_call_block_and_release + 24
    frame #7: 0x0000000109d58dc8 libdispatch.dylib`_dispatch_client_callout + 16
    frame #8: 0x0000000109d6a330 libdispatch.dylib`_dispatch_root_queue_drain + 716
    frame #9: 0x0000000109d6abc8 libdispatch.dylib`_dispatch_worker_thread2 + 156
    frame #10: 0x00000001aee2c17c libsystem_pthread.dylib`_pthread_wqthread + 472
    frame #11: 0x00000001aee2ecec libsystem_pthread.dylib`start_wqthread + 4
joostvandijk commented 5 years ago

Thanks for the stacktrace, that helps. It's clearly a bug on our side. I'll look into it tomorrow!

booranger commented 5 years ago

Cool thanks!

Simulators I've checked: iPhone 6s 12.1 -> working iPhone 8 -> Not working

Devices: iPhone 6s 12.1 -> working iPhone X 12.1 -> Not working

Does it use a location manager in the background as I see:

A location manager (0x7fd44beb29e0) was created on a dispatch queue executing on a thread other than the main thread. It is the developer's responsibility to ensure that there is a run loop running on the thread on which the location manager object is allocated. In particular, creating location managers in arbitrary dispatch queues (not attached to the main queue) is not supported and will result in callbacks not being received.

I also noticed the following message appearing a lot when it gets stuck (printed out 100's of times):

Discarding message for event 0 because of too many unprocessed messages
joostvandijk commented 5 years ago

Just wanted to let you know we fixed the issue. We expect to publish an update on Monday.

joostvandijk commented 5 years ago

Hi @booranger,

We just published 0.9.2 which fixes this issue. We did have to make some breaking changes to the ADYService interface. Most notably, the initializer is now asynchronous. This is to account for the retrieval of the user's location (when available).