igorski / MWEngine

Audio engine and DSP library for Android, written in C++ providing low latency performance within a musical context, while providing a Java/Kotlin API. Supports both OpenSL and AAudio.
MIT License
264 stars 45 forks source link

App get crashed added the processor to the input channel during recording #163

Closed YogarajRamesh closed 2 years ago

YogarajRamesh commented 2 years ago

Hi @igorski I have added processor to the input channel while recording then i dispose the engine without stop the recording after that again when switch on the inputchannel the app get crashed.

Adding the effect to the engine _engine.getInputChannel().getProcessingChain().addProcessor(reverb);

Dispose the engine _engine.stop(); // free memory allocated by song _engine.dispose(); // dispose the engine

LOGCAT

F/libc ( 6001): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8 in tid 6001 (testapp.test), pid 6001 (testapp.test)


Build fingerprint: 'HONOR/LLD-AL10/HWLLD-H:9/HONORLLD-AL10/9.1.0.173C675:user/release-keys' Revision: '0' ABI: 'arm64' Happend: 'Thu May 5 23:09:20 2022 ' SYSVMTYPE: Art APPVMTYPE: Art pid: 6001, tid: 6001, name: testapp.test >>> com.testapp.test <<< signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8 Cause: null pointer dereference x0 0000000000000000 x1 00000079d8697480 x2 0000007fdcc99c30 x3 0000007fdcc99c30 x4 0000000000000000 x5 0000000000000000 x6 00000079dee15c00 x7 0000000000000000 x8 0000000000000000 x9 00000079d8697480 x10 00000079c2f4c798 x11 0000000000000001 x12 0000007fdcc99ccc x13 0000007fdcc99cb8 x14 0000000000000002 x15 0000007fdcc98798 x16 00000079ab9afdf8 x17 00000079ab8bcf08 x18 0000000000000000 x19 00000079dee15c00 x20 0000000000000000 x21 00000079dee15c00 x22 0000007fdcc99fb0 x23 00000079c27c4096 x24 0000000000000018 x25 0000007a6578a5e0 x26 00000079dee15ca0 x27 0000000000000000 x28 0000007fdcc99cd0 x29 0000007fdcc99c40 sp 0000007fdcc99be0 lr 00000079ab8a5b40 pc 00000079ab8bcf1c backtrace:

00 pc 00000000000e4f1c /data/app/com.testapp.test-uzk8NHJMleI472FTW3aTbA==/base.apk (offset 0x4500000) (MWEngine::BaseProcessor::setChain(MWEngine::ProcessingChain*)+20)

#01 pc 00000000000cdb3c  /data/app/com.testapp.test-uzk8NHJMleI472FTW3aTbA==/base.apk (offset 0x4500000) (MWEngine::ProcessingChain::addProcessor(MWEngine::BaseProcessor*)+160)
#02 pc 00000000000ab99c  /data/app/com.testapp.test-uzk8NHJMleI472FTW3aTbA==/base.apk (offset 0x4500000) (Java_nl_igorski_mwengine_core_MWEngineCoreJNI_ProcessingChain_1addProcessor+72)
#03 pc 0000000000588fe0  /system/lib64/libart.so (art_quick_generic_jni_trampoline+144)
#04 pc 000000000058024c  /system/lib64/libart.so (art_quick_invoke_static_stub+604)
#05 pc 00000000000d8628  /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+232)
#06 pc 000000000028cec8  /system/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+344)
#07 pc 0000000000287ff4  /system/lib64/libart.so (bool art::interpreter::DoCall<true, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+748)
#08 pc 000000000054a198  /system/lib64/libart.so (MterpInvokeStaticRange+148)
#09 pc 0000000000572994  /system/lib64/libart.so (ExecuteMterpImpl+15380)
#10 pc 0000000000390854  /dev/ashmem/dalvik-classes3.dex extracted in memory from /data/app/com.testapp.test-uzk8NHJMleI472FTW3aTbA==/base.apk!classes3.dex (deleted) (nl.igorski.mwengine.core.ProcessingChain.addProcessor+16)
#11 pc 0000000000260bd4  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2850692617+488)
#12 pc 00000000002666c8  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+216)
#13 pc 0000000000286eb4  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+940)
#14 pc 000000000054747c  /system/lib64/libart.so (MterpInvokeVirtual+588)
#15 pc 0000000000572514  /system/lib64/libart.so (ExecuteMterpImpl+14228)
#16 pc 0000000000001d3e  /dev/ashmem/dalvik-classes16.dex extracted in memory from /data/app/com.testapp.test-uzk8NHJMleI472FTW3aTbA==/base.apk!classes16.dex (deleted) (com.testapp.flutterwmengine.FlutterwmenginePlugin.onMethodCall+1086)
#17 pc 0000000000260bd4  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2850692617+488)
#18 pc 00000000002666c8  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+216)
#19 pc 0000000000286eb4  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+940)
#20 pc 0000000000548238  /system/lib64/libart.so (MterpInvokeInterface+944)
#21 pc 0000000000572714  /system/lib64/libart.so (ExecuteMterpImpl+14740)
#22 pc 0000000000294f66  /dev/ashmem/dalvik-classes3.dex extracted in memory from /data/app/com.testapp.test-uzk8NHJMleI472FTW3aTbA==/base.apk!classes3.dex (deleted) (io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage+34)
#23 pc 0000000000260bd4  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2850692617+488)
#24 pc 00000000002666c8  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+216)
#25 pc 0000000000286eb4  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+940)
#26 pc 0000000000548238  /system/lib64/libart.so (MterpInvokeInterface+944)
#27 pc 0000000000572714  /system/lib64/libart.so (ExecuteMterpImpl+14740)

28 pc 0000000000289b90 /dev/ashmem/dalvik-classes3.dex extracted in memory from /data/app/com.testapp.test-uzk8NHJMleI472FTW3aTbA==/base.apk!classes3.dex (deleted) (io.flutter.embedding.engine.dart.DartMessenger.invokeHandler+36)

#29 pc 0000000000260bd4  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2850692617+488)
#30 pc 0000000000533414  /system/lib64/libart.so (artQuickToInterpreterBridge+1020)
#31 pc 00000000005890fc  /system/lib64/libart.so (art_quick_to_interpreter_bridge+92)

32 pc 0000000000014ca8 /dev/ashmem/dalvik-jit-code-cache (deleted) (io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger+248)

#33 pc 000000000057ff88  /system/lib64/libart.so (art_quick_invoke_stub+584)
#34 pc 00000000000d8608  /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200)
#35 pc 000000000028cec8  /system/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+344)
#36 pc 0000000000287ff4  /system/lib64/libart.so (bool art::interpreter::DoCall<true, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+748)
#37 pc 0000000000548cac  /system/lib64/libart.so (MterpInvokeVirtualRange+576)
#38 pc 0000000000572814  /system/lib64/libart.so (ExecuteMterpImpl+14996)

39 pc 0000000000288cb4 /dev/ashmem/dalvik-classes3.dex extracted in memory from /data/app/com.testapp.test-uzk8NHJMleI472FTW3aTbA==/base.apk!classes3.dex (deleted) (io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$TsixYUB5E6FpKhMtCSQVHKE89gQ.run+24)

#40 pc 0000000000260bd4  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2850692617+488)
#41 pc 0000000000533414  /system/lib64/libart.so (artQuickToInterpreterBridge+1020)
#42 pc 00000000005890fc  /system/lib64/libart.so (art_quick_to_interpreter_bridge+92)
#43 pc 0000000000019800  /dev/ashmem/dalvik-jit-code-cache (deleted) (android.os.Handler.handleCallback+64)
#44 pc 000000000001a57c  /dev/ashmem/dalvik-jit-code-cache (deleted) (android.os.Handler.dispatchMessage+60)
#45 pc 000000000057ff88  /system/lib64/libart.so (art_quick_invoke_stub+584)
#46 pc 00000000000d8608  /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200)
#47 pc 000000000028cec8  /system/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+344)
#48 pc 0000000000286ed0  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+968)
#49 pc 000000000054747c  /system/lib64/libart.so (MterpInvokeVirtual+588)
#50 pc 0000000000572514  /system/lib64/libart.so (ExecuteMterpImpl+14228)
#51 pc 0000000000b512f8  /system/framework/boot-framework.vdex (android.os.Looper.loop+498)
#52 pc 0000000000260bd4  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2850692617+488)
#53 pc 00000000002666c8  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+216)
#54 pc 0000000000286eb4  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+940)
#55 pc 0000000000548984  /system/lib64/libart.so (MterpInvokeStatic+204)
#56 pc 0000000000572694  /system/lib64/libart.so (ExecuteMterpImpl+14612)
#57 pc 00000000003decbc  /system/framework/boot-framework.vdex (android.app.ActivityThread.main+428)
#58 pc 0000000000260bd4  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2850692617+488)
#59 pc 0000000000533414  /system/lib64/libart.so (artQuickToInterpreterBridge+1020)
#60 pc 00000000005890fc  /system/lib64/libart.so (art_quick_to_interpreter_bridge+92)
#61 pc 000000000058024c  /system/lib64/libart.so (art_quick_invoke_static_stub+604)
#62 pc 00000000000d8628  /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+232)
#63 pc 000000000047ac6c  /system/lib64/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+104)
#64 pc 000000000047c6c0  /system/lib64/libart.so (art::InvokeMethod(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jobject*, _jobject*, unsigned long)+1440)
#65 pc 000000000040be28  /system/lib64/libart.so (art::Method_invoke(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*)+52)
#66 pc 00000000001456d4  /system/framework/arm64/boot.oat (offset 0x13b000) (java.lang.Class.getDeclaredMethodInternal [DEDUPED]+180)
#67 pc 000000000057ff88  /system/lib64/libart.so (art_quick_invoke_stub+584)
#68 pc 00000000000d8608  /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200)
#69 pc 000000000028cec8  /system/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+344)
#70 pc 0000000000286ed0  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+968)
#71 pc 000000000054747c  /system/lib64/libart.so (MterpInvokeVirtual+588)
#72 pc 0000000000572514  /system/lib64/libart.so (ExecuteMterpImpl+14228)
#73 pc 00000000012310c0  /system/framework/boot-framework.vdex (com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run+22)
#74 pc 0000000000260bd4  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.2850692617+488)
#75 pc 0000000000533414  /system/lib64/libart.so (artQuickToInterpreterBridge+1020)
#76 pc 00000000005890fc  /system/lib64/libart.so (art_quick_to_interpreter_bridge+92)
#77 pc 0000000000ee389c  /system/framework/arm64/boot-framework.oat (offset 0x415000) (com.android.internal.os.ZygoteInit.main+2540)
#78 pc 000000000058024c  /system/lib64/libart.so (art_quick_invoke_static_stub+604)
#79 pc 00000000000d8628  /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+232)
#80 pc 000000000047ac6c  /system/lib64/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+104)
#81 pc 000000000047a8cc  /system/lib64/libart.so (art::InvokeWithVarArgs(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list)+424)
#82 pc 0000000000370200  /system/lib64/libart.so (art::JNI::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+660)
#83 pc 00000000000b9bcc  /system/lib64/libandroid_runtime.so (_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+120)
#84 pc 00000000000bc944  /system/lib64/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&, bool)+780)
#85 pc 0000000000002368  /system/bin/app_process64 (main+1444)
#86 pc 00000000000ae7e4  /system/lib64/libc.so (__libc_init+88)

Lost connection to device. Exited (sigterm)

Thanks in Advance @igorski

igorski commented 2 years ago

then i dispose the engine without stop the recording

Well, have you tried stopping the recording prior to disposing the engine ? 🙈

This can't be handled by the engine because when the recording stops, a notification is sent out to handle writing the file asynchronously in a separate thread. Meaning : your code needs to be aware of this. At this point, might as well adjust your code to first stop recording, prior to disposing.

To be clear: disposal is to be used when the engine should be destroyed (e.g. is not expected to do process any audio / will be recreated later).

YogarajRamesh commented 2 years ago

Hi @igorski Thank you for the reply. found the problem I am usingasyncfunction to stop and destroy recoding and engine. after handle it properly the problem get fixed.

so what's happening when i try to destroy the engine it take few min(clear other process), mean while i reinit() the engine again and add effects to process. but the first destroy method dispose both the engine. so the effects is trying to add to the destroyed engine. it cause the crash.

Thanks for your suggestion @igorski