react-native-webview: [Crash] WebView inside ScrollView crash on scroll end - Android
Bug description: When I try to put a webview inside a scroll view along with other native content, the app crashes when scroll reaches the end. I have tried various different possibilities to check if it has something to do with my code but it seems otherwise.
Things work fine on iOS side, only Android side crashes.
To Reproduce: Even a simple code as this one below should reproduce the bug, it does on my side.
const dummyString = `Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
Why do we use it?
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
Where does it come from?
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.`
const html = '<p>This is web body</p>'
return (
<ScrollView>
<WebView style={{height:200}} scrollEnabled={false} source={{html}} ></WebView>
<Text>{dummyString}</Text>
</ScrollView>
);
Example app with reproduction code: https://github.com/noumantahir/react-native-webview-scrollview-crash
Screenshots/Videos:
https://user-images.githubusercontent.com/6298342/152299012-d684fbe6-3f45-4e60-96ff-2a86cf0c7c5a.mov
Environment:
- OS: Android
- OS version: 31
- react-native version: 0.67.2
- react-native-webview version: 11.17.1
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 16
- Comments: 37
@noumantahir Did you try to add
overScrollMode="never"?https://reactnative.dev/docs/scrollview#overscrollmode-android
add in scrollView props
removeClippedSubviews={true}work for me.
Thanks for the tip @phuongwd this worked like a charmm, saved us so much frustration…
+1 I have the same on android 12
Silly me, I was adding
overScrollMode="never"to theWebView, but instead it should be forScrollViewof course. Thank you! Works like a charm.Same problem, but, even with the tip above applied, crash persists if you navigate back (
@react-navigation/stack). Need a proper solution for this issue.I think this issue is connected with #1915 and #429
remove removeClippedSubviews={true} prop in ScrollView and remove opacity={{0.99}} prop in WebView , just add overScrollMode=‘never’ in ScrollView works for me
You are a genius. You solved my 9hours problem.
Using
removeClippedSubviews={true}andoverScrollMode="never"together worked for me! Thanks a lot guys!Same problem here and the tip by @phuongwd works great.
This is because of the over scrolled occur in react native try to use this:- overScrollMode=“never”
renderToHardwareTextureAndroid={true} if u set it to webview parent (for its View), so crash will not reproduce
i’m using import { WebView } from ‘react-native-webview’, implementing
opacity:0.99doesn’t work for me until i change to import { WebView } from ‘react-native’ and addopacity:0.99With the fix in that PR, yes.
Same problem, and
overScrollModedoesn’t work. Still trying to dig out. My crash result in a hwui native crash like:It’s only happened on Android 12 with Qualcomm Gen 1
ok, I finally realized it’s dup to https://github.com/react-native-webview/react-native-webview/issues/1915
+1