Skip to content
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

react navigation stack + react native screens + react native webview will crash (null pointer dereference) when the pop stack #6960

Closed
gaodeng opened this issue Feb 5, 2020 · 8 comments

Comments

@gaodeng
Copy link

gaodeng commented Feb 5, 2020

Current Behavior

react navigation stack + react native screens + react native webview will crash (null pointer dereference) when the pop stack

Expected Behavior

working fine

How to reproduce

react navigation stack + react native screens + react native webview will crash (null pointer dereference) after the pop webview's stack screen

Your Environment
latest

software version
iOS or Android ANDROID
react-navigation
react-navigation-stack
react-native-gesture-handler
react-native-safe-area-context
react-native-screens
react-native
expo
node
npm or yarn
@yzalvov
Copy link

yzalvov commented Feb 18, 2020

Same here. Both, Android emulator and real device. I use react-native-community WebView, and the following trick solved the problem for me. No more crashes.

...
<WebView
  androidHardwareAccelerationDisabled={true}
...

Credits to @emeraldsanto on stackoverflow.

@satya164 satya164 transferred this issue from react-navigation/stack Feb 24, 2020
@satya164
Copy link
Member

This seems like something which needs to be fixed in react-native-webview. Closing since it's not actionable for us and workaround is mentioned.

@Nantris
Copy link

Nantris commented May 11, 2021

The updated solution for this is androidLayerType="software", since androidHardwareAccelerationDisabled is now deprecated.

@andreialecu
Copy link

Leaving this here for future readers:

androidLayerType="software" has been making certain web content render as transparent/invisible for us. I would be able to long press to select text, and things like links would be clickable (and trigger navigation) but still everything would basically be invisible (as if rendered with opacity: 0).

Some HTML would render properly, but other wouldn't. Be careful with androidLayerType="software".

@github-actions
Copy link

github-actions bot commented Jan 6, 2022

Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro.

@Hmoulvad
Copy link

I can confirm by adding androidLayerType="software" it works. Adding prop androidHardwareAccelerationDisabled doesn't seem to do anything.

@Aszurar
Copy link

Aszurar commented Nov 12, 2022

With me the androidHardwareAccelerationDisabled property didn't solve it , I even tried disabling hardware acceleration directly in AndroidManifest with <activity android:hardwareAccelerated="false" /> , it even solved the problem, but the app's performance/fluidity dropped a lot, it got low fps so I don't think it's viable.

The androidLayerType="software" property avoided the crash of react native render html/react native webview with videos, but when using it, it made the videos not work anymore(the video no longer showed image, only sound) and as mentioned above, sometimes it visually affected some HTML.

So, taking a look at the possible values it could receive, I used it as: androidLayerType="hardware" and it worked perfectly, whether on the emulator or physical Android device.
(https://github.com/react-native-webview/react-native-webview/blob/master/docs/Reference.md#androidlayertype)

Any problems using with the value as hardware?

import RenderHtml from 'react-native-render-html';
...
    <RenderHtml
      renderers={{ iframe: IframeRenderer }}
      WebView={WebView}
      defaultWebViewProps={{
        androidLayerType: 'hardware',
      }}
      contentWidth={width * 0.9}
      source={{ html: html.replace(/src="\/\//g, 'src="https://') }}
      customHTMLElementModels={{ iframe: iframeModel }}
      renderersProps={{ iframe: { scalesPageToFit: true } }}
    />

@LunatiqueCoder
Copy link

androidHardwareAccelerationDisabled did not work for me, but the following solution did:

react-native-webview/react-native-webview#811 (comment)

    <WebView
      style={{ opacity: 0.99 }}
    />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants