react-native-vision-camera
react-native-vision-camera copied to clipboard
🐛 Frame processor crash on Android
What's happening?
After a few seconds (random, from 1s to 20s), the frame processor crashes on Android with a good old:
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0000000000000000
Cause: null pointer dereference
I post below the ndk-stack
symbolicated stack trace (truncated due to github char limits) obtained with $ANDROID_HOME/ndk/23.1.7779620/ndk-stack -dump my_crash.txt -sym android/app/build/intermediates/merged_native_libs/debug/out/lib/arm64-v8a
Looking at the logs it seems that this->frame
is null when calling get
on FrameHostObject
(stack #22 & #23 in the log below) here
Any idea how/why?
Reproduceable Code
const measurePupillaryDistanceInPixelsJS = Worklets.createRunInJsFn(measurePupillaryDistanceInPixels);
const frameProcessor = useFrameProcessor((frame: CameraFrame) => {
"worklet";
runAtTargetFps(frameProcessorFps, () => {
"worklet";
if (!frame.isValid) return;
const result = scanForEyes(frame); // custom frame processor
measurePupillaryDistanceInPixelsJS({
frame,
face: result?.faces?.[0],
});
});
}, []);
//...
<Camera
style={styles.camera}
device={device}
isActive
frameProcessor={frameProcessor}
pixelFormat={Platform.OS === "ios" ? "native" : "yuv"}
enableZoomGesture={false}
zoom={1}
/>
Relevant log output
********** Crash dump: **********
Build fingerprint: 'google/redfin/redfin:13/TQ3A.230901.001/10750268:user/release-keys'
#00 0x00000000000418f0 /system/lib64/libmedia_jni.so (Image_getFormat(_JNIEnv*, _jobject*, int)+100) (BuildId: 012e7bc47c226602b2c4185b894c1c3c)
#01 0x000000000034dc30 /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+144) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#02 0x00000000005d0530 /apex/com.android.art/lib64/libart.so (nterp_helper+4016) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#03 0x000000000033c8c2 /system/framework/framework.jar (android.media.ImageReader$SurfaceImage.getFormat+46)
#04 0x00000000005d04d4 /apex/com.android.art/lib64/libart.so (nterp_helper+3924) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#05 0x000000000033c9b2 /system/framework/framework.jar (android.media.ImageReader$SurfaceImage.getWidth+6)
#06 0x00000000005d04d4 /apex/com.android.art/lib64/libart.so (nterp_helper+3924) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#07 0x000000000033f356 /system/framework/framework.jar (android.media.Image.getCropRect+18)
#08 0x00000000003371a4 /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+612) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#09 0x0000000000519790 /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+1976) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#10 0x00000000004a2e3c /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false>(art::interpreter::SwitchImplContext*)+960) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#11 0x00000000003503d8 /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#12 0x000000000011e638 [anon:dalvik-classes2.dex extracted in memory from /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!classes2.dex] (com.mrousavy.camera.frameprocessor.Frame.getIsValid+0)
#13 0x000000000036c700 /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.3816585244953842104)+232) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#14 0x000000000036bff8 /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+964) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#15 0x000000000034dd68 /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#16 0x00000000003371a4 /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+612) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#17 0x00000000003352cc /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithVarArgs<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, std::__va_list)+772) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#18 0x000000000058dd24 /apex/com.android.art/lib64/libart.so (art::JNI<true>::CallBooleanMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)+148) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#19 0x00000000003f3f10 /apex/com.android.art/lib64/libart.so (art::(anonymous namespace)::CheckJNI::CallMethodV(char const*, _JNIEnv*, _jobject*, _jclass*, _jmethodID*, std::__va_list, art::Primitive::Type, art::InvokeType) (.__uniq.99033978352804627313491551960229047428)+720) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#20 0x000000000055d560 /apex/com.android.art/lib64/libart.so (art::(anonymous namespace)::CheckJNI::CallBooleanMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list) (.__uniq.99033978352804627313491551960229047428.llvm.6178811259984417487)+72) (BuildId: a5fcf27f4a71b07dff05c648ad58e3cd)
#21 0x0000000000050d28 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!libVisionCamera.so (offset 0x905e000) (_JNIEnv::CallBooleanMethod(_jobject*, _jmethodID*, ...)+116) (BuildId: 98e1c4344036e6e720e99c8d9f5409cec133e94f)
_JNIEnv::CallBooleanMethod(_jobject*, _jmethodID*, ...)
/Users/xavier.seignard/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/jni.h:618:5
#22 0x000000000005580c /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!libVisionCamera.so (offset 0x905e000) (vision::JFrame::getIsValid() const+100) (BuildId: 98e1c4344036e6e720e99c8d9f5409cec133e94f)
facebook::jni::JMethod<unsigned char ()>::operator()(facebook::jni::alias_ref<_jobject*>) const
/Users/xavier.seignard/.gradle/caches/transforms-3/6b918ff35b62995ee8f14daa75307542/transformed/jetified-fbjni-0.3.0/prefab/modules/fbjni/include/fbjni/detail/Meta-inl.h:100:1
vision::JFrame::getIsValid() const
/Users/xavier.seignard/REDACTED/REDACTED-web/node_modules/react-native-vision-camera/android/src/main/cpp/frameprocessor/java-bindings/JFrame.cpp:29:10
#23 0x0000000000049f6c /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!libVisionCamera.so (offset 0x905e000) (vision::FrameHostObject::get(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)+1492) (BuildId: 98e1c4344036e6e720e99c8d9f5409cec133e94f)
vision::FrameHostObject::get(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)
/Users/xavier.seignard/REDACTED/REDACTED-web/node_modules/react-native-vision-camera/android/src/main/cpp/frameprocessor/FrameHostObject.cpp:137:59
#24 0x00000000003e0080 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!libhermes_executor.so (offset 0x656c000) (facebook::jsi::DecoratedHostObject::get(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)+88) (BuildId: 5a3214274800ef73)
facebook::jsi::DecoratedHostObject::get(facebook::jsi::Runtime&, facebook::jsi::PropNameID const&)
??:0:0
#25 0x000000000007c16c /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!libhermes.so (offset 0x1519000) (BuildId: ac71a7c9e63858fa4554811e1f4806b7e5389562)
??
??:0:0
#26 0x00000000000c0fb0 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!libhermes.so (offset 0x1519000) (BuildId: ac71a7c9e63858fa4554811e1f4806b7e5389562)
??
??:0:0
#27 0x00000000000a8020 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!libhermes.so (offset 0x1519000) (BuildId: ac71a7c9e63858fa4554811e1f4806b7e5389562)
??
??:0:0
#28 0x00000000000a542c /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!libhermes.so (offset 0x1519000) (BuildId: ac71a7c9e63858fa4554811e1f4806b7e5389562)
??
??:0:0
#29 0x0000000000087fc0 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!libhermes.so (offset 0x1519000) (BuildId: ac71a7c9e63858fa4554811e1f4806b7e5389562)
??
??:0:0
#30 0x0000000000075bbc /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!libhermes.so (offset 0x1519000) (BuildId: ac71a7c9e63858fa4554811e1f4806b7e5389562)
??
??:0:0
#31 0x00000000003dee74 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!libhermes_executor.so (offset 0x656c000) (facebook::jsi::RuntimeDecorator<facebook::jsi::Runtime, facebook::jsi::Runtime>::call(facebook::jsi::Function const&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)+68) (BuildId: 5a3214274800ef73)
facebook::jsi::RuntimeDecorator<facebook::jsi::Runtime, facebook::jsi::Runtime>::call(facebook::jsi::Function const&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)
??:0:0
#32 0x00000000003dd2b0 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!libhermes_executor.so (offset 0x656c000) (BuildId: 5a3214274800ef73)
??
??:0:0
#33 0x00000000001076e8 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!librnworklets.so (offset 0xea5000) (facebook::jsi::Function::call(facebook::jsi::Runtime&, facebook::jsi::Value const*, unsigned long) const+108) (BuildId: 144b7ace8fd7b88a1c50702a7ccd635af80573c4)
facebook::jsi::Function::call(facebook::jsi::Runtime&, facebook::jsi::Value const*, unsigned long) const
/Users/xavier.seignard/.gradle/caches/transforms-3/6d46c82acd568adf361e70c6e9df93b4/transformed/jetified-react-android-0.72.5-debug/prefab/modules/jsi/include/jsi/jsi-inl.h:259:18
#34 0x000000000015732c /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!librnworklets.so (offset 0xea5000) (BuildId: 144b7ace8fd7b88a1c50702a7ccd635af80573c4)
RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const::'lambda0'(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>)::operator()(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>) const::'lambda'(facebook::jsi::Runtime&)::operator()(facebook::jsi::Runtime&) const
/Users/xavier.seignard/REDACTED/REDACTED-web/node_modules/react-native-worklets-core/cpp/WKTJsiWorkletContext.cpp:352:32
#35 0x0000000000157168 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!librnworklets.so (offset 0xea5000) (BuildId: 144b7ace8fd7b88a1c50702a7ccd635af80573c4)
decltype(std::__ndk1::forward<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const::'lambda0'(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>)::operator()(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>) const::'lambda'(facebook::jsi::Runtime&)&>(fp)(std::__ndk1::forward<facebook::jsi::Runtime&>(fp0))) std::__ndk1::__invoke<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const::'lambda0'(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>)::operator()(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>) const::'lambda'(facebook::jsi::Runtime&)&, facebook::jsi::Runtime&>(RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const::'lambda0'(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>)::operator()(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>) const::'lambda'(facebook::jsi::Runtime&)&, facebook::jsi::Runtime&)
/Users/xavier.seignard/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/type_traits:3874:1
#36 0x0000000000157104 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!librnworklets.so (offset 0xea5000) (BuildId: 144b7ace8fd7b88a1c50702a7ccd635af80573c4)
void std::__ndk1::__invoke_void_return_wrapper<void>::__call<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const::'lambda0'(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>)::operator()(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>) const::'lambda'(facebook::jsi::Runtime&)&, facebook::jsi::Runtime&>(RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const::'lambda0'(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>)::operator()(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>) const::'lambda'(facebook::jsi::Runtime&)&, facebook::jsi::Runtime&)
/Users/xavier.seignard/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/__functional_base:348:9
#37 0x00000000001570c4 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!librnworklets.so (offset 0xea5000) (BuildId: 144b7ace8fd7b88a1c50702a7ccd635af80573c4)
std::__ndk1::__function::__alloc_func<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const::'lambda0'(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>)::operator()(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>) const::'lambda'(facebook::jsi::Runtime&), std::__ndk1::allocator<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const::'lambda0'(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>)::operator()(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>) const::'lambda'(facebook::jsi::Runtime&)>, void (facebook::jsi::Runtime&)>::operator()(facebook::jsi::Runtime&)
/Users/xavier.seignard/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/functional:1557:16
#38 0x0000000000155e98 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!librnworklets.so (offset 0xea5000) (BuildId: 144b7ace8fd7b88a1c50702a7ccd635af80573c4)
std::__ndk1::__function::__func<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const::'lambda0'(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>)::operator()(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>) const::'lambda'(facebook::jsi::Runtime&), std::__ndk1::allocator<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const::'lambda0'(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>)::operator()(facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>) const::'lambda'(facebook::jsi::Runtime&)>, void (facebook::jsi::Runtime&)>::operator()(facebook::jsi::Runtime&)
/Users/xavier.seignard/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/functional:1731:12
#39 0x000000000013e220 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!librnworklets.so (offset 0xea5000) (BuildId: 144b7ace8fd7b88a1c50702a7ccd635af80573c4)
std::__ndk1::__function::__value_func<void (facebook::jsi::Runtime&)>::operator()(facebook::jsi::Runtime&) const
/Users/xavier.seignard/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/functional:1884:16
#40 0x000000000013e18c /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!librnworklets.so (offset 0xea5000) (std::__ndk1::function<void (facebook::jsi::Runtime&)>::operator()(facebook::jsi::Runtime&) const+44) (BuildId: 144b7ace8fd7b88a1c50702a7ccd635af80573c4)
std::__ndk1::function<void (facebook::jsi::Runtime&)>::operator()(facebook::jsi::Runtime&) const
/Users/xavier.seignard/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/functional:2556:12
#41 0x0000000000155544 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!librnworklets.so (offset 0xea5000) (BuildId: 144b7ace8fd7b88a1c50702a7ccd635af80573c4)
RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const::'lambda'(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)::operator()(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&) const::'lambda'(facebook::jsi::Runtime&)::operator()(facebook::jsi::Runtime&) const
/Users/xavier.seignard/REDACTED/REDACTED-web/node_modules/react-native-worklets-core/cpp/WKTJsiWorkletContext.cpp:309:44
#42 0x0000000000155504 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!librnworklets.so (offset 0xea5000) (BuildId: 144b7ace8fd7b88a1c50702a7ccd635af80573c4)
decltype(std::__ndk1::forward<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const::'lambda'(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)::operator()(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&) const::'lambda'(facebook::jsi::Runtime&)&>(fp)(std::__ndk1::forward<facebook::jsi::Runtime&>(fp0))) std::__ndk1::__invoke<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const::'lambda'(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)::operator()(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&) const::'lambda'(facebook::jsi::Runtime&)&, facebook::jsi::Runtime&>(RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const::'lambda'(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)::operator()(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&) const::'lambda'(facebook::jsi::Runtime&)&, facebook::jsi::Runtime&)
/Users/xavier.seignard/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/type_traits:3874:1
#43 0x00000000001554a0 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!librnworklets.so (offset 0xea5000) (BuildId: 144b7ace8fd7b88a1c50702a7ccd635af80573c4)
void std::__ndk1::__invoke_void_return_wrapper<void>::__call<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const::'lambda'(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)::operator()(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&) const::'lambda'(facebook::jsi::Runtime&)&, facebook::jsi::Runtime&>(RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const::'lambda'(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)::operator()(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&) const::'lambda'(facebook::jsi::Runtime&)&, facebook::jsi::Runtime&)
/Users/xavier.seignard/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/__functional_base:348:9
#44 0x0000000000155460 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!librnworklets.so (offset 0xea5000) (BuildId: 144b7ace8fd7b88a1c50702a7ccd635af80573c4)
std::__ndk1::__function::__alloc_func<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const::'lambda'(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)::operator()(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&) const::'lambda'(facebook::jsi::Runtime&), std::__ndk1::allocator<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const::'lambda'(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)::operator()(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&) const::'lambda'(facebook::jsi::Runtime&)>, void (facebook::jsi::Runtime&)>::operator()(facebook::jsi::Runtime&)
/Users/xavier.seignard/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/functional:1557:16
#45 0x0000000000154348 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!librnworklets.so (offset 0xea5000) (BuildId: 144b7ace8fd7b88a1c50702a7ccd635af80573c4)
std::__ndk1::__function::__func<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const::'lambda'(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)::operator()(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&) const::'lambda'(facebook::jsi::Runtime&), std::__ndk1::allocator<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) const::'lambda'(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)::operator()(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&) const::'lambda'(facebook::jsi::Runtime&)>, void (facebook::jsi::Runtime&)>::operator()(facebook::jsi::Runtime&)
/Users/xavier.seignard/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/functional:1731:12
#46 0x000000000013e220 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!librnworklets.so (offset 0xea5000) (BuildId: 144b7ace8fd7b88a1c50702a7ccd635af80573c4)
std::__ndk1::__function::__value_func<void (facebook::jsi::Runtime&)>::operator()(facebook::jsi::Runtime&) const
/Users/xavier.seignard/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/functional:1884:16
#47 0x000000000013e18c /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!librnworklets.so (offset 0xea5000) (std::__ndk1::function<void (facebook::jsi::Runtime&)>::operator()(facebook::jsi::Runtime&) const+44) (BuildId: 144b7ace8fd7b88a1c50702a7ccd635af80573c4)
std::__ndk1::function<void (facebook::jsi::Runtime&)>::operator()(facebook::jsi::Runtime&) const
/Users/xavier.seignard/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/functional:2556:12
#48 0x000000000013dfe8 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!librnworklets.so (offset 0xea5000) (BuildId: 144b7ace8fd7b88a1c50702a7ccd635af80573c4)
RNWorklet::JsiWorkletContext::invokeOnJsThread(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)::$_1::operator()() const
/Users/xavier.seignard/REDACTED/REDACTED-web/node_modules/react-native-worklets-core/cpp/WKTJsiWorkletContext.cpp:132:7
#49 0x000000000013defc /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!librnworklets.so (offset 0xea5000) (BuildId: 144b7ace8fd7b88a1c50702a7ccd635af80573c4)
decltype(std::__ndk1::forward<RNWorklet::JsiWorkletContext::invokeOnJsThread(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)::$_1&>(fp)()) std::__ndk1::__invoke<RNWorklet::JsiWorkletContext::invokeOnJsThread(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)::$_1&>(RNWorklet::JsiWorkletContext::invokeOnJsThread(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)::$_1&)
/Users/xavier.seignard/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/type_traits:3874:1
#50 0x000000000013deb0 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!librnworklets.so (offset 0xea5000) (BuildId: 144b7ace8fd7b88a1c50702a7ccd635af80573c4)
void std::__ndk1::__invoke_void_return_wrapper<void>::__call<RNWorklet::JsiWorkletContext::invokeOnJsThread(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)::$_1&>(RNWorklet::JsiWorkletContext::invokeOnJsThread(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)::$_1&)
/Users/xavier.seignard/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/__functional_base:348:9
#51 0x000000000013de88 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!librnworklets.so (offset 0xea5000) (BuildId: 144b7ace8fd7b88a1c50702a7ccd635af80573c4)
std::__ndk1::__function::__alloc_func<RNWorklet::JsiWorkletContext::invokeOnJsThread(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)::$_1, std::__ndk1::allocator<RNWorklet::JsiWorkletContext::invokeOnJsThread(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)::$_1>, void ()>::operator()()
/Users/xavier.seignard/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/functional:1557:16
#52 0x000000000013cc4c /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!librnworklets.so (offset 0xea5000) (BuildId: 144b7ace8fd7b88a1c50702a7ccd635af80573c4)
std::__ndk1::__function::__func<RNWorklet::JsiWorkletContext::invokeOnJsThread(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)::$_1, std::__ndk1::allocator<RNWorklet::JsiWorkletContext::invokeOnJsThread(std::__ndk1::function<void (facebook::jsi::Runtime&)>&&)::$_1>, void ()>::operator()()
/Users/xavier.seignard/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/c++/v1/functional:1731:12
#53 0x000000000004a5e8 /data/app/~~BMVBv-pBIFrTSW-JQ9axLA==/com.REDACTED-Xs1dulzccjN40HiZwN4c-A==/base.apk!libreact_render_runtimescheduler.so (offset 0x4baa000) (BuildId: e9cc0177fcb8bf54)
Camera Device
{
"sensorOrientation": "landscape-left",
"hardwareLevel": "full",
"maxZoom": 7,
"minZoom": 1,
"supportsLowLightBoost": false,
"neutralZoom": 1,
"physicalDevices": [
"wide-angle-camera"
],
"supportsFocus": true,
"supportsRawCapture": true,
"isMultiCam": false,
"name": "FRONT (1)",
"hasFlash": false,
"hasTorch": false,
"position": "front",
"id": "1"
}
Device
Pixel 5 / Android 13
VisionCamera Version
3.3.1 / worklets-core 0.2.2 / rn 0.72.5 / expo 49
Can you reproduce this issue in the VisionCamera Example app?
I don't reproduce even with my custom frame processor
Additional information
- [X] I am using Expo
- [X] I have enabled Frame Processors (react-native-worklets-core)
- [X] I have read the Troubleshooting Guide
- [X] I agree to follow this project's Code of Conduct
- [X] I searched for similar issues in this repository and found none.
Ok, after a good night of sleep, I know the problem.
If you look at my frame processor:
const measurePupillaryDistanceInPixelsJS = Worklets.createRunInJsFn(measurePupillaryDistanceInPixels);
const frameProcessor = useFrameProcessor((frame: CameraFrame) => {
"worklet";
runAtTargetFps(frameProcessorFps, () => {
"worklet";
if (!frame.isValid) return;
const result = scanForEyes(frame); // custom frame processor
measurePupillaryDistanceInPixelsJS({
frame,
face: result?.faces?.[0],
});
});
}, []);
You see I jump threads with the call to measurePupillaryDistanceInPixelsJS
which wraps a measurePupillaryDistanceInPixels
Looking more closely the measurePupillaryDistanceInPixels
I have the following:
const measurePupillaryDistanceInPixels = useCallback(
({ frame, face }: { frame: CameraFrame, face?: Face }) => {
if (!frame.isValid) return;
// Android is given dimensions in landscape mode
const portraitWidth = Math.min(frame.width, frame.height);
const portraitHeight = Math.max(frame.width, frame.height);
// blablabla
},
[]
);
Well, don't try to access the frame
props from the JS thread as the frame
can be null here. I won't dig into the why 🤷
Stay on the worklet thread and use useWorklet
instead of doing you computations on the JS thread like I do 🤦
Hope this helps
Just hit by the same problem on V2 - sort of different setup than OP's though. (I'm not using Expo)
While trying to access frame
from within useFrameProcessor using js, the app crashes with SIGSEGV
on release builds (yeah wired enough debug builds works fine).
So I quickly moved all frame-related code to Java side of frame processor plugin and the crash is gone.
I do feel like it's some kind of "intend usage" (the frame
is only intended to be passed to native side of frame processor and is not for anything else), mixed with some Android-specific wired behavior.
@mrousavy do you think it's necessary to dig into how/why this happened? (since it happened on both v2 and v3, with different worklet libs)
I think we can leave it as-is since we can do anything we want on the Java side and return the results packed in a WritableNativeMap
.
Yea I mean frame
should be intended to be either passed to native or access it in JS - it's completely fine to access anything in JS there. Please create a crash report
EDIT: If it's V2 I won't investigate it (unless someone pays me to). For V3 I might investigate it if it's an easy fix
Still happening in release mode 🤷
Actually I never succeedeed to make react-native-vision-camera@v3
work on android release builds (with proguard enabled)
From the stacktrace it looks like frame.isValid
is calling _frame.getIsValid()
on the native C++ side, and the internal _frame
is null
...
Does it work if you disable proguard?
This is really weird, as I never assign this->frame
to nullptr
and never pass a nullptr
frame
to the ctor.
Only situation where I do this is in the JS destructor: https://github.com/mrousavy/react-native-vision-camera/blob/f4617a3918783ff188c8b63f0694b1ad94ce3fae/package/android/src/main/cpp/frameprocessor/FrameHostObject.cpp#L24-L30
But I doubt that the JS destructor is called when you actually still have a reference in JS 🤔
I've read somewhere that this could be related to proguard removing codes that should not get removed. Does expo has proguard enabled in release builds?
Hello I am using "react-native-vision-camera": "3.6.4" and "react-native-worklets-core": "^0.2.4", App crashes after 5 minutes during frame processing
let frameProcessor = useFrameProcessor((frame) => {
"worklet";
try {
const data = frame.toArrayBuffer();
let avg = (data[0] + data[1] + data[2]) / 3;
hideSS(avg);
} finally {
//
}
}, []);
const format = useCameraFormat(device, [
{ videoResolution: { width: 720, height: 720 } },
{ fps: 10 },
]);
return (
<Camera
style={{
height: 500,
width: 500,
position: "absolute",
// zIndex: 2,
}}
device={device}
frameProcessor={frameProcessor}
isActive={true}
// enableFpsGraph={true}
format={format}
fps={10}
/>
);`
can you wait the same 5 minutes with hideSS(avg)
commented, and confirm the same crash?
Yes @rodgomesc I have checked with commenting hideSS(avg), still crash
that's weird, i can see the PreviewView Surface
being destroyed after a Memory warning
something is eating your memory, i had a similar issue some days ago while i was not releasing memory correctly in my c++ functions, please double check if you are not somehow blocking vision-camera from release it's resources
Thanks, @rodgomesc, but I already checked all the way. I also reset the bundle on the run time every 2 minutes app, it will crash after one hour. If I comment frameProcessor={frameProcessor}
from <Camera />
it's working fine.
I also monitored profiling in Android Studio. App crashes before reaching memory limit.
This issue caused by plugin or OS?
Does it work if you disable proguard?
Yes, it works in my case: "react-native": "0.72.7", "react-native-reanimated": "3.6.1", "react-native-vision-camera": "^3.6.16", "react-native-worklets-core": "^0.2.4",
Hey! Closing as I think this has been recently fixed. Let me know if you still encounter this issue in 3.7.1