google-ar / arcore-android-sdk

ARCore SDK for Android Studio
https://developers.google.com/ar
Other
4.97k stars 1.22k forks source link

Crash in libcamera2ndk.so (SIGSEGV) in versions prior to Android 8.1 / Android O MR1 (API 27) #291

Open RegisAG opened 6 years ago

RegisAG commented 6 years ago

I have an app in production used by many users. On some of them, only on Android 7.x, I have got the following error:

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 0

backtrace:
  #00  pc 000000000000b91c  /system/lib64/libcamera2ndk.so
  #01  pc 000000000000d0a0  /system/lib64/libcamera2ndk.so
  #02  pc 000000000001499c  /system/lib64/libcamera2ndk.so
  #03  pc 00000000000166bc  /system/lib64/libcamera2ndk.so
  #04  pc 00000000000120f4  /system/lib64/libstagefright_foundation.so (_ZN7android8AHandler14deliverMessageERKNS_2spINS_8AMessageEEE+52)
  #05  pc 0000000000015e9c  /system/lib64/libstagefright_foundation.so (_ZN7android8AMessage7deliverEv+112)
  #06  pc 000000000001322c  /system/lib64/libstagefright_foundation.so (_ZN7android7ALooper4loopEv+480)
  #07  pc 00000000000124e8  /system/lib64/libutils.so (_ZN7android6Thread11_threadLoopEPv+272)
  #08  pc 00000000000a5110  /system/lib64/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+116)
  #09  pc 00000000000696bc  /system/lib64/libc.so (_ZL15__pthread_startPv+196)
  #10  pc 000000000001dbf0  /system/lib64/libc.so (__start_thread+16)

Any idea on the origin of this problem ?

inio commented 6 years ago

This, unfortunately, is a known issue in Android versions prior to 8.1. It generally occurs only during extremely high CPU usage. There's nothing we can do about it. ☹️

RegisAG commented 6 years ago

Any update concerning this problem ? Note that according to my Android Vitals dashboard, this crash happens almost only on: Galaxy S7 Edge (hero2lte) (47.3% of the crashes), Galaxy S7 (herolte) (42% of the crashes), Galaxy S7 (heroltebmc) (2.2% of the crashes) => 90% of the occurences of this crash happen on S7 (running Android 7.x). Do you plan to fix this problem ? The S7 represents 20% of my installs and thus crash has a bad influence on my rating.

inio commented 6 years ago

This issue happens with high CPU load resulting in blocked Binder threads. If you can reduce your app's CPU usage and avoid blocking/waiting in any callbacks running on Binder threads, it may reduce this issue.

Long term, we're looking at ways to mitigate this issue, but they are major rewrites of substantial parts of our codebase. This is a bug in the android NDK Camera 2 API implementation that was fixed in Android 8.1.

RegisAG commented 6 years ago

"avoid blocking/waiting in any callbacks running on Binder threads" : how to do that ? :)

inio commented 6 years ago

Anything related to Android services should avoid blocking in callbacks. Google Play Services for example.

gkiernozek commented 5 years ago

@RegisAG - try newest ARCore 1.9.0 - I have not experienced the freeze yet from time I've updated SDK and hopefully it stays this way :)

Let me know if 1.9.0 ever crashes for you as it did in previous versions so I can be prepared that problem can still occur.

Noltibus commented 4 years ago

We still experience this error in production. Only on Samsung devices (S8, A6, A7 2108) with Android versions 9 and 10. the stacktrace reads as follows:

signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 0 >>> one.realnote.app <<<

backtrace:
  #00  pc 000000000001e1b0  /system/lib64/libcamera2ndk.so (android::acam::CameraManagerGlobal::DeathNotifier::binderDied(android::wp<android::IBinder> const&)+276)
  #01  pc 000000000004e400  /system/lib64/libbinder.so (android::BpBinder::reportOneDeath(android::BpBinder::Obituary const&)+148)
  #02  pc 000000000004e320  /system/lib64/libbinder.so (android::BpBinder::sendObituary()+148)
  #03  pc 0000000000058b18  /system/lib64/libbinder.so (android::IPCThreadState::executeCommand(int)+668)
  #04  pc 00000000000587c8  /system/lib64/libbinder.so (android::IPCThreadState::getAndExecuteCommand()+156)
  #05  pc 0000000000058f04  /system/lib64/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+60)
  #06  pc 000000000007f024  /system/lib64/libbinder.so (android::PoolThread::threadLoop()+24)
  #07  pc 00000000000135fc  /system/lib64/libutils.so (android::Thread::_threadLoop(void*)+288)
  #08  pc 00000000000ef900  /system/lib64/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+140)
  #09  pc 00000000000e28c0  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+36)
  #10  pc 000000000008503c  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)

Currently using ArCore 1.16