react-native-webview: Android 9: App crashes if hardware acceleration is enabled

Bug description: Our app crashes on Android 9 if the hardware acceleration was used in the webview. If I disable the hardware acceleration on the embedded webviews the app works fine. If I disable the acceleration in the AndroidManifest the app also works without crashes. So I think it has something to do with the webview implementation and their usage of the hardware acceleration on Android 9.

To Reproduce: The bug occurse in our currently productive app. The repository could be found here: postillonmedia/app

Expected behavior: The app should not crash when the acceleration is enabled 😄

Screenshots/Videos/Traces: Current reports of the Google-Play console image

One of the traces:

05-14 23:07:01.963 10286  7866 22340 W com.postillon: 0xebadde09 skipped times: 0
05-14 23:07:01.964 10286  7866 22340 F libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x1c in tid 22340 (RenderThread), pid 7866 (com.postillon)
05-14 23:07:02.049 10286 22987 22987 I crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone
05-14 23:07:02.051  1058  5437  5437 I /system/bin/tombstoned: received crash request for pid 22340
05-14 23:07:02.052 10286 22987 22987 I crash_dump32: performing dump of process 7866 (target tid = 22340)
05-14 23:07:02.065 10286 22987 22987 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-14 23:07:02.065 10286 22987 22987 F DEBUG   : Build fingerprint: 'samsung/beyond2lteeea/beyond2:9/PPR1.180610.011/G975FXXU1ASD5:user/release-keys'
05-14 23:07:02.065 10286 22987 22987 F DEBUG   : Revision: '26'
05-14 23:07:02.065 10286 22987 22987 F DEBUG   : ABI: 'arm'
05-14 23:07:02.065 10286 22987 22987 F DEBUG   : pid: 7866, tid: 22340, name: RenderThread  >>> com.postillon <<<
05-14 23:07:02.065 10286 22987 22987 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x1c
05-14 23:07:02.065 10286 22987 22987 F DEBUG   : Cause: null pointer dereference
05-14 23:07:02.065 10286 22987 22987 F DEBUG   :     r0  00000000  r1  e1b50d80  r2  eb08606d  r3  00000000
05-14 23:07:02.065 10286 22987 22987 F DEBUG   :     r4  00000000  r5  00000000  r6  a7aee7e0  r7  00000000
05-14 23:07:02.065 10286 22987 22987 F DEBUG   :     r8  00000000  r9  00000000  r10 00000000  r11 00000000
05-14 23:07:02.065 10286 22987 22987 F DEBUG   :     ip  eb5a3914  sp  c82b9fe0  lr  eaffcabd  pc  eb35e4b4
05-14 23:07:02.112 10286 22987 22987 F DEBUG   : 
05-14 23:07:02.112 10286 22987 22987 F DEBUG   : backtrace:
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #00 pc 003f14b4  /system/lib/libhwui.so (SkSurface::getCanvas()+4)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #01 pc 0008fab9  /system/lib/libhwui.so (android::uirenderer::skiapipeline::GLFunctorDrawable::onDraw(SkCanvas*)+1192)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #02 pc 0035a3b5  /system/lib/libhwui.so (SkDrawable::draw(SkCanvas*, SkMatrix const*)+212)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #03 pc 0035a967  /system/lib/libhwui.so (SkLiteDL::draw(SkCanvas*) const+154)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #04 pc 0034273d  /system/lib/libhwui.so (android::uirenderer::skiapipeline::RenderNodeDrawable::drawContent(SkCanvas*) const+272)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #05 pc 00342a53  /system/lib/libhwui.so (android::uirenderer::skiapipeline::RenderNodeDrawable::forceDraw(SkCanvas*)+202)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #06 pc 0035a345  /system/lib/libhwui.so (SkDrawable::draw(SkCanvas*, SkMatrix const*)+100)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #07 pc 0035a967  /system/lib/libhwui.so (SkLiteDL::draw(SkCanvas*) const+154)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #08 pc 0034273d  /system/lib/libhwui.so (android::uirenderer::skiapipeline::RenderNodeDrawable::drawContent(SkCanvas*) const+272)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #09 pc 00342a53  /system/lib/libhwui.so (android::uirenderer::skiapipeline::RenderNodeDrawable::forceDraw(SkCanvas*)+202)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #10 pc 0035a345  /system/lib/libhwui.so (SkDrawable::draw(SkCanvas*, SkMatrix const*)+100)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #11 pc 0035a967  /system/lib/libhwui.so (SkLiteDL::draw(SkCanvas*) const+154)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #12 pc 0034273d  /system/lib/libhwui.so (android::uirenderer::skiapipeline::RenderNodeDrawable::drawContent(SkCanvas*) const+272)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #13 pc 00342a53  /system/lib/libhwui.so (android::uirenderer::skiapipeline::RenderNodeDrawable::forceDraw(SkCanvas*)+202)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #14 pc 0035a345  /system/lib/libhwui.so (SkDrawable::draw(SkCanvas*, SkMatrix const*)+100)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #15 pc 0035a967  /system/lib/libhwui.so (SkLiteDL::draw(SkCanvas*) const+154)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #16 pc 0034273d  /system/lib/libhwui.so (android::uirenderer::skiapipeline::RenderNodeDrawable::drawContent(SkCanvas*) const+272)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #17 pc 00342a53  /system/lib/libhwui.so (android::uirenderer::skiapipeline::RenderNodeDrawable::forceDraw(SkCanvas*)+202)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #18 pc 0035a345  /system/lib/libhwui.so (SkDrawable::draw(SkCanvas*, SkMatrix const*)+100)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #19 pc 0035a967  /system/lib/libhwui.so (SkLiteDL::draw(SkCanvas*) const+154)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #20 pc 0034273d  /system/lib/libhwui.so (android::uirenderer::skiapipeline::RenderNodeDrawable::drawContent(SkCanvas*) const+272)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #21 pc 00342a53  /system/lib/libhwui.so (android::uirenderer::skiapipeline::RenderNodeDrawable::forceDraw(SkCanvas*)+202)
05-14 23:07:02.112 10286 22987 22987 F DEBUG   :     #22 pc 0035a345  /system/lib/libhwui.so (SkDrawable::draw(SkCanvas*, SkMatrix const*)+100)
05-14 23:07:02.113 10286 22987 22987 F DEBUG   :     #23 pc 0035a967  /system/lib/libhwui.so (SkLiteDL::draw(SkCanvas*) const+154)
05-14 23:07:02.113 10286 22987 22987 F DEBUG   :     #24 pc 0034273d  /system/lib/libhwui.so (android::uirenderer::skiapipeline::RenderNodeDrawable::drawContent(SkCanvas*) const+272)
05-14 23:07:02.113 10286 22987 22987 F DEBUG   :     #25 pc 00342a53  /system/lib/libhwui.so (android::uirenderer::skiapipeline::RenderNodeDrawable::forceDraw(SkCanvas*)+202)
05-14 23:07:02.113 10286 22987 22987 F DEBUG   :     #26 pc 0035a345  /system/lib/libhwui.so (SkDrawable::draw(SkCanvas*, SkMatrix const*)+100)
05-14 23:07:02.113 10286 22987 22987 F DEBUG   :     #27 pc 0035a967  /system/lib/libhwui.so (SkLiteDL::draw(SkCanvas*) const+154)
05-14 23:07:02.113 10286 22987 22987 F DEBUG   :     #28 pc 0034273d  /system/lib/libhwui.so (android::uirenderer::skiapipeline::RenderNodeDrawable::drawContent(SkCanvas*) const+272)
05-14 23:07:02.113 10286 22987 22987 F DEBUG   :     #29 pc 00342a53  /system/lib/libhwui.so (android::uirenderer::skiapipeline::RenderNodeDrawable::forceDraw(SkCanvas*)+202)
05-14 23:07:02.113 10286 22987 22987 F DEBUG   :     #30 pc 00097a0d  /system/lib/libhwui.so (android::uirenderer::skiapipeline::SkiaPipeline::renderLayersImpl(android::uirenderer::LayerUpdateQueue const&, bool, bool)+812)
05-14 23:07:02.113 10286 22987 22987 F DEBUG   :     #31 pc 00374d81  /system/lib/libhwui.so (android::uirenderer::skiapipeline::SkiaPipeline::renderFrame(android::uirenderer::LayerUpdateQueue const&, SkRect const&, std::__1::vector<android::sp<android::uirenderer::RenderNode>, std::__1::allocator<android::sp<android::uirenderer::RenderNode>>> const&, bool, bool, android::uirenderer::Rect const&, sk_sp<SkSurface>)+40)
05-14 23:07:02.113 10286 22987 22987 F DEBUG   :     #32 pc 00374497  /system/lib/libhwui.so (android::uirenderer::skiapipeline::SkiaOpenGLPipeline::draw(android::uirenderer::renderthread::Frame const&, SkRect const&, SkRect const&, android::uirenderer::FrameBuilder::LightGeometry const&, android::uirenderer::LayerUpdateQueue*, android::uirenderer::Rect const&, bool, bool, android::uirenderer::BakedOpRenderer::LightInfo const&, std::__1::vector<android::sp<android::uirenderer::RenderNode>, std::__1::allocator<android::sp<android::uirenderer::RenderNode>>
05-14 23:07:02.113 10286 22987 22987 F DEBUG   :     #33 pc 000a0963  /system/lib/libhwui.so (android::uirenderer::renderthread::CanvasContext::draw()+150)
05-14 23:07:02.113 10286 22987 22987 F DEBUG   :     #34 pc 00377791  /system/lib/libhwui.so (_ZNSt3__110__function6__funcIZN7android10uirenderer12renderthread13DrawFrameTask11postAndWaitEvE3$_0NS_9allocatorIS6_EEFvvEEclEv$c303f2d2360db58ed70a2d0ac7ed911b+576)
05-14 23:07:02.113 10286 22987 22987 F DEBUG   :     #35 pc 00341a9b  /system/lib/libhwui.so (android::uirenderer::WorkQueue::process()+122)
05-14 23:07:02.113 10286 22987 22987 F DEBUG   :     #36 pc 000aa13f  /system/lib/libhwui.so (android::uirenderer::renderthread::RenderThread::threadLoop()+178)
05-14 23:07:02.113 10286 22987 22987 F DEBUG   :     #37 pc 0000c08b  /system/lib/libutils.so (android::Thread::_threadLoop(void*)+166)
05-14 23:07:02.113 10286 22987 22987 F DEBUG   :     #38 pc 00064949  /system/lib/libc.so (__pthread_start(void*)+140)
05-14 23:07:02.113 10286 22987 22987 F DEBUG   :     #39 pc 0001e3c5  /system/lib/libc.so (__start_thread+24)

Environment:

  • OS: Android
  • OS version: 9
  • react-native version: 0.59.8
  • react-native-webview version: 5.8.2

Known devices

  • Galaxy Note9 (crownlte)

  • Galaxy Note8 (greatlte)

  • Galaxy S9 (starlte)

  • Galaxy S9+ (star2lte)

  • Galaxy S8 (dreamlte)

  • Galaxy S8+ (dream2lte)

  • P20 Pro (HWCLT)

  • Mate 10 Pro (HWBLA)

  • Mate 20 Pro (HWLYA)

  • P20 (HWEML)

  • Mate 20 (HWHMA)

  • Honor 10 (HWCOL)

  • Honor Play (HWCOR)

  • Mate 10 (HWALP)

  • Honor V10 (HWBKL)

  • P10 (HWVTR)

  • Honor 9 (HWSTF)

  • Honor 8X (HWJSN-H)

  • HONOR V20 (HWPCT)

  • HUAWEI P smart 2019 (HWPOT-H)

  • Mate 9 (HWMHA)

  • HUAWEI P30 lite (HWMAR)

  • Honor 10 Lite (HWHRY-H)

  • P10 Plus (HWVKY)

  • Mate 20 lite (HWSNE)

  • Xperia XZ1 Compact (G8441)

  • Xperia XZ1 (G8341)

  • Xperia XA2 (H3113)

  • Xperia XZ Premium (G8141)

  • Xperia XA2 Ultra (H4213)

  • Xperia 10 (I4113)

  • Pixel (sailfish)

  • Pixel 2 (walleye)

  • Pixel 2 XL (taimen)

  • Pixel 3 (blueline)

  • Pixel 3 XL (crosshatch)

  • moto g(6) (ali_n)

  • moto g(6) plus (evert_n)

  • moto g(6) play (aljeter)

All devices runs Android 9

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 9
  • Comments: 50 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Got the same issue here (Android 8, RN 0.59.10, RNN 2.22.3), one way to “fix” it without disabling animation on react-native-navigation or disabling it, application wide (via android:hardwareAccelerated="false" on manifest) is to just disable hw acceleration only on webview by setting androidHardwareAccelerationDisabled prop

<WebView
  androidHardwareAccelerationDisabled
  source={source}
/>

Disabling the animation in React-Navigation worked for me. If you are on React-Navigation 5, here is how to do it:

<NavigationContainer>
     <Stack.Navigator initialRouteName="HomeScreen">
          <Stack.Screen
            name="HomeScreen"
            component={HomeScreen}
            options={{
              animationEnabled: false,
            }}
          />
     </Stack.Navigator>
</NavigationContainer>

https://stackoverflow.com/a/60241167/2309061

So disabling the animations in react-native-navigation seems to fix the issue. Thanks @danielang!

I used this in order to fix the crash (and keep animations if supported):

  const hasAnimation = () => DeviceInfo.getAPILevel() !== 28;
  Navigation.setDefaultOptions({
    [...],
    animations: {
      dismissModal: { enabled: hasAnimation() },
      pop: { enabled: hasAnimation() },
      push: { enabled: hasAnimation() },
      setRoot: { enabled: hasAnimation() },
      showModal: { enabled: hasAnimation() },
    },
  })

I don’t know if it works in Android Q (API 29) so maybe a DeviceInfo.getAPILevel() > 28 would be better

Just here to say boy did this bug ever ruin my life for about 2 weeks and cause us to have to move back a launch.

@thanakij @Titozzz This is still an issue, please re-open this issue. Disabling hardwareAcceleration is not something we can do due to the software layer not being able to render larger batches of HTML.

Disabling the animation in React-Navigation worked for me. If you are on React-Navigation 5, here is how to do it:

<NavigationContainer>
     <Stack.Navigator initialRouteName="HomeScreen">
          <Stack.Screen
            name="HomeScreen"
            component={HomeScreen}
            options={{
              animationEnabled: false,
            }}
          />
     </Stack.Navigator>
</NavigationContainer>

https://stackoverflow.com/a/60241167/2309061

Glad to have found this thread, this gave us a clue that disabling animations could give us a fix.

Our case was slightly different as we were using react-native-screens for perf reasons and unfortunately for us, they had moved the documentation from RNN docs, which is now available here

We got it working after adding stackAnimation key to the options props for each of our screens under Stack.Navigator

<Stack.Screen options={{ stackAnimation: "none" }} name={"screenName"} component={Component} />

Below is the options you can try:

(1) <WebView androidLayerType="software" ... />

  • It would work but you will need to bear with the degraded performance instead.
  • Note: Another thing you can try is to set androidLayerType=“hardware”. It helps for some people.

(2) Disable react-native-screens for Platform.OS == 'android' and/or disable the animations of react-navigation in related screens with the WebView component.

(3) Try to prevent the crash

  • loading: Move HTML content into a state variable and then call setTimeout(this.setState({ html }), 1000) later to assign that variable with the actual value.
  • Note: This is to ensure that the animation would have already finished before the time when WebView comes in.
  • back+hardwareback: Make sure to setState({ html: undefined }) before navigating back (and starting the animation).

(4) Explore some alternatives, like react-native-render-html.

rn 0.62.2 still have this problem. please reopen this issue

can we reopen this?

If you are using react-navigation, try this:

// enableScreens();

which saved us from crash

Had similar problem with react-navigation and react-native-webview. Fixed by removing animation for particular screens:

static navigationOptions = () => ({
  animationEnabled: false,
});

The androidHardwareAccelerationDisabled is deprecated. For me, it worked just by changing androidLayerType="software". But on Android 11, it doesn’t work for inline videos (just for full screen). So, the only solution was to remove the stack transition animation.

Still having this issue in 9.3.0.

If you are using react-navigation and want to keep animations, you can use listeners to render the WebView only once the transitions are complete/hide the WebView once a transition starts.

Sample code:

  constructor(props: Props) {
    this.state = {
      showWebView: Platform.OS !== 'android'
    };

    if (Platform.OS === 'android') {
      this.willBlurListener = this.props.navigation.addListener('willBlur', () => {
        this.setState({ showWebView: false });
      });

      this.didFocusListener = this.props.navigation.addListener('didFocus', () => {
        this.setState({ showWebView: true });
      });
    }
  }

 componentWillUnmount() {
 if (Platform.OS === 'android') {
      if (this.willBlurListener) this.willBlurListener.remove();
      if (this.didFocusListener) this.didFocusListener.remove();
    }
 }

  render() {
   return (
          ...
          {this.state.showWebView ? // render web view
           : undefined }
    )
  }

facing the same prob,disabling hardware acceleration makes the webview responsiveness laggy which is undesirable but is solving the crash issue.

@dimasdanz disabling hardwareAccelerated, some videos won’t play anymore : (

I’m using react-navigation, but still facing this problem and #623 . With hardware acceleration disabled, embedded videos will not play anymore(only sound will play), so I don’t think it’s a valid workaround for me : (.

@Embraser01 Do you have any clue how disabling the animations in react-native-navigation fixes this issue?

Hey! Disabling hardware acceleration seems to fix it but embedded videos doesn’t work anymore 😢

The app also uses RNN so, I’ll try disabling animations and see if it work…

No, I don’t think so. I currently use realm in my app, which doesn’t support x64 when this bug appears. So the 64 Bit buiild was disabled as I submitted this issue. In the mean time realm supports x64 and the issue is still there.

I’ve used react-native-navigation [v1]. In my desperation I convert my app to the newer v2 version of rnn. Sadly the bug is still there, BUT if I disable the navigation animations, which is not really possible in rnn v1, the bug was worked around.

So I think there must be an issue in the WebView, when it was animated and (un)mounted in the same time.

@MaxMaes: Which navigation library did you use?