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

[expo-gl] Android app crash after libexpo-gl.so loaded #7575

Closed
alenoir opened this issue Apr 1, 2020 · 29 comments · Fixed by #8352
Closed

[expo-gl] Android app crash after libexpo-gl.so loaded #7575

alenoir opened this issue Apr 1, 2020 · 29 comments · Fixed by #8352
Assignees

Comments

@alenoir
Copy link

alenoir commented Apr 1, 2020

🐛 Bug Report

Environment

Expo CLI 3.17.5 environment info:
    System:
      OS: macOS 10.15.2
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node
      Yarn: 1.22.0 - ~/.nvm/versions/node/v12.16.1/bin/yarn
      npm: 6.13.4 - ~/.nvm/versions/node/v12.16.1/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    IDEs:
      Android Studio: 3.5 AI-191.8026.42.35.6010548
      Xcode: 11.4/11E146 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.11.0 => 16.11.0
      react-native: 0.62.0 => 0.62.0
    npmGlobalPackages:
      expo-cli: 3.17.5

Target : React Native Android

Steps to Reproduce

Launch App

Expected Behavior

No crash

Actual Behavior

App crash after execution of GLView.createContextAsync(); or await tf.ready();

In Logcat :

2020-04-01 14:23:58.501 8177-8177/com.tensorflowapp D/ScrollView: initGoToTop
2020-04-01 14:23:58.650 8177-8177/com.tensorflowapp D/ViewRootImpl@9cfe773[MainActivity]: Relayout returned: old=[0,0][1080,1920] new=[0,0][1080,1920] result=0x1 surface={valid=true 493719822336} changed=false
2020-04-01 14:23:58.670 8177-8891/com.tensorflowapp D/SoLoader: About to load: libexpo-gl.so
2020-04-01 14:23:58.671 8177-8891/com.tensorflowapp D/SoLoader: libexpo-gl.so not found on /data/data/com.tensorflowapp/lib-main
2020-04-01 14:23:58.671 8177-8891/com.tensorflowapp D/SoLoader: libexpo-gl.so found on /data/app/com.tensorflowapp-LFEiOec5Q3Fag-tWih-9nw==/lib/arm64
2020-04-01 14:23:58.671 8177-8891/com.tensorflowapp D/SoLoader: Not resolving dependencies for libexpo-gl.so
2020-04-01 14:23:58.674 8177-8177/com.tensorflowapp D/ViewRootImpl@9cfe773[MainActivity]: Relayout returned: old=[0,0][1080,1920] new=[0,0][1080,1920] result=0x1 surface={valid=true 493719822336} changed=false
2020-04-01 14:23:58.678 8177-8891/com.tensorflowapp D/SoLoader: Loaded: libexpo-gl.so
2020-04-01 14:23:58.685 8177-8891/com.tensorflowapp A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 8891 (mqt_js)

Reproducible Demo

Repo here : https://github.com/alenoir/tesorflowapp

@wkozyra95
Copy link
Contributor

hi, are you using hermes or JSC ?

@alenoir
Copy link
Author

alenoir commented Apr 3, 2020

@wkozyra95
Copy link
Contributor

The crash happens when context id is converted into string https://github.com/expo/expo/blob/master/packages/expo-gl-cpp/cpp/EXGLContext.cpp#L52

I don't see how this code could break, I suspect that there is a bug in the implementation of standard library distributed with react-native. You could try upgrading to the latest react-native or downgrading. Alternatively, it could be caused by com.facebook.flipper:flipper overriding one of .so files

@LevanSanadiradze
Copy link

LevanSanadiradze commented Apr 20, 2020

Same problem here, when executing tf.ready() with rn-webgl backend.

"@react-native-community/async-storage": "^1.9.0",
"@tensorflow-models/posenet": "^2.2.1",
"@tensorflow/tfjs": "^1.7.2",
"@tensorflow/tfjs-react-native": "^0.2.3",
"expo-camera": "^8.2.0",
"expo-gl": "^8.1.0",
"expo-gl-cpp": "^8.1.0",
"react": "16.11.0",
"react-native": "0.62.2",
"react-native-fs": "^2.16.6",
"react-native-unimodules": "^0.9.0"
04-20 20:23:59.141 23117 23190 D SoLoader: About to load: libexpo-gl.so
04-20 20:23:59.142 23117 23190 D SoLoader: libexpo-gl.so not found on /data/data/com.testposenet/lib-main
04-20 20:23:59.142 23117 23190 D SoLoader: libexpo-gl.so found on /data/app/com.testposenet--9kpWdVHeYlobWh8YSDV9g==/lib/arm64
04-20 20:23:59.142 23117 23190 D SoLoader: Not resolving dependencies for libexpo-gl.so
04-20 20:23:59.156 23117 23190 D SoLoader: Loaded: libexpo-gl.so
04-20 20:23:59.163 23117 23190 F libc    : Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 23190 (mqt_js), pid 23117 (com.testposenet)

@wkozyra95
Copy link
Contributor

Hi
Can you enable logging at the start of the program and post output ?

gl.enableLogging = true

@LevanSanadiradze
Copy link

LevanSanadiradze commented Apr 20, 2020

@wkozyra95 The crash apparently occurs during the createContextAsync function execution and I'm unable to get gl object to set the enableLogging to true. Or am I doing it wrong? Just adding that line causes an error as gl object doesn't exist.

@jbrew138
Copy link

jbrew138 commented Apr 21, 2020

I'm running into this issue as well, although I'm trying out gl-react/gl-react-native which uses expo-gl and expo-gl-cpp as dependencies, both 8.1.0. My logcat shows the same fatal signal when loading libexpo-gl.so.

EDIT: After looking at the versions of libexpo-gl.so in the repository, there was a commit 20 days ago where all of the .so files show drastically reduced file sizes, but only one line of C++ was added. Before that, the binaries were updated a year ago, and I can confirm those are the versions in my project. Perhaps the binaries haven't been updated for distribution since then? I'm not familiar with the code/repo, so I could be mistaken.

3cd0a4d#diff-deb21d1a9538f8afac0d00d5d10f7b0b

Annotation 2020-04-20 195023

@wkozyra95
Copy link
Contributor

if this is the same issue as @alenoir, then it's unrelated to recent changes, I tested it with older expo-gl. I linked in one of my previous answers where the actual crash happens in C++ code, It's either bug in react-native or breaking change on an abi level. We'll investigate it further, but for now, I suggest using older react-native version, preferably the same as latest sdk(0.61.4)

@jbrew138 there were more changes added before, but so files were not committed at the time.

@wood1986
Copy link
Contributor

same there

@wood1986
Copy link
Contributor

wood1986 commented Apr 22, 2020

One more question. Is the environment an emulator or a real device? You can try my repo. Remember to use yarn start and yarn android

@jbrew138
Copy link

@wkozyra95 I created a fresh react-native project using 0.61.4 and it's still triggering this issue.

For context, I'm testing it on both a Galaxy S7 and S9. I believe both have arm64 CPUs, if the issue is on an abi level.

@wkozyra95
Copy link
Contributor

@wood After downgrading to 0.61.4
removing file app/android/app/src/debug/java/com/app/ReactNativeFlipper.java and removing flipper-fresco-plugin like in a diff bellow, your example started working

diff --git a/app/android/app/build.gradle b/app/android/app/build.gradle
index 23be2e4..03092e1 100644
--- a/app/android/app/build.gradle
+++ b/app/android/app/build.gradle
@@ -202,13 +202,6 @@ dependencies {
 
     addUnimodulesDependencies([modulesPaths: ['../../../node_modules']])
 
-    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
-        exclude group:'com.facebook.flipper'
-    }
-
-    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
-        exclude group:'com.facebook.flipper'
-    }
 
     if (enableHermes) {
         def hermesPath = "../../../node_modules/hermes-engine/android/";

@jbrew138 can you check if those changes fix the issue for you?

@wood1986
Copy link
Contributor

@wkozyra95 Thanks for your follow up. May I know if you are using real device? As I am using the emulator, I still got the error

04-22 00:56:02.103  5286  5286 W com.app : Accessing hidden field Landroid/view/View;->mAccessibilityDelegate:Landroid/view/View$AccessibilityDelegate; (greylist, reflection, allowed)
04-22 00:56:02.157  5286  5286 W com.app : Accessing hidden field Landroid/widget/ScrollView;->mScroller:Landroid/widget/OverScroller; (greylist, reflection, allowed)
04-22 00:56:02.177  5286  5310 D EGL_emulation: eglMakeCurrent: 0xe38c6aa0: ver 3 0 (tinfo 0xd817f0a0)
04-22 00:56:02.189  5286  5341 D HostConnection: HostConnection::get() New Host Connection established 0xdb751b80, tid 5341
04-22 00:56:02.192  5286  5325 D SoLoader: About to load: libexpo-gl.so
04-22 00:56:02.192  5286  5325 D SoLoader: libexpo-gl.so not found on /data/data/com.app/lib-main
04-22 00:56:02.192  5286  5325 D SoLoader: libexpo-gl.so found on /data/app/com.app-ExBF9zlg--kwgUuzK3xCVA==/lib/x86
04-22 00:56:02.192  5286  5325 D SoLoader: Not resolving dependencies for libexpo-gl.so
04-22 00:56:02.236  5286  5341 D HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_0
04-22 00:56:02.237  5286  5341 D EGL_emulation: eglCreateContext: 0xdb71bb60: maj 3 min 0 rcv 3
04-22 00:56:02.238  1636  1636 I hwservicemanager: getTransport: Cannot find entry android.hardware.graphics.allocator@3.0::IAllocator/default in either framework or device manifest.
04-22 00:56:02.249  5286  5341 W Gralloc3: allocator 3.x is not supported
04-22 00:56:02.251  5286  5325 D SoLoader: Loaded: libexpo-gl.so
04-22 00:56:02.253  5286  5325 F libc    : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 5325 (mqt_js), pid 5286 (com.app)
04-22 00:56:02.253  1749  1912 D gralloc_ranchu: gralloc_alloc: Creating ashmem region of size 2252800
04-22 00:56:02.266  5286  5341 D EGL_emulation: eglMakeCurrent: 0xdb71bb60: ver 3 0 (tinfo 0xbef4a240)
04-22 00:56:02.270  5286  5341 E EGL_emulation: tid 5341: eglSurfaceAttrib(1399): error 0x3009 (EGL_BAD_MATCH)
04-22 00:56:02.270  5286  5341 E EXGL    : EGL error = 0x3009
04-22 00:56:02.295  5344  5344 I crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone
04-22 00:56:02.295  1811  1811 I /system/bin/tombstoned: received crash request for pid 5325
04-22 00:56:02.295  5344  5344 I crash_dump32: performing dump of process 5286 (target tid = 5325)
04-22 00:56:02.303  5344  5344 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
04-22 00:56:02.303  5344  5344 F DEBUG   : Build fingerprint: 'google/sdk_gphone_x86/generic_x86:10/QSR1.191030.002/5978551:userdebug/dev-keys'
04-22 00:56:02.303  5344  5344 F DEBUG   : Revision: '0'
04-22 00:56:02.303  5344  5344 F DEBUG   : ABI: 'x86'
04-22 00:56:02.304  5344  5344 F DEBUG   : Timestamp: 2020-04-22 00:56:02-0700
04-22 00:56:02.304  5344  5344 F DEBUG   : pid: 5286, tid: 5325, name: mqt_js  >>> com.app <<<
04-22 00:56:02.304  5344  5344 F DEBUG   : uid: 10133
04-22 00:56:02.304  5344  5344 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
04-22 00:56:02.304  5344  5344 F DEBUG   :     eax 00000000  ebx 000014a6  ecx 000014cd  edx 00000006
04-22 00:56:02.304  5344  5344 F DEBUG   :     edi ed94933e  esi bed19aa0
04-22 00:56:02.304  5344  5344 F DEBUG   :     ebp eef50ad0  esp bed19a48  eip eef50ad9
04-22 00:56:02.387  5344  5344 F DEBUG   :
04-22 00:56:02.387  5344  5344 F DEBUG   : backtrace:
04-22 00:56:02.387  5344  5344 F DEBUG   :       #00 pc 00000ad9  [vdso] (__kernel_vsyscall+9)
04-22 00:56:02.387  5344  5344 F DEBUG   :       #01 pc 00092328  /apex/com.android.runtime/lib/bionic/libc.so (syscall+40) (BuildId: 76290498408016ad14f4b98c3ab6c65c)

And this is my virtual device configuration

image

@wkozyra95
Copy link
Contributor

I tested on the same emulator. You can try switching option Emualted Preformance -> Graphics to the software(and if that won't work to hardware). It's possible that your gpu does not support emulation (or required version of opengl, but it's less likely).

@LevanSanadiradze
Copy link

@wkozyra95 Tried to remove flipper as you described, but the issue persists. Nothing's changed, the error is the same. I'm testing on a Galaxy S8

@wkozyra95
Copy link
Contributor

wkozyra95 commented Apr 22, 2020

@LevanSanadiradze

  • Are you sure that that you followed all the steps? Maybe it's still using 0.62 react-native, try running ./gradlew clean
  • Is the error the same as before?
  • Can you create repo with a minimal example to reproduce it?

@LevanSanadiradze
Copy link

LevanSanadiradze commented Apr 22, 2020

@wkozyra95

  1. Yes, I followed the steps and I ran the ./gradlew clean
  2. Yes, the error is exactly the same
  3. I will create the repo in several minutes.

@LevanSanadiradze
Copy link

@wkozyra95 Actually after fresh creating a new project with react-native 0.61.4 the crash no longer occurs (Without removing flipper).

@wood1986
Copy link
Contributor

@wkozyra95 I am using the latest mac mini 2018. I think it supports OpenGL ES 3.0. Anyway as you have said it worked. I trust you. Again thank you so much

@wood1986
Copy link
Contributor

I have some update. As I forgot to downgrade to 0.61.4, it did not work. Now it works on emulator. @wkozyra95 Which side is responsible for getting 0.62.2 work? react-native or expo?

@wood1986
Copy link
Contributor

FYI: @LevanSanadiradze I can get 0.61.5 work as well

@jbrew138
Copy link

I ran into an issue where npm was automatically upgrading to 0.62.2. After ensuring that it downgraded to 0.61.4 and rebuilding, it started working. Flipper was only added as of 0.62 so I didn't have to edit anything else.

As an experiment I tried preventing flipper from being added to my 0.62.2 copy (including removing the initializeFlipper function in MainApplication.java, and ReactNativeFlipper.java from app/src/debug/...), but it still crashed.

nicholas added a commit to nicholas/tfjs_issue_3197 that referenced this issue May 4, 2020
Flipper causes crash with expo-gl.
See expo/expo#7575
@wood1986
Copy link
Contributor

wood1986 commented May 7, 2020

Could be related to #7623

@mauscoelho
Copy link

Seems to not be compatible with 0.62
✅ Back to 0.61.5! expo-gl works and Flipper still working.

@wkozyra95
Copy link
Contributor

expo-gl-cpp@8.2.0 should have this issue fixed

@tsapeta
Copy link
Member

tsapeta commented May 22, 2020

^ Small correction because expo-gl-cpp shouldn't be installed directly, for React Native 0.62 please use expo-gl@8.2.0 that solved this issue.

@StampixSMO
Copy link

This seems to be happening again with RN @ 0.68.0 and expo-gl @ 11.1.1 and expo-gl-cpp @ 11.1.0.

@tsapeta
Copy link
Member

tsapeta commented Apr 8, 2022

Thanks for the report @StampixSMO. We'll investigate that and release a new version soon as the SDK45 release is coming 😉

@StampixSMO
Copy link

@tsapeta Thanks for the quick reply, might be a different underlying issue though: #16887

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

Successfully merging a pull request may close this issue.

9 participants