pinkfish / flutter_rtmppublisher

Publisher to rtmp using the camera plugin as a basis to do all the basic camera/record management.
BSD 3-Clause "New" or "Revised" License
95 stars 121 forks source link

Bug of camera switching in Android 8.1 #11

Open bohdanuhryn opened 4 years ago

bohdanuhryn commented 4 years ago

There is ndk level bug that manifests while dispose() method calls. com.whelksoft.camera_with_rtmp.Camera.kt

fun dispose() {
  close()
  flutterTexture.release()
  orientationEventListener.disable()
}

flutterTexture.release() method causes exception but it is impossible to catch it in kotlin since it is lower level exception. Example of exception log:

F/libc    ( 3696): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 3696 (elic.requestify), pid 3696 (elic.requestify)

Build fingerprint: 'google/sdk_gphone_x86/generic_x86:8.1.0/OSM1.180201.007/4586646:user/release-keys'
Revision: '0'
ABI: 'x86'
pid: 3696, tid: 3696, name: elic.requestify  >>> com.polydelic.requestify <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Cause: null pointer dereference
    eax ffffffff  ebx ab3b6e70  ecx 00002ace  edx af16d000
    esi 00000000  edi 7fa724a4
    xcs 00000073  xds 0000007b  xes 0000007b  xfs 0000003b  xss 0000007b
    eip ab3a2df3  ebp bf99e788  esp bf99e760  flags 00210292
backtrace:
    #00 pc 0000bdf3  /system/lib/libutils.so (android::RefBase::decStrong(void const*) const+35)
    #01 pc 00145aad  /system/lib/libstagefright.so (android::MediaCodec::~MediaCodec()+1613)
    #02 pc 00145fe1  /system/lib/libstagefright.so (android::MediaCodec::~MediaCodec()+33)
    #03 pc 0000be2f  /system/lib/libutils.so (android::RefBase::decStrong(void const*) const+95)
    #04 pc 001571a9  /system/lib/libstagefright.so (android::MediaCodec::stop()+329)
    #05 pc 00026072  /system/lib/libmedia_jni.so (android_media_MediaCodec_stop(_JNIEnv*, _jobject*)+146)
    #06 pc 00606568  /system/framework/x86/boot-framework.oat (offset 0x606000) (android.os.Binder.destroyBinder [DEDUPED]+104)
    #07 pc 00642262  /system/lib/libart.so (art_quick_invoke_stub+338)
    #08 pc 001160cf  /system/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+223)
    #09 pc 0032153f  /system/lib/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+335)
    #10 pc 0031a7a4  /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+836)
    #11 pc 0062942c  /system/lib/libart.so (MterpInvokeDirect+428)
    #12 pc 006333a1  /system/lib/libart.so (artMterpAsmInstructionStart+14369)
    #13 pc 002f3a2b  /system/lib/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue, bool)+539)
    #14 pc 002fa2e7  /system/lib/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame*, art::JValue*)+231)
    #15 pc 0031a78a  /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+810)
    #16 pc 00627e14  /system/lib/libart.so (MterpInvokeVirtual+756)
    #17 pc 006332a1  /system/lib/libart.so (artMterpAsmInstructionStart+14113)
    #18 pc 002f3a2b  /system/lib/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue, bool)+539)
    #19 pc 002fa2e7  /system/lib/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame*, art::JValue*)+231)
    #20 pc 0031a78a  /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+810)
    #21 pc 00627e14  /system/lib/libart.so (MterpInvokeVirtual+756)
    #22 pc 006332a1  /system/lib/libart.so (artMterpAsmInstructionStart+14113)
    #23 pc 002f3a2b  /system/lib/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue, bool)+539)
    #24 pc 002fa2e7  /system/lib/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame*, art::JValue*)+231)
    #25 pc 0031a78a  /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+810)
    #26 pc 00627e14  /system/lib/libart.so (MterpInvokeVirtual+756)
    #27 pc 006332a1  /system/lib/libart.so (artMterpAsmInstructionStart+14113)
    #28 pc 002f3a2b  /system/lib/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue, bool)+539)
    #29 pc 002fa2e7  /system/lib/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame*, art::JValue*)+231)
    #30 pc 0031a78a  /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+810)
    #31 pc 00627e14  /system/lib/libart.so (MterpInvokeVirtual+756)
    #32 pc 006332a1  /system/lib/libart.so (artMterpAsmInstructionStart+14113)
    #33 pc 002f3a2b  /system/lib/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue, bool)+539)
    #34 pc 002fa2e7  /system/lib/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame*, art::JValue*)+231)
    #35 pc 0031a78a  /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+810)
    #36 pc 00627e14  /system/lib/libart.so (MterpInvokeVirtual+756)
    #37 pc 006332a1  /system/lib/libart.so (artMterpAsmInstructionStart+14113)
    #38 pc 002f3a2b  /system/lib/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue, bool)+539)
    #39 pc 002fa1cb  /system/lib/libart.so (art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame*)+139)
    #40 pc 006179bf  /system/lib/libart.so (artQuickToInterpreterBridge+1311)
    #41 pc 0064832d  /system/lib/libart.so (art_quick_to_interpreter_bridge+77)
    #42 pc 00020e95  /dev/ashmem/dalvik-jit-code-cache (deleted)

Steps to reproduce (Android 8.1):

  1. User starts streaming (creates controller)
  2. User switches camera (disposes prev controller and creates new one synchronously)
  3. Exception occurs after 1 or more switches.
pinkfish commented 4 years ago

Hmm. Do you know how to stop it happening? Looks like it is a segmentation fault.

pinkfish commented 4 years ago

I have not been able to reproduce this at all? I just changed how I use the camera apis in the current version. Maybe that will help?