-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebView rerender crashes on Android API 28+ #1915
WebView rerender crashes on Android API 28+ #1915
Comments
I am also getting this crash error in Android real device only. In older Version of Android, It's working fine. Let me know if any solution for this. |
Hello @Invertisment , |
Thank you. |
@mehul2013 , I've tried options={{animationEnabled: false}} but it seems that it is not working for the latest versions of Android. |
@Invertisment may I ask what library did you use for WebView? |
@pepemiso16 Set WebView inside View:
Set injectedJavaScript:
Set dynamic Height:
I am hoping that above code may resolve your issue. |
@mehul2013 seems that that one didn't work. Thanks though. |
Instead of this recaptcha3 lib: https://github.com/jarden-digital/react-native-recaptchav3 I used this recaptcha2 library: https://github.com/xuho/react-native-google-recaptcha-v2. These libraries are not interchangeable, recaptcha_v2 and recaptcha_v3 are a different thing. |
a workaround is to set the style of WebView to |
The workaround that worked for me was:
|
I also was faced with a crash when I was trying to navigate to a non-webview component.
|
on react-navigation
this worked for me. all iOS options work. <Stack.Screen
name="MyTestScreen"
options={{
headerShown: false,
cardStyleInterpolator: CardStyleInterpolators.forVerticalIOS,
}}
> |
It looks like android 12 (SDK 31) has a "bounce" animation for scrollviews. This also triggers the crash fortunately the opacity workaround still works. |
@LonelyCpp, you didn't mention any new evidence. Also this is what the before-mentioned PR is about: https://github.com/newsuk/times-components-native/pull/462 |
Another solution to fix this is to mount the html view after the interaction manager is complete.
|
Also started getting crashes on Android 12 recently, seems to be related to WebViews inside a ScrollView (the new overscroll effect)
|
Thanks, @markstreich. Tip: If you want to disable it globally, the easiest way is probably to do it in your <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
{...}
<item name="android:overScrollMode">never</item>
</style> Reference: https://stackoverflow.com/a/17283061 |
Many thanks for the quick fix, is there a longer term solution somewhere which allows overscroll to remain enabled? |
Thanks @markstreich, I prefer your workaround because it seems to me that |
Its work! Thanks a lot |
|
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 |
It's not fixed. |
Made a repro for this in #2771 |
<Stack.Screen worked for me. |
This is finally fixed by #2874. PR is not yet merged, but we've been successfully using those changes using |
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 |
Not fixed yet |
It's still happening, Android 13 (SDK 33). |
Use |
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 |
这是来自QQ邮箱的假期自动回复邮件。 您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
|
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 |
for react navigation v6 and > options={{ animation: 'none' }} |
This issue still exists but the opacity workaround worked for me: import { forwardRef } from "react"
import { StyleSheet } from "react-native"
import { WebView, WebViewProps } from "react-native-webview"
const CustomWebView = forwardRef((props: WebViewProps) => {
return <WebView {...props} style={styles.webView} />
})
export default CustomWebView
const styles = StyleSheet.create({
webView: {
opacity: 0.99,
},
}) |
Bug description:
I tried to use this library: https://github.com/jarden-digital/react-native-recaptchav3. It uses JS in a
WebView
to fetch a captcha token from the web.When I render the component then initially nothing bad happens and everything works. I get the captcha token and I can use it later. The error happens when I get the token and go back to a previous app screen (not
WebView
page) which destroys theWebView
. When I rererender theWebView
then the app exits due to an error.I consider this a normal use as I want to create a form that has a captcha where user can go back and retry at any time.
Related issues:
I get a different stacktrace than facebook/react-native#25494.
One user posted a similar stack trace to mine in that same thread: facebook/react-native#25494 (comment). I think that stacktrace is related to this issue as the library from his stacktrace is a different one than OP's and the same as from my stacktrace.
I also registered this issue: jarden-digital/react-native-recaptchav3#14. But as it's a more general issue I decided to register one here as well.
I think these people have a fix for a similar crash but it didn't work for me:
https://github.com/celo-org/celo-monorepo/blob/db83744270f29ec748cdee422f08d3e9c4c40af7/packages/mobile/src/components/WebView.tsx
I can't catch this error using an
ErrorBoundary
component as it instantly kills the whole app. It's an error outside of JS.This didn't help:
hardwareAccelerationDisabledAndroid={true}
, this didn't help too:style={{opacity: 0.99}}
.To Reproduce:
Use recaptcha component from the library as it's intended in the README file.
This should also impact other similar libraries. Not only the ones intended for captchas.
Regular use:
The crash persists if I switch to a different activity via
onPause
:The crash doesn't persist if I kill the app completely (prevents the crash for the next render):
Expected behavior:
Rerendering and
onPause+onResume
should not result in a crash.Screenshots/Videos:
I have this stack trace from logcat:
Environment:
5.10
~0.63.4
^11.2.4
Devices I tested:
Android emulator with API 30 - crashes
Android emulator with API 29 - crashes
Android emulator with API 27 - works
Android physical with API 21 - works (android 7.0)
The text was updated successfully, but these errors were encountered: