react-native-webview / react-native-webview

React Native Cross-Platform WebView
https://github.com/react-native-community/discussions-and-proposals/pull/3
MIT License
6.31k stars 2.96k forks source link

WebView Crashing #3383

Closed asutariyadigit closed 2 days ago

asutariyadigit commented 2 months ago

Hi My App crashing the below Error: com.facebook.react.views.view.ReactClippingViewManager.getChildCount java.lang.ClassCastException - com.reactnativecommunity.webview.d cannot be cast to com.facebook.react.views.view.ReactViewGroup

To Reproduce: if we Continue move between From Webview to View Component by Pressing hardware back button.

Expected behavior:

Screenshots/Videos:

Environment:

Fatal Exception: java.lang.ClassCastException: com.reactnativecommunity.webview.d cannot be cast to com.facebook.react.views.view.ReactViewGroup at com.facebook.react.views.view.ReactClippingViewManager.getChildCount() at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:70) at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.dropView(ReanimatedNativeHierarchyManager.java:7) at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:104) at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.dropView(ReanimatedNativeHierarchyManager.java:7) at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:104) at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.dropView(ReanimatedNativeHierarchyManager.java:7) at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:104) at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.dropView(ReanimatedNativeHierarchyManager.java:7) at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:104) at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.dropView(ReanimatedNativeHierarchyManager.java:7) at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:104) at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.dropView(ReanimatedNativeHierarchyManager.java:7) at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:104) at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.dropView(ReanimatedNativeHierarchyManager.java:7) at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:104) at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.dropView(ReanimatedNativeHierarchyManager.java:7) at com.facebook.react.uimanager.NativeViewHierarchyManager.dropView(NativeViewHierarchyManager.java:104) at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.dropView(ReanimatedNativeHierarchyManager.java:7) at com.facebook.react.uimanager.NativeViewHierarchyManager.manageChildren(NativeViewHierarchyManager.java:304) at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.manageChildren(ReanimatedNativeHierarchyManager.java:13) at com.facebook.react.uimanager.UIViewOperationQueue$ManageChildrenOperation.execute(UIViewOperationQueue.java:14) at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:135) at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:53) at com.facebook.react.uimanager.UIViewOperationQueue.access$2600(UIViewOperationQueue.java) at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:31) at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java) at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:46) at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:2) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1140) at android.view.Choreographer.doCallbacks(Choreographer.java:946) at android.view.Choreographer.doFrame(Choreographer.java:870) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1127) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:210) at android.os.Looper.loop(Looper.java:299) at android.app.ActivityThread.main(ActivityThread.java:8292) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)

netmaxt3r commented 2 months ago

@asutariyadigit looks like you have reanimated , can you post your jsx view hierarchy?

asutariyadigit commented 2 months ago

@netmaxt3r Please find JSX structure.

return ( <> <View style={{ marginTop: StatusBar.currentHeight, marginBottom: 0 }}> <Header homeScreen={true} navigateHome={true} isProgressBarShown={false} leftActionPress={() => { this.props.navigation.openDrawer(); }} />

    <StatusBar
      barStyle="dark-content"
      hidden={false}
      backgroundColor="#ffffff"
      translucent={true}
    />
    <WebView
      ref={(ref) => (this.WEBVIEW_REF = ref)}
      source={{ uri: redirectionLink }}
      onNavigationStateChange={(event) =>{
        var url = event.url;
        this.onNavigationStateChange(event);
          if(url.includes("/KYC")){
          this.props.navigation.navigate("KYCScreen", {kycUrl : url, flow : 'mmmmmm', data : this.state.afData });
        }
      }
    }
      javaScriptEnabledAndroid={true}
      javaScriptEnabled={true}
      automaticallyAdjustContentInsets={false}
      startInLoadingState={true}
      removeClippedSubviews={true}
      allowsBackForwardNavigationGestures={true}
      // injectedJavaScript={hideHeaderInWebView}     script.
      onLoadProgress={(progress) => {
        console.log("progress", progress);
        if (this.state.url !== progress.nativeEvent.url)
          this.onNavigationStateChange(progress.nativeEvent);
      }}
      onError={(syntheticEvent) => {
        const { nativeEvent } = syntheticEvent;
        onErrorhandler(nativeEvent);
        this.props.navigation.goBack();
      }}
      onMessage={(data)=>{ this.triggerEvents(data)}}
      setSupportMultipleWindows={false}
      onShouldStartLoadWithRequest={event => this.onShouldStartLoadWithRequest(event)}
       renderLoading={() => {
         return <Spinner animating />;
       }}
    />
  </>
);

} }

asutariyadigit commented 2 months ago

WhatsApp Image 2024-04-06 at 1 10 46 AM ![Uploading WhatsApp Image 2024-04-07 at 1.52.23 PM.jpeg…]()

asutariyadigit commented 2 months ago

@netmaxt3r @alloy Please any solution?

netmaxt3r commented 2 months ago

@asutariyadigit i am not able to reproduce the issue with code you have provided works fine with bare project and your code ( with minor modifications ). the root cause must be somewhere else, with your higher wrapping components. where does your View import is from? is it animated View ? if yes try changing to View from react-native

asutariyadigit commented 2 months ago

@netmaxt3r Thanks for your response View is not imported from animated view it is taken only View from react-native.To Reproduce:** if we Continue move between From Webview to View Component by Pressing hardware back button.

netmaxt3r commented 2 months ago

if we Continue move between From Webview to View Component by Pressing hardware back button

that suggests you need to look into your navigation setup, try turn off any animation you have between screen navigation, update reanimated library and check

asutariyadigit commented 2 months ago

Hi @netmaxt3r stop animation in Stack navigator as well individual component but still have issue

netmaxt3r commented 2 months ago

@asutariyadigit sorry mate i have no other suggestion to help you out of this crash :(

github-actions[bot] commented 1 week ago

Hello 👋, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically

asutariyadigit commented 2 days ago

@netmaxt3r Any Solution for that.