Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI API called from background thread #565

Closed
Jackhammer42 opened this issue Aug 27, 2019 · 9 comments · Fixed by #576
Closed

UI API called from background thread #565

Jackhammer42 opened this issue Aug 27, 2019 · 9 comments · Fixed by #576

Comments

@Jackhammer42
Copy link

Hey,

i am facing an issue with the current Lock version for Swift (v.2.11.0) in the iOS13 Beta 8.
When I hit the login button, the app freezes for a few seconds and the proceeds normally.

In Xcode (Version 11.0 beta 5 (11M382q)) I get the following message in the terminal:

Main Thread Checker: UI API called on a background thread: -[UIViewController presentingViewController]
PID: 6280, TID: 151027, Thread name: (none), Queue name: NSOperationQueue 0x10a201270 (QOS: UNSPECIFIED), QoS: 0
Backtrace:
4   Lock                                0x0000000105afa860 $s4Lock13ObserverStoreV8dispatch6resultyAA6ResultO_tF + 604
5   Lock                                0x0000000105afc5e8 $s4Lock13ObserverStoreVAA10DispatcherA2aDP8dispatch6resultyAA6ResultO_tFTW + 12
6   Lock                                0x0000000105a5b3b8 $s4Lock25CredentialAuthenticatablePAAE6handle10identifier6result8callbackySS_5Auth06ResultOyAH11CredentialsCGyAA0B9AuthErrorOSgXEtF + 9308
7   Lock                                0x0000000105a669cc $s4Lock18DatabaseInteractorV5loginyyyAA19CredentialAuthErrorOSgcFy5Auth06ResultOyAH11CredentialsCGcfU_ + 348
8   Lock                                0x0000000105a66b80 $s5Auth06ResultOyAA11CredentialsCGIegg_AFIegn_TR + 52
9   Auth0                               0x00000001052237a8 $s5Auth06ResultOyAA11CredentialsCGIgn_AFIegg_TR + 84
10  Auth0                               0x00000001052236b4 $s5Auth06ResultOyAA11CredentialsCGIgg_AFIegn_TR + 52
11  Auth0                               0x0000000105241274 $s5Auth020authenticationObject4from8callbackyAA8ResponseVyAA19AuthenticationErrorCG_yAA6ResultOyxGXEtAA17JSONObjectPayloadRzlF + 1120
12  Auth0                               0x0000000105223620 $s5Auth08ResponseVyAA19AuthenticationErrorCGAA6ResultOyAA11CredentialsCGIgn_Ieggy_AfKIgg_Ieggy_TR + 48
13  Auth0                               0x00000001052236f4 $s5Auth08ResponseVyAA19AuthenticationErrorCGAA6ResultOyAA11CredentialsCGIgg_Ieggy_AfKIgn_Ieggy_TR + 48
14  Auth0                               0x000000010525be5c $s5Auth07RequestV5startyyyAA6ResultOyxGcFy10Foundation4DataVSg_So13NSURLResponseCSgs5Error_pSgtcfU_ + 820
15  Auth0                               0x000000010525bf98 $s5Auth07RequestV5startyyyAA6ResultOyxGcFy10Foundation4DataVSg_So13NSURLResponseCSgs5Error_pSgtcfU_TA + 80
16  Auth0                               0x000000010525c0c4 $s10Foundation4DataVSgSo13NSURLResponseCSgs5Error_pSgIegggg_So6NSDataCSgAGSo7NSErrorCSgIeyByyy_TR + 284
17  CFNetwork                           0x000000019a584878 CFNetServiceBrowserSearchForServices + 93080
18  CFNetwork                           0x000000019a594c64 _CFHTTPMessageSetResponseProxyURL + 9212
19  Foundation                          0x000000019774ae08 DBDE3CC3-3420-35A3-A815-5F48DEF6B71C + 1134088
20  Foundation                          0x0000000197654e78 DBDE3CC3-3420-35A3-A815-5F48DEF6B71C + 126584
21  Foundation                          0x000000019774d090 DBDE3CC3-3420-35A3-A815-5F48DEF6B71C + 1142928
22  Foundation                          0x0000000197654b10 DBDE3CC3-3420-35A3-A815-5F48DEF6B71C + 125712
23  Foundation                          0x000000019774da88 DBDE3CC3-3420-35A3-A815-5F48DEF6B71C + 1145480
24  Foundation                          0x000000019774d554 DBDE3CC3-3420-35A3-A815-5F48DEF6B71C + 1144148
25  libdispatch.dylib                   0x0000000109f5131c _dispatch_block_async_invoke2 + 104
26  libdispatch.dylib                   0x0000000109f42c88 _dispatch_client_callout + 16
27  libdispatch.dylib                   0x0000000109f4588c _dispatch_continuation_pop + 524
28  libdispatch.dylib                   0x0000000109f44d0c _dispatch_async_redirect_invoke + 624
29  libdispatch.dylib                   0x0000000109f541ec _dispatch_root_queue_drain + 376
30  libdispatch.dylib                   0x0000000109f54b14 _dispatch_worker_thread2 + 156
31  libsystem_pthread.dylib             0x00000001970a3f68 _pthread_wqthread + 212
32  libsystem_pthread.dylib             0x00000001970a6ae4 start_wqthread + 8
2019-08-27 12:50:32.914769+0200 Wombat[6280:151027] [reports] Main Thread Checker: UI API called on a background thread: -[UIViewController presentingViewController]
PID: 6280, TID: 151027, Thread name: (none), Queue name: NSOperationQueue 0x10a201270 (QOS: UNSPECIFIED), QoS: 0
Backtrace:
4   Lock                                0x0000000105afa860 $s4Lock13ObserverStoreV8dispatch6resultyAA6ResultO_tF + 604
5   Lock                                0x0000000105afc5e8 $s4Lock13ObserverStoreVAA10DispatcherA2aDP8dispatch6resultyAA6ResultO_tFTW + 12
6   Lock                                0x0000000105a5b3b8 $s4Lock25CredentialAuthenticatablePAAE6handle10identifier6result8callbackySS_5Auth06ResultOyAH11CredentialsCGyAA0B9AuthErrorOSgXEtF + 9308
7   Lock                                0x0000000105a669cc $s4Lock18DatabaseInteractorV5loginyyyAA19CredentialAuthErrorOSgcFy5Auth06ResultOyAH11CredentialsCGcfU_ + 348
8   Lock                                0x0000000105a66b80 $s5Auth06ResultOyAA11CredentialsCGIegg_AFIegn_TR + 52
9   Auth0                               0x00000001052237a8 $s5Auth06ResultOyAA11CredentialsCGIgn_AFIegg_TR + 84
10  Auth0                               0x00000001052236b4 $s5Auth06ResultOyAA11CredentialsCGIgg_AFIegn_TR + 52
11  Auth0                               0x0000000105241274 $s5Auth020authenticationObject4from8callbackyAA8ResponseVyAA19AuthenticationErrorCG_yAA6ResultOyxGXEtAA17JSONObjectPayloadRzlF + 1120
12  Auth0                               0x0000000105223620 $s5Auth08ResponseVyAA19AuthenticationErrorCGAA6ResultOyAA11CredentialsCGIgn_Ieggy_AfKIgg_Ieggy_TR + 48
13  Auth0                               0x00000001052236f4 $s5Auth08ResponseVyAA19AuthenticationErrorCGAA6ResultOyAA11CredentialsCGIgg_Ieggy_AfKIgn_Ieggy_TR + 48
14  Auth0                               0x000000010525be5c $s5Auth07RequestV5startyyyAA6ResultOyxGcFy10Foundation4DataVSg_So13NSURLResponseCSgs5Error_pSgtcfU_ + 820
15  Auth0                               0x000000010525bf98 $s5Auth07RequestV5startyyyAA6ResultOyxGcFy10Foundation4DataVSg_So13NSURLResponseCSgs5Error_pSgtcfU_TA + 80
16  Auth0                               0x000000010525c0c4 $s10Foundation4DataVSgSo13NSURLResponseCSgs5Error_pSgIegggg_So6NSDataCSgAGSo7NSErrorCSgIeyByyy_TR + 284
17  CFNetwork                           0x000000019a584878 CFNetServiceBrowserSearchForServices + 93080
18  CFNetwork                           0x000000019a594c64 _CFHTTPMessageSetResponseProxyURL + 9212
19  Foundation                          0x000000019774ae08 DBDE3CC3-3420-35A3-A815-5F48DEF6B71C + 1134088
20  Foundation                          0x0000000197654e78 DBDE3CC3-3420-35A3-A815-5F48DEF6B71C + 126584
21  Foundation                          0x000000019774d090 DBDE3CC3-3420-35A3-A815-5F48DEF6B71C + 1142928
22  Foundation                          0x0000000197654b10 DBDE3CC3-3420-35A3-A815-5F48DEF6B71C + 125712
23  Foundation                          0x000000019774da88 DBDE3CC3-3420-35A3-A815-5F48DEF6B71C + 1145480
24  Foundation                          0x000000019774d554 DBDE3CC3-3420-35A3-A815-5F48DEF6B71C + 1144148
25  libdispatch.dylib                   0x0000000109f5131c _dispatch_block_async_invoke2 + 104
26  libdispatch.dylib                   0x0000000109f42c88 _dispatch_client_callout + 16

27  libdispatch.dylib                   0x0000000109f4588c _dispatch_continuation_pop + 524
28  libdispatch.dylib                   0x0000000109f44d0c _dispatch_async_redirect_invoke + 624
29  libdispatch.dylib                   0x0000000109f541ec _dispatch_root_queue_drain + 376
30  libdispatch.dylib                   0x0000000109f54b14 _dispatch_worker_thread2 + 156
31  libsystem_pthread.dylib             0x00000001970a3f68 _pthread_wqthread + 212
32  libsystem_pthread.dylib             0x00000001970a6ae4 start_wqthread + 8

In addition Xcode shows me this:

2019-08-27_12-55-03

On iOS 12 i do not experience this issue.

@cocojoe
Copy link
Member

cocojoe commented Aug 27, 2019

Not sure why this comes up, the closure is executed further down on the main thread and has never come up as in issue before. It only appears to happen the first time it's called, on subsequent retries there is no delay.

May be a false positive introduced in this beta. As the checker has been active since Xcode 9

https://developer.apple.com/documentation/code_diagnostics/main_thread_checker

Flagged thread check
https://github.com/auth0/Lock.swift/blob/master/Lock/ObserverStore.swift#L43

Dispatch
https://github.com/auth0/Lock.swift/blob/master/Lock/ObserverStore.swift#L67

@Jackhammer42
Copy link
Author

Jackhammer42 commented Aug 27, 2019

It only appears to happen the first time it's called, on subsequent retries there is no delay.

yes, same here. forgot to mention that detail.

next steps? wait for the final version of Xcode and check again?

@cocojoe
Copy link
Member

cocojoe commented Aug 27, 2019

I'm going to file a bug report, would suggest doing the same.

@cocojoe
Copy link
Member

cocojoe commented Sep 18, 2019

I had another quick look, it seems that merely obtaining a reference to the presentingViewController flags up the thread checker. Even though the actual action is performed is dispatched in the main thread.

However, the delay/pause seems to have gone in later versions of iOS 13 Beta, at least when I tested.

@colin-chan
Copy link

We are also experiencing this problem. We are using XCode 11 GM2, ios 13.0.

@pixeled
Copy link
Contributor

pixeled commented Oct 1, 2019

my app was rejected because of this-
sign-in, then the callbacks to ‘move ahead’ aren’t called.

may be 13.1.2 specific - may be iPad specific.

@cocojoe
Copy link
Member

cocojoe commented Oct 3, 2019

Fix in #576

@omarzl
Copy link

omarzl commented Oct 10, 2019

could you please create a new tag (maybe 2.13.1) so this change is included?
The tag 2.13.0 was created before this pr get merged 😞

@cocojoe
Copy link
Member

cocojoe commented Oct 11, 2019

Yes, will release on Monday. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants