Description:
I get this error printed to my console in xcode, almost every time (but not every time) I call OneSignal.registerForPushNotifications() on a freshly installed version of my app, which results in a 5-10 seconds freeze of the whole app UI.
Environment
Onesignal: v3.2.12
React native: 0.59.5
iOS: 12.2
Anything else:
Full message is
Main Thread Checker: UI API called on a background thread: -[UIApplication registerForRemoteNotifications]
PID: 1821, TID: 772156, Thread name: (none), Queue name: com.facebook.react.OneSignalQueue, QoS: 0
Backtrace:
4 MY_APP_NAME 0x0000000102f9a774 +[OneSignal registerForAPNsToken] + 432
5 MY_APP_NAME 0x0000000102fafcf0 -[OneSignalNotificationSettingsIOS10 promptForNotifications:] + 244
6 MY_APP_NAME 0x0000000102f9abc8 +[OneSignal promptForPushNotificationsWithUserResponse:] + 252
7 MY_APP_NAME 0x0000000102f83724 -[RCTOneSignalEventEmitter registerForPushNotifications] + 52
8 CoreFoundation 0x00000001af74fba0 <redacted> + 144
9 CoreFoundation 0x00000001af631c90 <redacted> + 292
10 CoreFoundation 0x00000001af6328c4 <redacted> + 60
11 MY_APP_NAME 0x0000000102ce7d54 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2064
12 MY_APP_NAME 0x0000000102d7ea54 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 664
13 MY_APP_NAME 0x0000000102d7e5c4 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 144
14 MY_APP_NAME 0x0000000102d7e528 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28
15 libdispatch.dylib 0x0000000103e6b6f0 _dispatch_call_block_and_release + 24
16 libdispatch.dylib 0x0000000103e6cc74 _dispatch_client_callout + 16
17 libdispatch.dylib 0x0000000103e74bf4 _dispatch_lane_serial_drain + 712
18 libdispatch.dylib 0x0000000103e758b4 _dispatch_lane_invoke + 456
19 libdispatch.dylib 0x0000000103e7f77c _dispatch_workloop_worker_thread + 1148
20 libsystem_pthread.dylib 0x00000001af369114 _pthread_wqthread + 304
21 libsystem_pthread.dylib 0x00000001af36bcd4 start_wqthread + 4
Could you please include the entire log in a pastebin?
@rgomezp Yes of course. Can you point me in the direction of where to get the full log that you need?
@krismeld ,
We have some docs with the instructions.
Closing due to inactivity
Hi @rgomezp - we are getting this issue 100% of the time in our react native iOS application.
I _believe_, but do not know with certainty, that in addition to:
+(BOOL)requiresMainQueueSetup {
return YES;
}
at https://github.com/geektimecoil/react-native-onesignal/blob/41ed4ef20719f613746923a03d92bda8f9118a55/ios/RCTOneSignal/RCTOneSignalEventEmitter.m#L24 the following may also be required to ensure that the relevant UI API is never called from a background thread:
- (dispatch_queue_t)methodQueue
{
return dispatch_get_main_queue();
}
based on my reading of https://facebook.github.io/react-native/docs/native-modules-ios#threading - or, alternatively, dispatching the permissions request in particular on the main queue (which would be a bit less heavy-handed).
Our full log of the event in question is as follows:
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIApplication registerForRemoteNotifications]
PID: 2604, TID: 3343089, Thread name: (none), Queue name: com.facebook.react.OneSignalQueue, QoS: 0
Backtrace:
4 Drivetime 0x0000000104724660 +[OneSignal registerForAPNsToken] + 432
5 Drivetime 0x0000000104739bdc -[OneSignalNotificationSettingsIOS10 promptForNotifications:] + 244
6 Drivetime 0x0000000104724ab4 +[OneSignal promptForPushNotificationsWithUserResponse:] + 252
7 Drivetime 0x000000010471e1c0 -[RCTOneSignalEventEmitter promptForPushNotificationsWithUserResponse:] + 164
8 CoreFoundation 0x000000019d2f0900 <redacted> + 144
9 CoreFoundation 0x000000019d1d24d0 <redacted> + 292
10 CoreFoundation 0x000000019d1d3104 <redacted> + 60
11 Drivetime 0x00000001048530f4 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2064
12 Drivetime 0x00000001048ea0b4 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 664
13 Drivetime 0x00000001048e9c24 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 144
14 Drivetime 0x00000001048e9b88 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28
15 libdispatch.dylib 0x000000010698b6f0 _dispatch_call_block_and_release + 24
16 libdispatch.dylib 0x000000010698cc74 _dispatch_client_callout + 16
17 libdispatch.dylib 0x0000000106994bf4 _dispatch_lane_serial_drain + 712
18 libdispatch.dylib 0x00000001069958b4 _dispatch_lane_invoke + 456
19 libdispatch.dylib 0x000000010699f77c _dispatch_workloop_worker_thread + 1148
20 libsystem_pthread.dylib 0x000000019cf09114 _pthread_wqthread + 304
21 libsystem_pthread.dylib 0x000000019cf0bcd4 start_wqthread + 4
2019-06-26 13:54:19.362308-0700 Drivetime[2604:3343089] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication registerForRemoteNotifications]
PID: 2604, TID: 3343089, Thread name: (none), Queue name: com.facebook.react.OneSignalQueue, QoS: 0
Backtrace:
4 Drivetime 0x0000000104724660 +[OneSignal registerForAPNsToken] + 432
5 Drivetime 0x0000000104739bdc -[OneSignalNotificationSettingsIOS10 promptForNotifications:] + 244
6 Drivetime 0x0000000104724ab4 +[OneSignal promptForPushNotificationsWithUserResponse:] + 252
7 Drivetime 0x000000010471e1c0 -[RCTOneSignalEventEmitter promptForPushNotificationsWithUserResponse:] + 164
8 CoreFoundation 0x000000019d2f0900 <redacted> + 144
9 CoreFoundation 0x000000019d1d24d0 <redacted> + 292
10 CoreFoundation 0x000000019d1d3104 <redacted> + 60
11 Drivetime 0x00000001048530f4 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2064
12 Drivetime 0x00000001048ea0b4 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 664
13 Drivetime 0x00000001048e9c24 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 144
14 Drivetime 0x00000001048e9b88 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28
15 libdispatch.dylib 0x000000010698b6f0 _dispatch_call_block_and_release + 24
16 libdispatch.dylib 0x000000010698cc74 _dispatch_client_callout + 16
17 libdispatch.dylib 0x0000000106994bf4 _dispatch_lane_serial_drain + 712
18 libdispatch.dylib 0x00000001069958b4 _dispatch_lane_invoke + 456
19 libdispatch.dylib 0x000000010699f77c _dispatch_workloop_worker_thread + 1148
20 libsystem_pthread.dylib 0x000000019cf09114 _pthread_wqthread + 304
21 libsystem_pthread.dylib 0x000000019cf0bcd4 start_wqthread + 4
Please note that I have audited 100% of the logs from this session and the above are the only logs given from OneSignal. We have sensitive information elsewhere in the logs and because I see nothing else from OneSignal I do not believe giving more in a pastebin should be necessary or any more productive than what is provided here. Please let me know if there is anything else I can provide that would be helpful in confirming one of the proposed fixes; I'm happy to try my hand at sending a PR if that would help.
Also, since I forgot to mention it, this is on the latest version of the SDK (3.2.14 / 2.10.0).
Happens to me too, see #326
Howdy,
Apologies for the delay @cojo . Did you ever resolve this? We're happy to look at any PRs
@noway ,
Are you on the latest version of the SDK?
Howdy,
Apologies for the delay @cojo . Did you ever resolve this? We're happy to look at any PRs@noway ,
Are you on the latest version of the SDK?
I'm using:
"react-native-onesignal": "^3.5.0",
"react-native": "^0.61.4",
Hi y'all,
Thanks for your patience while we resolve
Edit: detailed reproduction steps or a blank project that reproduces it would be very helpful in expediting a solution for this
I'm seeing this too, are there any fixes for this?
Confirmed, either
- (dispatch_queue_t)methodQueue
{
return dispatch_get_main_queue();
}
works, or, wrap the error reported code in
dispatch_sync(dispatch_get_main_queue(), ^{
}
block.
in the file RCTOneSignalEventEmitter.m
The problem is, no idea which way is better.
Is there something I'm missing that makes this not a massive issue? Is there a workaround? I'm happy to submit a PR with code from @ulion if that would help get this fixed.
We're happy to review any submitted PRs! Thanks @maxschmeling
Happens to me as well. Please fix that little thing. It is not convenient to fork the lib.
Is there a fix for this issue? Our app has a ~5 second launch screen load time due to this issue.
it's in debug mode only :) ours the same
+1 calling promptForPushNotificationsWithUserResponse causes a 5 seconds delay in my app.
Howdy,
This fix will go out with the next release. Cheers
Most helpful comment
Howdy,
This fix will go out with the next release. Cheers