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

Android crash while navigating back to stack screen . #393

Closed
5 tasks done
drb1 opened this issue Jul 29, 2020 · 11 comments
Closed
5 tasks done

Android crash while navigating back to stack screen . #393

drb1 opened this issue Jul 29, 2020 · 11 comments
Labels
bug:upstream The bug is caused by a third party library. bug Crush'em all. is:waiting for feedback Waiting for OP input.

Comments

@drb1
Copy link

drb1 commented Jul 29, 2020

Oath

I swear that I have completed these tasks before submitting:

Decision table

  • My issue does not look like “The HTML attribute 'xxx' is ignored” (unless
    we claim support for it),
  • My issue does not look like “The HTML element <yyy> is not rendered”

Bug Report

07-29 17:41:49.173  6901  6901 F crashpad: dlopen: dlopen failed: library "libandroidicu.so" not found: needed by /system/lib/libharfbuzz_ng.so in namespace (default)
--------- beginning of crash
07-29 17:41:49.176  6410  6441 F libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x1c in tid 6441 (RenderThread), pid 6410 (com.newmednav)
07-29 17:41:49.340  6904  6904 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
07-29 17:41:49.340  6904  6904 F DEBUG   : Build fingerprint: 'google/sdk_gphone_x86_arm/generic_x86_arm:11/RPB2.200611.009/6625208:userdebug/dev-keys'
07-29 17:41:49.340  6904  6904 F DEBUG   : Revision: '0'
07-29 17:41:49.340  6904  6904 F DEBUG   : ABI: 'x86'
07-29 17:41:49.340  6904  6904 F DEBUG   : Timestamp: 2020-07-29 17:41:49+0545
07-29 17:41:49.340  6904  6904 F DEBUG   : pid: 6410, tid: 6441, name: RenderThread  >>> com.newmednav <<<
07-29 17:41:49.340  6904  6904 F DEBUG   : uid: 10152
07-29 17:41:49.340  6904  6904 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x1c
07-29 17:41:49.340  6904  6904 F DEBUG   : Cause: null pointer dereference
07-29 17:41:49.340  6904  6904 F DEBUG   :     eax efbc2cb0  ebx eed5c69c  ecx eed52a80  edx 00000000
07-29 17:41:49.341  6904  6904 F DEBUG   :     edi d139ae90  esi 00000000
07-29 17:41:49.341  6904  6904 F DEBUG   :     ebp c086ed48  esp c086eb50  eip ee698c1c
07-29 17:41:49.425  6904  6904 F DEBUG   : backtrace:
07-29 17:41:49.425  6904  6904 F DEBUG   :       #00 pc 00247c1c  /system/lib/libhwui.so (android::uirenderer::skiapipeline::GLFunctorDrawable::onDraw(SkCanvas*)+1548) (BuildId: 434a9b68672e1dd2b15599730362463d)
07-29 17:41:49.425  6904  6904 F DEBUG   :       #01 pc 00303a57  /system/lib/libhwui.so (SkDrawable::draw(SkCanvas*, SkMatrix const*)+87) (BuildId: 434a9b68672e1dd2b15599730362463d)
07-29 17:41:49.425  6904  6904 F DEBUG   :       #02 pc 002f4606  /system/lib/libhwui.so (SkBaseDevice::drawDrawable(SkDrawable*, SkMatrix const*, SkCanvas*)+38) (BuildId: 434a9b68672e1dd2b15599730362463d)
07-29 17:41:49.425  6904  6904 F DEBUG   :       #03 pc 00659291  /system/lib/libhwui.so (SkGpuDevice::drawDrawable(SkDrawable*, SkMatrix const*, SkCanvas*)+353) (BuildId: 434a9b68672e1dd2b15599730362463d)
07-29 17:41:49.425  6904  6904 F DEBUG   :       #04 pc 002d9dc0  /system/lib/libhwui.so (SkCanvas::onDrawDrawable(SkDrawable*, SkMatrix const*)+48) (BuildId: 434a9b68672e1dd2b15599730362463d)
React Native

0.61.5

Libraries
  • react-native-render-html: 4.2.2
  • react-native-webview: 10.3.2
  • react-native-screens: 2.8.0
  • react-native-render-html-table-bridge: ^0.6.1,

Devices

  • Device 1 emulator (Google Pixel 3a)
    • OS: Android 10.0
    • Environment: both
Description

1.Android app crashes while navigating back to stack screen after rendering table content and embedded videos from youtube.
2.Normal behavior when rendering normal html content
3.No crashes while disable {enableScreen } from react-native-screens

@drb1 drb1 added the bug Crush'em all. label Jul 29, 2020
@jsamr

This comment has been minimized.

@jsamr jsamr added the is:waiting for feedback Waiting for OP input. label Jul 29, 2020
@drb1

This comment has been minimized.

@jsamr jsamr added the bug:upstream The bug is caused by a third party library. label Jul 30, 2020
@jsamr
Copy link
Collaborator

jsamr commented Jul 30, 2020

@drb1 First of all, congratulations on the reproduction. That is pristine! So I did my little investigation, and this is what I found out:

  • Some Android developers have reported that this native error can be worked around by disabling hardware acceleration, but eventually at the cost of lower performance (that part is to be verified yet), according to the documentation.
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 433c7e2..c569e8f 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -15,6 +15,7 @@
         android:label="@string/app_name"
         android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
         android:launchMode="singleTask"
+        android:hardwareAccelerated="false"
         android:windowSoftInputMode="adjustResize">
         <intent-filter>
             <action android:name="android.intent.action.MAIN" />

Indeed, after disabling hardware acceleration, the app doesn't crash anymore.

@drb1
Copy link
Author

drb1 commented Jul 30, 2020

this solves the problem, but disabling hardwareAccelerated has serious impact on performance of app, hope it will be fixed soon

@jsamr
Copy link
Collaborator

jsamr commented Jul 30, 2020

@drb1 I do understand this is problematic. A user in the react-native-webview thread I referenced claims that putting opacity at 0.99 for the WebView might do the trick. I tested on your repo, and it works. My god, that's so utterly hackish. Here is the patch:

diff --git a/src/screens/EmbededVideoDemo.js b/src/screens/EmbededVideoDemo.js
index 1f42739..e6fa5cf 100644
--- a/src/screens/EmbededVideoDemo.js
+++ b/src/screens/EmbededVideoDemo.js
@@ -4,11 +4,16 @@ import HTML from 'react-native-render-html';
 
 const htmlContent = "<p style=\"text-align: left;\">The word&nbsp;<em>ocean</em>&nbsp;comes from the figure in&nbsp;<span style=\"color: #3598db;\"><a style=\"color: #3598db;\" title=\"Classical antiquity\" href=\"https://en.wikipedia.org/wiki/Classical_antiquity\">classical antiquity</a></span>,&nbsp;<a title=\"Oceanus\" href=\"https://en.wikipedia.org/wiki/Oceanus\">Oceanus</a> <small>pronounced&nbsp;</small><span class=\"IPA\" title=\"Representation in the International Phonetic Alphabet (IPA)\"><a title=\"Help:IPA/Greek\" href=\"https://en.wikipedia.org/wiki/Help:IPA/Greek\">[??kean&oacute;s]</a></span>, the elder of the&nbsp;<a class=\"mw-redirect\" title=\"Titan (mythology)\" href=\"https://en.wikipedia.org/wiki/Titan_(mythology)\">Titans</a>&nbsp;in classical&nbsp;<a title=\"Greek mythology\" href=\"https://en.wikipedia.org/wiki/Greek_mythology\">Greek mythology</a>, believed by the&nbsp;<a title=\"Ancient Greece\" href=\"https://en.wikipedia.org/wiki/Ancient_Greece\">ancient Greeks</a>&nbsp;and&nbsp;<a title=\"Ancient Rome\" href=\"https://en.wikipedia.org/wiki/Ancient_Rome\">Romans</a>&nbsp;to be the divine personification of the&nbsp;<a title=\"Sea\" href=\"https://en.wikipedia.org/wiki/Sea\">sea</a>, an enormous&nbsp;<a title=\"River\" href=\"https://en.wikipedia.org/wiki/River\">river</a>&nbsp;encircling the world.</p>\n<p style=\"text-align: center;\"><iframe src=\"https://www.youtube.com/embed/1La4QzGeaaQ\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"></iframe></p>\n<p style=\"text-align: left;\">Extraterrestrial oceans&nbsp;may be composed of water or other&nbsp;elements&nbsp;and&nbsp;compounds. The only confirmed large stable bodies of extraterrestrial surface&nbsp;<a class=\"mw-redirect\" title=\"Liquids\" href=\"https://en.wikipedia.org/wiki/Liquids\">liquids</a>&nbsp;are the&nbsp;<a title=\"Lakes of Titan\" href=\"https://en.wikipedia.org/wiki/Lakes_of_Titan\">lakes of Titan</a>, although there is evidence for the existence of oceans elsewhere in the&nbsp;Solar System. Early in their geologic histories,&nbsp;<a title=\"Mars\" href=\"https://en.wikipedia.org/wiki/Mars\">Mars</a>&nbsp;and&nbsp;<a title=\"Venus\" href=\"https://en.wikipedia.org/wiki/Venus\">Venus</a>&nbsp;are theorized to have had large water oceans. The&nbsp;Mars ocean hypothesis&nbsp;suggests that nearly a third of the surface of Mars was once covered by water, and a&nbsp;<a title=\"Runaway greenhouse effect\" href=\"https://en.wikipedia.org/wiki/Runaway_greenhouse_effect\">runaway greenhouse effect</a>&nbsp;may have boiled away the global ocean of Venus. Compounds such as&nbsp;<a title=\"Salt (chemistry)\" href=\"https://en.wikipedia.org/wiki/Salt_(chemistry)\">salts</a>&nbsp;and&nbsp;<a title=\"Ammonia\" href=\"https://en.wikipedia.org/wiki/Ammonia\">ammonia</a>&nbsp;dissolved in water lower its freezing point so that water might exist in large quantities in extraterrestrial environments as brine or convecting&nbsp;<a title=\"Ice\" href=\"https://en.wikipedia.org/wiki/Ice\">ice</a>. Unconfirmed oceans are speculated beneath the surface of many&nbsp;<a class=\"mw-redirect\" title=\"Dwarf planets\" href=\"https://en.wikipedia.org/wiki/Dwarf_planets\">dwarf planets</a>&nbsp;and natural satellites; notably, the ocean of the moon&nbsp;<a title=\"Europa (moon)\" href=\"https://en.wikipedia.org/wiki/Europa_(moon)\">Europa</a>&nbsp;is estimated to have over twice the water volume of Earth.</p>";
 
+const tagsStyles = {
+    iframe: {
+        opacity: 0.99
+    }
+}
 
 const EmbededVideoDemo = () => {
     return (
         <ScrollView style={{flex: 1}}>
-            <HTML html={htmlContent} imagesMaxWidth={Dimensions.get('window').width}/>
+            <HTML tagsStyles={tagsStyles} html={htmlContent} imagesMaxWidth={Dimensions.get('window').width}/>
         </ScrollView>
     );
 };

Can you confirm on your side?

@drb1
Copy link
Author

drb1 commented Jul 30, 2020

yes this also solved the issue, i think this is the best method for now.

@jsamr
Copy link
Collaborator

jsamr commented Jul 30, 2020

I am closing because there is a known workaround and the bug happens upstream.
See https://stackoverflow.com/q/63171131/2779871

@hrdyjan1
Copy link

Thank you for the temporary solution, still not sure how is it possible, that opacity style will fix the issue 🤷

@marco2216
Copy link

marco2216 commented Oct 13, 2022

The current equivalent to this solution, assuming you're using @native-html/iframe-plugin, is as follows (optionally check if is android when applying this):

renderersProps={{
  iframe: {
    webViewProps: {
      style: { opacity: 0.99 },
    },
  },
}}

@Nasseratic
Copy link

@marco2216 Thanks man that worked!

@limeojin363
Copy link

As @marco2216 metioned, when you are using plugin(table/iframe) with HTML component containing Webview={WebView} prop, you may need renderersProps, not tagStyles.
I was using @native-html/table-plugin and WebView prop like this.

import HTML from 'react-native-render-html';
import WebView from 'react-native-webview';
import TableRenderer from '@native-html/table-plugin';

// ...
  return (
    <HTML
      source={{html}} // html: Some texts..
      WebView={WebView}
      renderers={{table: TableRenderer}}
    />
  );

// ...

First didn't work for me and second did.

// import statements..

//...
  return (
    <HTML
      tagsStyles={{ // X
        table: {
          opacity: 0.99,
        },
      }}
      source={{html}}
      WebView={WebView}
      renderers={{table: TableRenderer}}
    />
  );

// ...
// import statements..

//...
  return (
    <HTML
      renderersProps={{ // O
        table: {
          webViewProps: {
            style: {opacity: 0.99},
          },
        },
      }}
      source={{html}}
      WebView={WebView}
      renderers={{table: TableRenderer}}
    />
  );

// ...

eunbae0 pushed a commit to uoslife/uoslife-client that referenced this issue Jan 29, 2024
# Summary

- 안드로이드에서 특정 공지글 진입 시 앱이 강제종료되는 현상을 해결했습니다.
- 확인된 바로는 표(table)이 있는 공지글에서 발생하는 현상이었습니다.
- `react-native-render-html`과 `@native-html/table-plugin` 두 라이브러리를
사용하는데, 해당 조합에서 발생하는
[버그](meliorence/react-native-render-html#393.
- `HTML(imported from 'react-native-render-html')` 컴포넌트에 특정한 prop을
추가함으로서 간단히(검색에 들인 시간과 비교했을 때 매우..) 해결되는 문제였습니다.
```tsx
  <HTML 
      // with some other props..
      renderersProps={{
        table: {
          webViewProps: {
            style: {opacity: 0.99},
          },
        },
      }}
  />

````

# Blackbox

- 에러가 무슨 이유로 발생하는지 파악하지 못하였습니다. 그에 따라 저 스타일과 관련된 것으로만 보이는 코드가 어떻게 이 에러를
해결하는지도 알 수가 없었습니다.
- 원리를 파악하려면 해당 라이브러리 소스, 심하면 native level까지 뜯어보아야 하는 것으로 보여, 도저히 그렇게 할
엄두는 내지 못했습니다. 그닥 효율적인 방법도 아닌 것 같아서 일단 이대로 두는 게 최선으로 보입니다.

# 반성과 느낀 점

- rebuild 배포 후에, UX에 큰 해악을 끼치는 에러를 너무 오래 방치해 두었다는 생각이 듭니다. 다음에는 신경써서
신속하게 고칠 수 있도록 하겠습니다.
- QA가 제대로 진행되었다면 배포 전에 파악되지 않았을까 하는 아쉬움도 남습니다.

# Allocated issue

- close #293

# For reviewers

- 말씀드렸다시피 사용자 경험을 심각하게 저하시키는 문제라 가능한 한 빠르게 merge, 변경사항 배포해주시면 좋겠습니다.
감사합니다..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:upstream The bug is caused by a third party library. bug Crush'em all. is:waiting for feedback Waiting for OP input.
Projects
None yet
Development

No branches or pull requests

6 participants