fix(android): sometimes view tag is not resolved immediately#3074
fix(android): sometimes view tag is not resolved immediately#3074
Conversation
|
@WoLewicki @j-piasecki Sometimes this code seems to raise an exception
I assume this is some kind of race condition. I assume it's possible that the tag => View association has yet not been made on the native side, when we're already called a method on the view module. My ugly workaround so doing another loop in the ui queue, if the first one we've not found the tag. It seems to work, but do you have a better suggestion? Exception in native call
com.facebook.react.uimanager.IllegalViewOperationException: Trying to resolve view with tag 569 which doesn't exist
at com.facebook.react.uimanager.NativeViewHierarchyManager.resolveView(NativeViewHierarchyManager.java:102)
at com.facebook.react.uimanager.UIManagerModule.resolveView(UIManagerModule.java:870)
at com.rnmapbox.rnmbx.components.mapview.NativeMapViewModule.withMapViewOnUIThread$lambda$0(NativeMapViewModule.kt:30)
at com.rnmapbox.rnmbx.components.mapview.NativeMapViewModule.$r8$lambda$HbfWzkRxa1r9gGwoHqVmAHlh0JU(Unknown Source:0)
at com.rnmapbox.rnmbx.components.mapview.NativeMapViewModule$$ExternalSyntheticLambda0.run(Unknown Source:8)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8176)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
|
|
I thought that maybe we should do the same thing as on maps/ios/RNMBX/RNMBXMapViewModule.mm Line 25 in 20d6ad9 Android unfortunately. I think your solution is closest to what we can do about it. We do something quite similar in react-native-svg where there are more attempts to make it work: https://github.com/software-mansion/react-native-svg/blob/f9c7d8a807c8dc5b21e8ac0358a9bf7a820a1f61/android/src/main/java/com/horcrux/svg/SvgViewModule.java#L66. There are more options there, you can check it in the code of the above file.
|
d0eb1c4 to
4fffe97
Compare
Thanks, much! I've ended up using the same technique, queue functions depending on the view until |
Fixes the folllowing warning on android:
Can be reproduce with this example:
See also: https://github.com/software-mansion/react-native-reanimated/pull/2982/files