react-native-device-info: Required dispatch_sync to load constants for RNDeviceInfo. This may lead to deadlocks
I’m getting this warning on 0.49.5
Required dispatch_sync to load constants for RNDeviceInfo. This may lead to deadlocks
Everything seems to function fine, but I’m wondering what does this exactly mean?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 60
- Comments: 52
Still an issue on RN v0.56.0
@compojoom move the libRNDeviceInfo.a to the bottom of linked frameworks and libraries
I think I found how to resolve this issue: the issue is caused by the fact that the module requires the main queue (https://github.com/rebeccahughes/react-native-device-info/blob/master/ios/RNDeviceInfo/RNDeviceInfo.m#L31) while the app’s loading, it seems to be wrong for some reason so we need the
requiresMainQueueSetup
to returnNO
.Unfortunately doing so would cause a crash since when the lib loads it needs to be in the UI Thread because it silently instantiate a UIWebView to get the device User Agent.
IMHO we should defer this task and transform the
userAgent
field into agetUserAgent
method (likeisPinOrFingerprintSet
andgetBatteryLevel
), it would allow us to achieve lazy loading for this property, solving this issue.Warning still there. React Native 0.57.4
Warning still there. React Native 0.57.3
Updating the library or moving the libRNDeviceInfo.a to the bottom of linked frameworks and libraries did not help in my case
Thanks, @haystome - your note lead me to update the library to the latest,
0.15.3
(updated from0.14.0
), and it worked!Not sure what version or commit fixed the problem, but for me it’s working on
0.15.3
after updating and then un-linking and re-linking the library. Output:This warning only appears when we call a function from the RNDeviceInfo module in our initial render stage.
I’m guessing this has something to do with the synchronous nature of the call (in our case: ‘getUniqueID’), resulting in the whole app locking up until the function returns.
Warning still there.
React Native 0.57.3
Same here 😦
RN: 0.57 react-native-device-info: 0.22.5
Issue is still present in 0.21.4.
Same here. React Native 0.57.7
For me the YellowBox is now showing this warning since I upgraded from RN 0.55.4 to 0.56.
@machour PR #442 is ready to be tested, I didn’t modify the changelog since I don’t know what you want to do with the semver (I guess the changelog will have to be modified in the process). I integrated the new way of getting user agent @maxkomarychev suggested
+1
RN 0.48.4
There is also this warning in console:
@psegalen can we bring back
requiresMainQueueSetup
to returnYES
?I see no problem with module being initialized on main thread in general.
The bigger problem is to have
dispatch_sync
called with main thread from main thread. Which I’m assuming what was wrong with webview operation - which we solved.looks like we have a solution in #442, great job @psegalen !
Also the current way of getting user agent is now deprecated. New version is async: https://developer.apple.com/documentation/uikit/uiwebview/1617963-stringbyevaluatingjavascriptfrom?language=objc
Hi @psegalen, by all means yes. This will be a bc breaking release though, we’ll need to semver that properly
@antoinerousseau did you tried to ullink and link the pakges? see this and this