software-mansion / react-native-gesture-handler

Declarative API exposing platform native touch and gesture system to React Native.
https://docs.swmansion.com/react-native-gesture-handler/
MIT License
5.85k stars 954 forks source link

java.lang.IllegalStateException: Expect view tag to be set on CodePush restart #715

Closed jakemmarsh closed 2 years ago

jakemmarsh commented 4 years ago

My app is running react-native 0.60.4 and react-native-gesture-handler 1.3.0. It also uses react-native-code-push 5.6.0 for OTA updates.

It checks for and installs any new updates on app launch. After installation, the app is restarted with the new version. Upon restart, my Android users are frequently hitting an exception:

IllegalStateException
Expect view tag to be set for com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView{3cdcdcc V.E...... ........ 0,0-1440,2392}
com.swmansion.gesturehandler.react.RNGestureHandlerRootHelper in <init> at line 45
com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView in initialize at line 49
com.swmansion.gesturehandler.react.RNGestureHandlerModule$2 in execute at line 603
com.facebook.react.uimanager.UIViewOperationQueue$UIBlockOperation in execute at line 530
com.facebook.react.uimanager.UIViewOperationQueue$1 in run at line 844
com.facebook.react.uimanager.UIViewOperationQueue in flushPendingBatches at line 952
com.facebook.react.uimanager.UIViewOperationQueue in access$2200 at line 44
com.facebook.react.uimanager.UIViewOperationQueue$2 in runGuarded at line 910
com.facebook.react.bridge.GuardedRunnable in run at line 24
android.os.Handler in handleCallback at line 873
android.os.Handler in dispatchMessage at line 99
android.os.Looper in loop at line 193
android.app.ActivityThread in main at line 6718
java.lang.reflect.Method in invoke
com.android.internal.os.RuntimeInit$MethodAndArgsCaller in run at line 495
com.android.internal.os.ZygoteInit in main at line 858

Any previous issues I've found around this exception mention issues with componentDidMount state logic inside gesture handler components. However, I don't believe I'm doing any of that. The only component I'm using directly is Swipeable.

kaanduraa commented 4 years ago

same issue for react native 0.59.5 react-native-code-push 5.6.0 react-native-gesture-handler 1.1.0

HarshitMadhav commented 4 years ago

@jakemmarsh Follow this comment https://github.com/facebook/react-native/issues/25924#issuecomment-517894044

for react-native version > 0.60 you are missing the androidx support for the react native gesture handler as react-native gesture handler is not upgraded yet for androidx support.

kaanduraa commented 4 years ago

@HarshitMadhav error also exists for version 0.59.5, below 0.60

HarshitMadhav commented 4 years ago

@capslock35 because by default androidx is enabled and this react-native gesture handler doesnt have the support for androidx till now. Run the command gradlew app:dependencies in android folder to know which libraries of your project are using androidx

asleepace commented 4 years ago

Any update for this, happening to me on react native 0.59.10?

HarshitMadhav commented 4 years ago

@Asleepace read out my last comment

asleepace commented 4 years ago

@HarshitMadhav androidx is only on react native 0.60+ but I'm using a lower version and this still occurs on some android devices. Seems to be a race condition.

HarshitMadhav commented 4 years ago

No, somehow your project might be using the updated androidx support third party library. run gradlew app:dependencies to check which library is using androidx and try running the project removing that library and then installing the android library only.

mrigo commented 4 years ago

Hello, I've the same problem here, using react native 0.60.5, I've this error:

Expect view tag to be set for com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView

I'm using jetifier but still having this issue..

learnyst commented 4 years ago

We are also facing the same issue. We are using Reacr-native 60.4 and also using code-push

learnyst commented 4 years ago

@HarshitMadhav we are using RN 0.60.4 and also code push. RN 0.60.4 uses androidx. How to resolve this issue for RN 0.60.4? also we noticed this issue only after code push update

skoob13 commented 4 years ago

We're also facing this issue. I can't say definitely that the issue appears after Code Push update, but I see logs for users, that haven't installed the update yet.

RN: 0.59.10 RNGH: 1.4.1

mrigo commented 4 years ago

Check that your view is a real view, a react component, and that the view is the only thing currently on the screen. I've added an alert("ok") for testing the startup of the app in the index.js file (shame on me) and the alert was the view on the screen at the startup of the app, so react native gesture was searching for the tag on an alert and not on a component...

tylorr commented 4 years ago

We are seeing this issue with the following versions, we also run jetifier on postinstall

"react-native": "0.61.2"
"react-native-gesture-handler": "1.4.1"
"react-native-code-push": "5.6.0"

Any suggestion on a path forward?

schumannd commented 4 years ago

facing the same issue in RN 61.4

"react-native": "0.61.4",
"react-navigation": "4.0.10",
"react-navigation-stack": "1.10.3",
"react-navigation-tabs": "2.5.6",
"react-native-gesture-handler": "1.5.0",
schumannd commented 4 years ago

@jakemmarsh how did you end up working around this bug?

jakemmarsh commented 4 years ago

@schumannd unfortunately I didn't. Priorities have shifted but the bug was still occurring last I knew.

tylorr commented 4 years ago

My issue was caused by attempting to navigate to a different screen while CodePush was trying to restart. Stopping that fixed the issue for me.

danut-t commented 3 years ago

Hello, any updates for this? The same issue is still happening with the following versions:

"react-native": "0.61.5",
"react-native-code-push": "6.2.0",
"react-native-gesture-handler": "1.6.1",
"react-navigation": "4.3.9"
gif0101 commented 3 years ago

Same issue as danut-t with :

"react-native": "0.61.5",
"react-native-code-push": "6.2.0",
"react-native-gesture-handler": "1.6.1",
"react-navigation": "4.3.9"
grantgeorge commented 3 years ago

We're getting this error as a crash for prod builds.

I can confirm it's after a CodePush sync has been fired

fukuball commented 3 years ago

Same issue

"react-native": "0.61.5", "react-native-code-push": "6.2.1", "react-native-gesture-handler": "1.6.1", "react-navigation": "4.4.0"

crwecker commented 3 years ago

Same issue

"react-native": "0.63.2", "react-native-code-push": "6.3.0", "react-native-gesture-handler": "1.7.0", "@react-navigation/native": "5.7.3"

ANIBIT14 commented 3 years ago

Same issue in our production app hope someones provide a solution: react-native: 062.2 "react-native-gesture-handler": "version": "1.7.0", "react-navigation": "version": "4.3.9",

luatnd commented 3 years ago

Trying to navigate when codePush.restartApp() cannot reproduce the error :(

nadav2051 commented 3 years ago

Happening to me too, RN63.3, RNGestureHandler: "react-native-gesture-handler": "1.6.1", "react-native": "0.63.3",

ulbekovad commented 3 years ago

We've got a lot of cases with such issue in Crashlytics. Mostly for Android 9, 10 and 11. "react-native-gesture-handler": "1.6.0", "react-native": "0.62.2".

@HarshitMadhav should adding "npx jetify" at the postinstall step fix such issue?

chgsilva commented 3 years ago

same issue here, any workarounds?

snehalm-iprogrammer commented 3 years ago

Fatal Exception: java.lang.IllegalStateException: java.lang.IllegalStateException: Expect view tag to be set for com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView{bbcb787 V.E...... ........ 0,0-1080,2400} at com.facebook.react.bridge.ReactContext.handleException(ReactContext.java:390) at com.facebook.react.bridge.ReactContext$ExceptionHandlerWrapper.handleException(ReactContext.java:397) at com.facebook.react.bridge.GuardedRunnable.run(GuardedRunnable.java:33) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:224) at android.app.ActivityThread.main(ActivityThread.java:7565) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

Got this error on google console and there are many crashes due to it. Any solution?

netshade commented 3 years ago

I also get a fair number of crashes here. Looking at the code that triggers it here: https://github.com/software-mansion/react-native-gesture-handler/blame/master/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.java#L44-L47 , I'm trying to understand what would cause it to get into this state. The React Native code that exercises it ( https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java#L100-L107 by way of https://github.com/software-mansion/react-native-gesture-handler/blob/master/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.java#L603 ) seems to absolutely have a tag associated with the View ( otherwise, how could the exception even be reached? ), but the id of the View is < 1. And that is also confusing to me, because my reading of that seems to indicate that any id < 1 is invalid, but my presumption looking at Android / the view resolver is that any integer value of id that is not View.NO_ID ( -1 , see: https://developer.android.com/reference/android/view/View?authuser=3#NO_ID ) is a valid id. However, is there some other React Native protocol that needs to be followed here? Is View id 0 special somehow and that is also being accommodated for? I'd be happy to submit a PR that is in the neighborhood of trying to address this, but would want to know that I'm not ignoring other React Native protocols that are in play here.

cc @kmagiera who wrote the original exception here, just in case you have any insight afa what might be up.

kkafar commented 2 years ago

Can any one verify, that the problem disappears when this PR is released (or try building from source)?