Closed Don2012 closed 5 years ago
Hi @Don2012, there is no guarantee on which thread completion block will be invoked, so I recommend you wrapping your UI calls into:
dispatch_async(dispatch_get_main_queue(), ^{
/* Do UI work here */
});
Hi @antrix1989, I'm also having main thread warnings on iOS 13 Simulator after calling
- (void)acquireTokenWithResource:(NSString*)resource
clientId:(NSString*)clientId
redirectUri:(NSURL*)redirectUri
completionBlock:(ADAuthenticationCallback)completionBlock;
This is happening with Xcode 11 Beta-6, Adal 4.0.0
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIViewController init]
PID: 10529, TID: 274678, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4 ADAL 0x000000010e74e1cf -[MSIDWebviewUIController initWithContext:] + 79
5 ADAL 0x000000010e733f77 -[MSIDOAuth2EmbeddedWebviewController initWithStartURL:endURL:webview:customHeaders:context:] + 535
6 ADAL 0x000000010e6d9a39 -[MSIDAADOAuthEmbeddedWebviewController initWithStartURL:endURL:webview:customHeaders:context:] + 361
7 ADAL 0x000000010e6e290e -[MSIDAADWebviewFactory embeddedWebviewSessionFromConfiguration:customWebview:context:] + 430
8 ADAL 0x000000010e74af81 +[MSIDWebviewAuthorization startEmbeddedWebviewAuthWithConfiguration:oauth2Factory:webview:context:completionHandler:] + 225
9 ADAL 0x000000010e6c80c4 +[ADWebAuthController(Internal) startWithRequest:promptBehavior:context:completion:] + 2020
10 ADAL 0x000000010e6a341b -[ADAuthenticationRequest(WebRequest) requestCode:] + 955
11 ADAL 0x000000010e69b879 -[ADAuthenticationRequest(AcquireToken) requestTokenImpl:] + 1369
12 ADAL 0x000000010e69b17b -[ADAuthenticationRequest(AcquireToken) requestToken:] + 1563
13 ADAL 0x000000010e69a768 __63-[ADAuthenticationRequest(AcquireToken) validatedAcquireToken:]_block_invoke + 216
14 ADAL 0x000000010e69ab27 __56-[ADAuthenticationRequest(AcquireToken) getAccessToken:]_block_invoke + 263
15 ADAL 0x000000010e682919 __40-[ADAcquireTokenSilentHandler getToken:]_block_invoke + 729
16 ADAL 0x000000010e68683d -[ADAcquireTokenSilentHandler tryFRT:completionBlock:] + 781
17 ADAL 0x000000010e686213 -[ADAcquireTokenSilentHandler tryMRRT:] + 755
18 ADAL 0x000000010e68558d -[ADAcquireTokenSilentHandler getAccessToken:] + 1405
19 ADAL 0x000000010e682602 -[ADAcquireTokenSilentHandler getToken:] + 178
20 ADAL 0x000000010e69a9c1 -[ADAuthenticationRequest(AcquireToken) getAccessToken:] + 433
21 ADAL 0x000000010e69a60b -[ADAuthenticationRequest(AcquireToken) validatedAcquireToken:] + 331
22 ADAL 0x000000010e699f3c __70-[ADAuthenticationRequest(AcquireToken) acquireToken:completionBlock:]_block_invoke.160 + 636
23 ADAL 0x000000010e6a8aeb __74-[ADAuthorityValidation checkAuthority:validateAuthority:completionBlock:]_block_invoke + 299
24 ADAL 0x000000010e6a93b5 __76-[ADAuthorityValidation validateAADAuthority:requestParams:completionBlock:]_block_invoke_2 + 53
25 libdispatch.dylib 0x0000000110462df0 _dispatch_call_block_and_release + 12
26 libdispatch.dylib 0x0000000110463d64 _dispatch_client_callout + 8
27 libdispatch.dylib 0x000000011046620b _dispatch_queue_override_invoke + 1022
28 libdispatch.dylib 0x000000011047529a _dispatch_root_queue_drain + 351
29 libdispatch.dylib 0x0000000110475ba4 _dispatch_worker_thread2 + 132
30 libsystem_pthread.dylib 0x00007fff511c26b3 _pthread_wqthread + 583
31 libsystem_pthread.dylib 0x00007fff511c23fd start_wqthread + 13
Basically, [MSIDWebviewUIController initWithContext:]
is not being called on main thread.
Also running into this issue on iOS 13 with v4.0.3. It seems to cause a significant delay when invoking the prompt and my call to acquireTokenWithResource
is already inside dispatch_async(dispatch_get_main_queue()...
.
dispatch_async(dispatch_get_main_queue(), ^{
[authContext
acquireTokenWithResource:resourceId
clientId:clientId
redirectUri:redirectUri
promptBehavior:AD_PROMPT_ALWAYS
userId:userId
extraQueryParameters:extraQueryParameters
completionBlock:^(ADAuthenticationResult *result) {
...
I'm not experienced with Objective C so am unsure of how to debug this futher.
Main Thread Checker: UI API called on a background thread: -[UIViewController init]
PID: 357, TID: 12904, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 0
Backtrace:
4 ADAL 0x0000000100654bc0 -[MSIDWebviewUIController initWithContext:] + 92
5 ADAL 0x000000010063a9b8 -[MSIDOAuth2EmbeddedWebviewController initWithStartURL:endURL:webview:customHeaders:context:] + 472
6 ADAL 0x00000001005e31ec -[MSIDAADOAuthEmbeddedWebviewController initWithStartURL:endURL:webview:customHeaders:context:] + 344
7 ADAL 0x00000001005ebf70 -[MSIDAADWebviewFactory embeddedWebviewSessionFromConfiguration:customWebview:context:] + 400
8 ADAL 0x00000001006513e0 +[MSIDWebviewAuthorization startEmbeddedWebviewAuthWithConfiguration:oauth2Factory:webview:context:completionHandler:] + 212
9 ADAL 0x00000001005d2510 +[ADWebAuthController(Internal) startWithRequest:promptBehavior:context:completion:] + 1788
10 ADAL 0x00000001005abefc -[ADAuthenticationRequest(WebRequest) requestCode:] + 880
11 ADAL 0x00000001005a3ce4 -[ADAuthenticationRequest(AcquireToken) requestTokenImpl:] + 1272
12 ADAL 0x00000001005a3608 -[ADAuthenticationRequest(AcquireToken) requestToken:] + 1524
13 ADAL 0x00000001005a2aa0 -[ADAuthenticationRequest(AcquireToken) validatedAcquireToken:] + 448
14 ADAL 0x00000001005a22e0 __70-[ADAuthenticationRequest(AcquireToken) acquireToken:completionBlock:]_block_invoke.160 + 656
15 ADAL 0x00000001005b1374 __74-[ADAuthorityValidation checkAuthority:validateAuthority:completionBlock:]_block_invoke + 276
16 ADAL 0x00000001005b1b30 __76-[ADAuthorityValidation validateAADAuthority:requestParams:completionBlock:]_block_invoke_2 + 56
17 libdispatch.dylib 0x0000000100c09828 _dispatch_call_block_and_release + 24
18 libdispatch.dylib 0x0000000100c0ac04 _dispatch_client_callout + 16
19 libdispatch.dylib 0x0000000100c0d300 _dispatch_queue_override_invoke + 872
20 libdispatch.dylib 0x0000000100c1c168 _dispatch_root_queue_drain + 376
21 libdispatch.dylib 0x0000000100c1ca90 _dispatch_worker_thread2 + 156
22 libsystem_pthread.dylib 0x000000018b3a1f64 _pthread_wqthread + 212
23 libsystem_pthread.dylib 0x000000018b3a4ae0 start_wqthread + 8
Should be fixed in 4.0.4. Please reopen the issue if it still persists in 4.0.4 release.
Crash in iOS13 when presenting a ViewController, but it is fine in iOS12. Tried ADAL (2.7.9) & ADAL (4.0.0), and all crash