react-native-rich-editor: Crash on android

App crash when i navigate to android from flatlist, i tried androidHardwareAccelerationDisabled but not work, please help

Version detail

   "react-native-webview": "^11.17.1",
   "react-native-pell-rich-editor": "^1.8.8",
   "react-native": "^0.67.1",

The code

 <RichEditor
            androidHardwareAccelerationDisabled
            editorInitializedCallback={() => {
              richText?.current?.setFontName("Montserrat");
            }}
            ref={richText}
            editorStyle={{
              cssText: fontEditor,
              contentCSSText: editorCss,
              // backgroundColor: color.backgroundGrey,
            }}
            onChange={(descriptionText) => {
              console.log("descriptionText:", descriptionText);
            }}
          />

Behavior

https://user-images.githubusercontent.com/37074707/151480856-bae059ae-c50f-432d-843f-2ae2c882d8dc.mov

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 5
  • Comments: 24 (1 by maintainers)

Most upvoted comments

Like @KazakovVS suggests, you can pass androidLayerType prop with software value to underlying web view:

<RichEditor
  androidLayerType="software"
  ...
/>

androidHardwareAccelerationDisabled is deprecated according to react-native-webview documentation, so there is no need to use it

Instead of switching off the hardware acceleration globally, just passed 2 additional params to the component:

  • androidLayerType=“software”
  • androidHardwareAccelerationDisabled

Hey @sameer0075, until an new version is released, here is a workaround, check how patch-package works. https://www.npmjs.com/package/patch-package

After you have installed your packages with npm or yarn, check for react-native-pell-rich-editor library folder, installed in node_modules folder, path: ./node_modules/react-native-pell-rich-editor/src/ . After check for the file RichEditor.js on line 270, you will have the dataDetectorTypes={'none'} attribute. Just comment it out and use the patch-package to create a patch, commit your new package.json and created patch folder to your GIT repo and next time you will install your packages the patch will automatically be applied.

This worked in my case, as I am using Expo aswell.

Everything else androidHardwareAccelerationDisabled, androidLayerType="software" or Add android:hardwareAccelerated="false" in AndroidManifest.xml did not work for me.

Now works great both on iOS and Android.

      <WebView
          useWebKit={true}
          scrollEnabled={false}
          hideKeyboardAccessoryView={true}
          keyboardDisplayRequiresUserAction={false}
          nestedScrollEnabled={!useContainer}
          style={[styles.webview, style]}
          {...rest}
          ref={that.setRef}
          onMessage={that.onMessage}
          originWhitelist={['*']}
          // dataDetectorTypes={'none'}
          domStorageEnabled={false}
          bounces={false}
          javaScriptEnabled={true}
          source={viewHTML}
          onLoad={that.init}
          onShouldStartLoadWithRequest={event => {
            if (event.url !== 'about:blank') {
              this.webviewBridge?.stopLoading();
              Linking?.openURL(event.url);
              return false;
            }
            return true;
          }}
        />

Add android:hardwareAccelerated=“false” in AndroidManifest.xml

it worked for me!

I had the same issue, looking into sentry I have the following stack trace

Application Specific Information:
Segfault

Thread 0 Crashed:
0   libhwui.so                      0x732f63aadc        SkSurface::getCanvas
1   libhwui.so                      0x732f72a6bc        android::MinikinFontSkia::GetSkTypeface
2   libhwui.so                      0x732f60bd10        SkCanvas::onDrawDrawable
3   libhwui.so                      0x732f5f964c        SkPath::addRect
4   libhwui.so                      0x732f60bcac        SkCanvas::onDrawDrawable
5   libhwui.so                      0x732f5f964c        SkPath::addRect
6   libhwui.so                      0x732f60bcac        SkCanvas::onDrawDrawable
7   libhwui.so                      0x732f5f964c        SkPath::addRect
8   libhwui.so                      0x732f60bcac        SkCanvas::onDrawDrawable
9   libhwui.so                      0x732f5f964c        SkPath::addRect
10  libhwui.so                      0x732f60bcac        SkCanvas::onDrawDrawable
11  libhwui.so                      0x732f5f964c        SkPath::addRect
12  libhwui.so                      0x732f62cf90        SkCanvas::concat
13  libhwui.so                      0x732f63d1e8        GrRenderTargetContext::internalClear
14  libhwui.so                      0x732f63a5cc        GrBackendRenderTarget::~GrBackendRenderTarget
15  libhwui.so                      0x732f63a238        SkCanvas::drawPaint
16  libhwui.so                      0x732f68d0d0        SkString::appendf
17  libhwui.so                      0x732f68c28c        SkString::appendf

There is a known hack adding opacity: 0.99 to the style of the WebView. I have tried it and it works.

Hey @sameer0075, until an new version is released, here is a workaround, check how patch-package works. https://www.npmjs.com/package/patch-package

After you have installed your packages with npm or yarn, check for react-native-pell-rich-editor library folder, installed in node_modules folder, path: ./node_modules/react-native-pell-rich-editor/src/ . After check for the file RichEditor.js on line 270, you will have the dataDetectorTypes={'none'} attribute. Just comment it out and use the patch-package to create a patch, commit your new package.json and created patch folder to your GIT repo and next time you will install your packages the patch will automatically be applied.

This worked in my case, as I am using Expo aswell.

Everything else androidHardwareAccelerationDisabled, androidLayerType="software" or Add android:hardwareAccelerated="false" in AndroidManifest.xml did not work for me.

Now works great both on iOS and Android.

      <WebView
          useWebKit={true}
          scrollEnabled={false}
          hideKeyboardAccessoryView={true}
          keyboardDisplayRequiresUserAction={false}
          nestedScrollEnabled={!useContainer}
          style={[styles.webview, style]}
          {...rest}
          ref={that.setRef}
          onMessage={that.onMessage}
          originWhitelist={['*']}
          // dataDetectorTypes={'none'}
          domStorageEnabled={false}
          bounces={false}
          javaScriptEnabled={true}
          source={viewHTML}
          onLoad={that.init}
          onShouldStartLoadWithRequest={event => {
            if (event.url !== 'about:blank') {
              this.webviewBridge?.stopLoading();
              Linking?.openURL(event.url);
              return false;
            }
            return true;
          }}
        />

This one worked for me

I recently started experiencing the same issue as well

Yhh it worked for me as well.

@mmaghiar thanks a lot, It worked 😃

@mmaghiar thanks alot, it worked for me thanks for saving me

Thank You So Much @davidwico well worked On android 12

  • 1, same here

I am also facing same issue