Open jodrescher opened 2 weeks ago
no other log output or errors or something corresponding to the async function
I need log outputs or error messages or anything. Please post those, otherwise I cannot help you. On Android, use adb logcat
.
Ah nevermind you just posted error messages this second lol
Just to clarify; this works fine in Debug, but fails in Release?
Just to clarify; this works fine in Debug, but fails in Release?
Yes, exactly, I had this with older versions of vision-camera and worklets-core too and hoped that the current version would fix it.
I am looking at the code and I don't really see where the initialization is different, are you 100% sure that it works with the Worklets.defaultContext
, but doesn't work with the Worklets.createContext('VisionCamera.async')
?
And does this crash on iOS as well, or only Android?
@mrousavy This issue is related to #2589 and also this worklets-core issue.
On old worklets-core version (0.4.0), creating context with Worklets.createRunInContextFn( func, 'AnyStringValue' )
also prevents app from crashing.
And does this crash on iOS as well, or only Android?
I tested it only on android. I'll test on IOS and provide you a feedback.
I am looking at the code and I don't really see where the initialization is different, are you 100% sure that it works with the
Worklets.defaultContext
, but doesn't work with theWorklets.createContext('VisionCamera.async')
?And does this crash on iOS as well, or only Android?
I have now tested the Example app again on a Samsung A55 (Android 14), a Samsung A41 (Android 12) and an iPhone 12 mini (iOS 17.4.1). The same result on all devices, everything works in debug mode, even with âWorklets.createContext(âVisionCamera.asyncâ)â. In release mode, however, the app crashes. If I change to âWorklets.defaultContextâ it works on all devices, even in release mode.
This is so weird. I mean we definitely want a separate Context in case you are using react-native-worklets-core for something else (which is usually the default context), so not sure why this is happening.
Hey - I spent a little time investigating the parallel memory allocations and actually found & fixed a bug! Try this and see if this fixes your issue: https://github.com/mrousavy/react-native-vision-camera/pull/2829
For me, runAsync
runs perfectly fine now
Hey - I spent a little time investigating the parallel memory allocations and actually found & fixed a bug! Try this and see if this fixes your issue: #2829
I tested it with the current clean repo version and it sometimes works on iOS, but most of the time the app crashes (9 out of 10 cases). The fix is only for iOS? I get the following error message in XCode: Thread 9: EXC_BAD_ACCESS (code=1, address=0x80000000000000d0)
Thread 9 Queue : mrousavy/VisionCamera.video (serial)
#0 0x0000000102fcd4c4 in long std::__1::__libcpp_atomic_refcount_increment[abi:ue170006]<long>(long&) [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__memory/shared_ptr.h:106
#1 0x0000000102fcd4c4 in std::__1::__shared_weak_count::__add_weak[abi:ue170006]() [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__memory/shared_ptr.h:210
#2 0x0000000102fcd4c0 in std::__1::weak_ptr<RNWorklet::JsiWorkletContext>::weak_ptr(std::__1::weak_ptr<RNWorklet::JsiWorkletContext> const&) [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__memory/shared_ptr.h:1722
#3 0x0000000102fcd4b4 in std::__1::weak_ptr<RNWorklet::JsiWorkletContext>::weak_ptr(std::__1::weak_ptr<RNWorklet::JsiWorkletContext> const&) [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__memory/shared_ptr.h:1720
#4 0x0000000102fcd4b4 in std::__1::enable_shared_from_this<RNWorklet::JsiWorkletContext>::weak_from_this[abi:ue170006]() [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__memory/shared_ptr.h:1963
#5 0x0000000102fcd4b4 in RNWorklet::JsiWorkletContext::invokeOnWorkletThread(std::__1::function<void (RNWorklet::JsiWorkletContext*, facebook::jsi::Runtime&)>&&) at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/WKTJsiWorkletContext.cpp:146
#6 0x0000000102fd631c in 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::__1::function<void (facebook::jsi::Runtime&)>&&)::operator()(std::__1::function<void (facebook::jsi::Runtime&)>&&) const [inlined] at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/WKTJsiWorkletContext.cpp:309
#7 0x0000000102fd62cc in 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::__1::shared_ptr<RNWorklet::PromiseParameter>)::operator()(facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>) const [inlined] at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/WKTJsiWorkletContext.cpp:344
#8 0x0000000102fd618c in decltype(std::declval<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::__1::shared_ptr<RNWorklet::PromiseParameter>)&>()(std::declval<facebook::jsi::Runtime&>(), std::declval<std::__1::shared_ptr<RNWorklet::PromiseParameter>>())) std::__1::__invoke[abi:ue170006]<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::__1::shared_ptr<RNWorklet::PromiseParameter>)&, facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>>(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::__1::shared_ptr<RNWorklet::PromiseParameter>)&, facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__type_traits/invoke.h:340
#9 0x0000000102fd6184 in void std::__1::__invoke_void_return_wrapper<void, true>::__call[abi:ue170006]<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::__1::shared_ptr<RNWorklet::PromiseParameter>)&, facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>>(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::__1::shared_ptr<RNWorklet::PromiseParameter>)&, facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__type_traits/invoke.h:415
#10 0x0000000102fd6184 in std::__1::__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::__1::shared_ptr<RNWorklet::PromiseParameter>), std::__1::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::__1::shared_ptr<RNWorklet::PromiseParameter>)>, void (facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>)>::operator()[abi:ue170006](facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__functional/function.h:193
#11 0x0000000102fd6184 in std::__1::__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::__1::shared_ptr<RNWorklet::PromiseParameter>), std::__1::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::__1::shared_ptr<RNWorklet::PromiseParameter>)>, void (facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>)>::operator()(facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>&&) at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__functional/function.h:364
#12 0x0000000102fc3138 in std::__1::__function::__value_func<void (facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>)>::operator()[abi:ue170006](facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>&&) const [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__functional/function.h:518
#13 0x0000000102fc311c in std::__1::function<void (facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>)>::operator()(facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>) const [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__functional/function.h:1169
#14 0x0000000102fc311c in RNWorklet::JsiPromiseWrapper::runComputation(facebook::jsi::Runtime&, std::__1::function<void (facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>)>) at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/wrappers/WKTJsiPromiseWrapper.cpp:31
#15 0x0000000102fc3028 in RNWorklet::JsiPromiseWrapper::createPromiseWrapper(facebook::jsi::Runtime&, std::__1::function<void (facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>)>) at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/wrappers/WKTJsiPromiseWrapper.cpp:18
#16 0x0000000102fd4d4c in 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 [inlined] at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/WKTJsiWorkletContext.cpp:338
#17 0x0000000102fd4b74 in decltype(std::declval<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5&>()(std::declval<facebook::jsi::Runtime&>(), std::declval<facebook::jsi::Value const&>(), std::declval<facebook::jsi::Value const*>(), std::declval<unsigned long>())) std::__1::__invoke[abi:ue170006]<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long>(RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*&&, unsigned long&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__type_traits/invoke.h:340
#18 0x0000000102fd4b6c in facebook::jsi::Value std::__1::__invoke_void_return_wrapper<facebook::jsi::Value, false>::__call[abi:ue170006]<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long>(RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*&&, unsigned long&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__type_traits/invoke.h:407
#19 0x0000000102fd4b6c in std::__1::__function::__alloc_func<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5, std::__1::allocator<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5>, facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>::operator()[abi:ue170006](facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*&&, unsigned long&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__functional/function.h:193
#20 0x0000000102fd4b6c in std::__1::__function::__func<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5, std::__1::allocator<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5>, facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*&&, unsigned long&&) at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__functional/function.h:364
#21 0x0000000123b95480 in ___lldb_unnamed_symbol838 ()
#22 0x0000000123ba8d70 in ___lldb_unnamed_symbol1219 ()
#23 0x0000000123bc7da8 in ___lldb_unnamed_symbol1739 ()
#24 0x0000000123bc72b4 in ___lldb_unnamed_symbol1738 ()
#25 0x0000000123ba9018 in ___lldb_unnamed_symbol1225 ()
#26 0x0000000123b8ddd4 in ___lldb_unnamed_symbol680 ()
#27 0x0000000102e92b90 in facebook::jsi::Function::callWithThis(facebook::jsi::Runtime&, facebook::jsi::Object const&, facebook::jsi::Value const*, unsigned long) const [inlined] at ../react-native-vision-camera/package/example/ios/Pods/Headers/Public/hermes-engine/jsi/jsi-inl.h:280
#28 0x0000000102e92b50 in RNWorklet::JsiWorklet::call(std::__1::shared_ptr<facebook::jsi::Function>, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/WKTJsiWorklet.h:219
#29 0x0000000102e92234 in RNWorklet::WorkletInvoker::call(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/WKTJsiWorklet.h:369
#30 0x0000000123b95480 in ___lldb_unnamed_symbol838 ()
#31 0x0000000123ba8d70 in ___lldb_unnamed_symbol1219 ()
#32 0x0000000123bc7da8 in ___lldb_unnamed_symbol1739 ()
#33 0x0000000123bc72b4 in ___lldb_unnamed_symbol1738 ()
#34 0x0000000123ba9018 in ___lldb_unnamed_symbol1225 ()
#35 0x0000000123b8ddd4 in ___lldb_unnamed_symbol680 ()
#36 0x0000000102e92b90 in facebook::jsi::Function::callWithThis(facebook::jsi::Runtime&, facebook::jsi::Object const&, facebook::jsi::Value const*, unsigned long) const [inlined] at ../react-native-vision-camera/package/example/ios/Pods/Headers/Public/hermes-engine/jsi/jsi-inl.h:280
#37 0x0000000102e92b50 in RNWorklet::JsiWorklet::call(std::__1::shared_ptr<facebook::jsi::Function>, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/WKTJsiWorklet.h:219
#38 0x0000000102e92234 in RNWorklet::WorkletInvoker::call(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/WKTJsiWorklet.h:369
#39 0x0000000123b95480 in ___lldb_unnamed_symbol838 ()
#40 0x0000000123ba8d70 in ___lldb_unnamed_symbol1219 ()
#41 0x0000000123bc7da8 in ___lldb_unnamed_symbol1739 ()
#42 0x0000000123bc72b4 in ___lldb_unnamed_symbol1738 ()
#43 0x0000000123ba9018 in ___lldb_unnamed_symbol1225 ()
#44 0x0000000123b8ddd4 in ___lldb_unnamed_symbol680 ()
#45 0x0000000102e92b90 in facebook::jsi::Function::callWithThis(facebook::jsi::Runtime&, facebook::jsi::Object const&, facebook::jsi::Value const*, unsigned long) const [inlined] at ../react-native-vision-camera/package/example/ios/Pods/Headers/Public/hermes-engine/jsi/jsi-inl.h:280
#46 0x0000000102e92b50 in RNWorklet::JsiWorklet::call(std::__1::shared_ptr<facebook::jsi::Function>, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/WKTJsiWorklet.h:219
#47 0x0000000102e92234 in RNWorklet::WorkletInvoker::call(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/WKTJsiWorklet.h:369
#48 0x0000000102e920ec in -[FrameProcessor callWithFrameHostObject:] at ../react-native-vision-camera/package/ios/FrameProcessors/FrameProcessor.mm:45
#49 0x0000000102e923a0 in -[FrameProcessor call:] at ../react-native-vision-camera/package/ios/FrameProcessors/FrameProcessor.mm:51
#50 0x0000000102eac590 in CameraView.onFrame(sampleBuffer:) [inlined] at ../react-native-vision-camera/package/ios/React/CameraView.swift:356
#51 0x0000000102eac57c in protocol witness for CameraSessionDelegate.onFrame(sampleBuffer:) in conformance CameraView [inlined] at ../react-native-vision-camera/package/example/ios/Pods/<compiler-generated>:349
#52 0x0000000102eac57c in specialized CameraSession.captureOutput(_:didOutput:from:) at ../react-native-vision-camera/package/ios/Core/CameraSession.swift:277
#53 0x0000000102eabbdc in CameraSession.captureOutput(_:didOutput:from:) [inlined] ()
#54 0x0000000102eabbd0 in @objc CameraSession.captureOutput(_:didOutput:from:) at ../react-native-vision-camera/package/example/ios/Pods/<compiler-generated>:274
#55 0x00000001bd81ec30 in -[AVCaptureVideoDataOutput _processSampleBuffer:] ()
#56 0x00000001bd81eafc in __47-[AVCaptureVideoDataOutput _updateRemoteQueue:]_block_invoke ()
#57 0x00000001c0fd42e4 in __FigRemoteOperationReceiverCreateMessageReceiver_block_invoke ()
#58 0x00000001c0fd4220 in __rqReceiverSetSource_block_invoke ()
#59 0x00000001050467bc in _dispatch_client_callout ()
#60 0x00000001050498e0 in _dispatch_continuation_pop ()
#61 0x0000000105060cc8 in _dispatch_source_latch_and_call ()
#62 0x000000010505f718 in _dispatch_source_invoke ()
#63 0x000000010504e4a4 in _dispatch_lane_serial_drain ()
#64 0x000000010504f408 in _dispatch_lane_invoke ()
#65 0x000000010505c404 in _dispatch_root_queue_drain_deferred_wlh ()
#66 0x000000010505ba38 in _dispatch_workloop_worker_thread ()
#67 0x00000001fc8f4f20 in _pthread_wqthread ()
When i use runAsyn but is not use runAsync app crash.
my code: const runOnJs = Worklets.createRunOnJS(() => { router.push("/"); });
const faceDetectionProcess = useFrameProcessor( (frame: Frame) => { "worklet"; try { console.log(plugin); runAsync(frame, () => { "worklet"; const internal = frame as FrameInternal; internal.incrementRefCount(); // @ts-ignore const faces = plugin?.call(frame) as Face[]; if (faces.length > 0) { runOnJs(); } }); } catch (error) { console.log(error); } }, [runOnJs] ); my config in babel.config module.exports = function (api) { api.cache(true); return { presets: ["babel-preset-expo"], plugins: [ [ "@tamagui/babel-plugin", { components: ["tamagui"], config: "./tamagui.config.ts", logTimings: true, disableExtraction: process.env.EXPO_PUBLIC_NODE_ENV === "development", }, ], "react-native-reanimated/plugin", ["react-native-worklets-core/plugin"], ], }; };
runs perfectly fine now
I think that #2829 is the fix for #2579 issue.
This runAsync
crash is also happening on android but #2829 pull doesn't have any changes on android files.
Okay yea well then this might be an actual Worklets bug.
I think it's really weird that it works with the defaultContext
but not with the one we create.
On worklets-core 0.4.0
It works if we create the context from a string:
Worklets.createRunInContextFn(func..., 'AnyStringValue' )
Instead of:
const asyncContext = Worklets.createContext('VisionCamera.async')
Worklets.createRunInContextFn(func..., asyncContext)
I don't know why but it works
On worklets-core
0.4.0
It works if we create the context from a string:Worklets.createRunInContextFn(func..., 'AnyStringValue' )
Instead of:
const asyncContext = Worklets.createContext('VisionCamera.async') Worklets.createRunInContextFn(func..., asyncContext)
I don't know why but it works
The type for the second parameter is IWorkletContext | 'default'
, and you are not passing in a IWorkletContext
, nor 'default'
, you are passing in a different string. TypeScript should've already told you that this isn't acceptable by adding squiggly red lines below that. However, Worklets Core didn't throw in that case, it just automatically fell back to the 'default'
context, see JsiWorkletApi::createRunInContextFn(...)
.
So your example of passing 'AnyStringValue'
is exactly the same as passing in 'default'
, or in react-native-worklets-core 1.x.x. where the string parameter has been removed, this is now exactly the same as Worklets.defaultContext
.
But it's so weird that it works with the Worklets.defaultContext
but not the custom context we create. We'll maybe look into this soon, let's see. If you want this issue prioritized consider contacting us thru the consulting agency, this will only take a few hours to fix.
The type for the second parameter is
IWorkletContext | 'default'
, and you are not passing in aIWorkletContext
, nor'default'
, you are passing in a different string. TypeScript should've already told you that this isn't acceptable by adding squiggly red lines below that.
yes yes, I had this TS warning but I rewrite it forcing my string to be from any
type.
However, Worklets Core didn't throw in that case, it just automatically fell back to the
'default'
context, seeJsiWorkletApi::createRunInContextFn(...)
.So your example of passing
'AnyStringValue'
is exactly the same as passing in'default'
, or in react-native-worklets-core 1.x.x. where the string parameter has been removed, this is now exactly the same asWorklets.defaultContext
.
okay, now that makes sense đ¤Ż
But it's so weird that it works with the Worklets.defaultContext but not the custom context we create. We'll maybe look into this soon, let's see. If you want this issue prioritized consider contacting us thru the consulting agency, this will only take a few hours to fix.
Take your time, I'm in no hury đ Also thanks for your amazing work
yes yes, I had this TS warning but I rewrite it forcing my string to be from
any
type.
Yea, it's not a warning it's an error. Basically the force cast to any didn't change anything - as I said, 'default'
has the same effect as passing in any other string.
Take your time, I'm in no hury đ Also thanks for your amazing work
I can only agree, thank you for all your hard work.
When i use runAsyn but is not use runAsync app crash.
my code: const runOnJs = Worklets.createRunOnJS(() => { router.push("/"); });
const faceDetectionProcess = useFrameProcessor( (frame: Frame) => { "worklet"; try { console.log(plugin); runAsync(frame, () => { "worklet"; const internal = frame as FrameInternal; internal.incrementRefCount(); // @ts-ignore const faces = plugin?.call(frame) as Face[]; if (faces.length > 0) { runOnJs(); } }); } catch (error) { console.log(error); } }, [runOnJs] ); my config in babel.config module.exports = function (api) { api.cache(true); return { presets: ["babel-preset-expo"], plugins: [ [ "@tamagui/babel-plugin", { components: ["tamagui"], config: "./tamagui.config.ts", logTimings: true, disableExtraction: process.env.EXPO_PUBLIC_NODE_ENV === "development", }, ], "react-native-reanimated/plugin", ["react-native-worklets-core/plugin"], ], }; };
runs perfectly fine now
I am facing the same
I got a tombstone for this. tombstone.zip
Hey - I spent a little time investigating the parallel memory allocations and actually found & fixed a bug! Try this and see if this fixes your issue: #2829
I tested it with the current clean repo version and it sometimes works on iOS, but most of the time the app crashes (9 out of 10 cases). The fix is only for iOS? I get the following error message in XCode: Thread 9: EXC_BAD_ACCESS (code=1, address=0x80000000000000d0)
Thread 9 Queue : mrousavy/VisionCamera.video (serial) #0 0x0000000102fcd4c4 in long std::__1::__libcpp_atomic_refcount_increment[abi:ue170006]<long>(long&) [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__memory/shared_ptr.h:106 #1 0x0000000102fcd4c4 in std::__1::__shared_weak_count::__add_weak[abi:ue170006]() [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__memory/shared_ptr.h:210 #2 0x0000000102fcd4c0 in std::__1::weak_ptr<RNWorklet::JsiWorkletContext>::weak_ptr(std::__1::weak_ptr<RNWorklet::JsiWorkletContext> const&) [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__memory/shared_ptr.h:1722 #3 0x0000000102fcd4b4 in std::__1::weak_ptr<RNWorklet::JsiWorkletContext>::weak_ptr(std::__1::weak_ptr<RNWorklet::JsiWorkletContext> const&) [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__memory/shared_ptr.h:1720 #4 0x0000000102fcd4b4 in std::__1::enable_shared_from_this<RNWorklet::JsiWorkletContext>::weak_from_this[abi:ue170006]() [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__memory/shared_ptr.h:1963 #5 0x0000000102fcd4b4 in RNWorklet::JsiWorkletContext::invokeOnWorkletThread(std::__1::function<void (RNWorklet::JsiWorkletContext*, facebook::jsi::Runtime&)>&&) at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/WKTJsiWorkletContext.cpp:146 #6 0x0000000102fd631c in 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::__1::function<void (facebook::jsi::Runtime&)>&&)::operator()(std::__1::function<void (facebook::jsi::Runtime&)>&&) const [inlined] at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/WKTJsiWorkletContext.cpp:309 #7 0x0000000102fd62cc in 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::__1::shared_ptr<RNWorklet::PromiseParameter>)::operator()(facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>) const [inlined] at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/WKTJsiWorkletContext.cpp:344 #8 0x0000000102fd618c in decltype(std::declval<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::__1::shared_ptr<RNWorklet::PromiseParameter>)&>()(std::declval<facebook::jsi::Runtime&>(), std::declval<std::__1::shared_ptr<RNWorklet::PromiseParameter>>())) std::__1::__invoke[abi:ue170006]<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::__1::shared_ptr<RNWorklet::PromiseParameter>)&, facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>>(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::__1::shared_ptr<RNWorklet::PromiseParameter>)&, facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__type_traits/invoke.h:340 #9 0x0000000102fd6184 in void std::__1::__invoke_void_return_wrapper<void, true>::__call[abi:ue170006]<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::__1::shared_ptr<RNWorklet::PromiseParameter>)&, facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>>(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::__1::shared_ptr<RNWorklet::PromiseParameter>)&, facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__type_traits/invoke.h:415 #10 0x0000000102fd6184 in std::__1::__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::__1::shared_ptr<RNWorklet::PromiseParameter>), std::__1::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::__1::shared_ptr<RNWorklet::PromiseParameter>)>, void (facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>)>::operator()[abi:ue170006](facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__functional/function.h:193 #11 0x0000000102fd6184 in std::__1::__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::__1::shared_ptr<RNWorklet::PromiseParameter>), std::__1::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::__1::shared_ptr<RNWorklet::PromiseParameter>)>, void (facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>)>::operator()(facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>&&) at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__functional/function.h:364 #12 0x0000000102fc3138 in std::__1::__function::__value_func<void (facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>)>::operator()[abi:ue170006](facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>&&) const [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__functional/function.h:518 #13 0x0000000102fc311c in std::__1::function<void (facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>)>::operator()(facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>) const [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__functional/function.h:1169 #14 0x0000000102fc311c in RNWorklet::JsiPromiseWrapper::runComputation(facebook::jsi::Runtime&, std::__1::function<void (facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>)>) at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/wrappers/WKTJsiPromiseWrapper.cpp:31 #15 0x0000000102fc3028 in RNWorklet::JsiPromiseWrapper::createPromiseWrapper(facebook::jsi::Runtime&, std::__1::function<void (facebook::jsi::Runtime&, std::__1::shared_ptr<RNWorklet::PromiseParameter>)>) at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/wrappers/WKTJsiPromiseWrapper.cpp:18 #16 0x0000000102fd4d4c in 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 [inlined] at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/WKTJsiWorkletContext.cpp:338 #17 0x0000000102fd4b74 in decltype(std::declval<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5&>()(std::declval<facebook::jsi::Runtime&>(), std::declval<facebook::jsi::Value const&>(), std::declval<facebook::jsi::Value const*>(), std::declval<unsigned long>())) std::__1::__invoke[abi:ue170006]<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long>(RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*&&, unsigned long&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__type_traits/invoke.h:340 #18 0x0000000102fd4b6c in facebook::jsi::Value std::__1::__invoke_void_return_wrapper<facebook::jsi::Value, false>::__call[abi:ue170006]<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long>(RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*&&, unsigned long&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__type_traits/invoke.h:407 #19 0x0000000102fd4b6c in std::__1::__function::__alloc_func<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5, std::__1::allocator<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5>, facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>::operator()[abi:ue170006](facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*&&, unsigned long&&) [inlined] at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__functional/function.h:193 #20 0x0000000102fd4b6c in std::__1::__function::__func<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5, std::__1::allocator<RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5>, facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>::operator()(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*&&, unsigned long&&) at /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.4.sdk/usr/include/c++/v1/__functional/function.h:364 #21 0x0000000123b95480 in ___lldb_unnamed_symbol838 () #22 0x0000000123ba8d70 in ___lldb_unnamed_symbol1219 () #23 0x0000000123bc7da8 in ___lldb_unnamed_symbol1739 () #24 0x0000000123bc72b4 in ___lldb_unnamed_symbol1738 () #25 0x0000000123ba9018 in ___lldb_unnamed_symbol1225 () #26 0x0000000123b8ddd4 in ___lldb_unnamed_symbol680 () #27 0x0000000102e92b90 in facebook::jsi::Function::callWithThis(facebook::jsi::Runtime&, facebook::jsi::Object const&, facebook::jsi::Value const*, unsigned long) const [inlined] at ../react-native-vision-camera/package/example/ios/Pods/Headers/Public/hermes-engine/jsi/jsi-inl.h:280 #28 0x0000000102e92b50 in RNWorklet::JsiWorklet::call(std::__1::shared_ptr<facebook::jsi::Function>, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/WKTJsiWorklet.h:219 #29 0x0000000102e92234 in RNWorklet::WorkletInvoker::call(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/WKTJsiWorklet.h:369 #30 0x0000000123b95480 in ___lldb_unnamed_symbol838 () #31 0x0000000123ba8d70 in ___lldb_unnamed_symbol1219 () #32 0x0000000123bc7da8 in ___lldb_unnamed_symbol1739 () #33 0x0000000123bc72b4 in ___lldb_unnamed_symbol1738 () #34 0x0000000123ba9018 in ___lldb_unnamed_symbol1225 () #35 0x0000000123b8ddd4 in ___lldb_unnamed_symbol680 () #36 0x0000000102e92b90 in facebook::jsi::Function::callWithThis(facebook::jsi::Runtime&, facebook::jsi::Object const&, facebook::jsi::Value const*, unsigned long) const [inlined] at ../react-native-vision-camera/package/example/ios/Pods/Headers/Public/hermes-engine/jsi/jsi-inl.h:280 #37 0x0000000102e92b50 in RNWorklet::JsiWorklet::call(std::__1::shared_ptr<facebook::jsi::Function>, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/WKTJsiWorklet.h:219 #38 0x0000000102e92234 in RNWorklet::WorkletInvoker::call(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/WKTJsiWorklet.h:369 #39 0x0000000123b95480 in ___lldb_unnamed_symbol838 () #40 0x0000000123ba8d70 in ___lldb_unnamed_symbol1219 () #41 0x0000000123bc7da8 in ___lldb_unnamed_symbol1739 () #42 0x0000000123bc72b4 in ___lldb_unnamed_symbol1738 () #43 0x0000000123ba9018 in ___lldb_unnamed_symbol1225 () #44 0x0000000123b8ddd4 in ___lldb_unnamed_symbol680 () #45 0x0000000102e92b90 in facebook::jsi::Function::callWithThis(facebook::jsi::Runtime&, facebook::jsi::Object const&, facebook::jsi::Value const*, unsigned long) const [inlined] at ../react-native-vision-camera/package/example/ios/Pods/Headers/Public/hermes-engine/jsi/jsi-inl.h:280 #46 0x0000000102e92b50 in RNWorklet::JsiWorklet::call(std::__1::shared_ptr<facebook::jsi::Function>, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/WKTJsiWorklet.h:219 #47 0x0000000102e92234 in RNWorklet::WorkletInvoker::call(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long) at ../react-native-vision-camera/package/example/node_modules/react-native-worklets-core/cpp/WKTJsiWorklet.h:369 #48 0x0000000102e920ec in -[FrameProcessor callWithFrameHostObject:] at ../react-native-vision-camera/package/ios/FrameProcessors/FrameProcessor.mm:45 #49 0x0000000102e923a0 in -[FrameProcessor call:] at ../react-native-vision-camera/package/ios/FrameProcessors/FrameProcessor.mm:51 #50 0x0000000102eac590 in CameraView.onFrame(sampleBuffer:) [inlined] at ../react-native-vision-camera/package/ios/React/CameraView.swift:356 #51 0x0000000102eac57c in protocol witness for CameraSessionDelegate.onFrame(sampleBuffer:) in conformance CameraView [inlined] at ../react-native-vision-camera/package/example/ios/Pods/<compiler-generated>:349 #52 0x0000000102eac57c in specialized CameraSession.captureOutput(_:didOutput:from:) at ../react-native-vision-camera/package/ios/Core/CameraSession.swift:277 #53 0x0000000102eabbdc in CameraSession.captureOutput(_:didOutput:from:) [inlined] () #54 0x0000000102eabbd0 in @objc CameraSession.captureOutput(_:didOutput:from:) at ../react-native-vision-camera/package/example/ios/Pods/<compiler-generated>:274 #55 0x00000001bd81ec30 in -[AVCaptureVideoDataOutput _processSampleBuffer:] () #56 0x00000001bd81eafc in __47-[AVCaptureVideoDataOutput _updateRemoteQueue:]_block_invoke () #57 0x00000001c0fd42e4 in __FigRemoteOperationReceiverCreateMessageReceiver_block_invoke () #58 0x00000001c0fd4220 in __rqReceiverSetSource_block_invoke () #59 0x00000001050467bc in _dispatch_client_callout () #60 0x00000001050498e0 in _dispatch_continuation_pop () #61 0x0000000105060cc8 in _dispatch_source_latch_and_call () #62 0x000000010505f718 in _dispatch_source_invoke () #63 0x000000010504e4a4 in _dispatch_lane_serial_drain () #64 0x000000010504f408 in _dispatch_lane_invoke () #65 0x000000010505c404 in _dispatch_root_queue_drain_deferred_wlh () #66 0x000000010505ba38 in _dispatch_workloop_worker_thread () #67 0x00000001fc8f4f20 in _pthread_wqthread ()
Running this in an LLM parser returns the following:
`Here's a breakdown of what the stack trace is showing:
It starts with a crash that seems to originate from a call to RNWorklet::JsiWorkletContext::invokeOnWorkletThread. The crash occurs while trying to call a lambda function within createCallInContext. There's a series of nested function calls involving std::1::function and std::1::shared_ptr. The crash ultimately occurs while processing a sample buffer in the CameraSession. To debug this issue, you might want to look into the implementation of RNWorklet::JsiWorkletContext and CameraSession. It appears that there might be some issue with memory management or thread synchronization when processing the sample buffer.`
Based on that information, it seems the error is occurring most likely due to context switching within the worklets module. I wonder if it is because Worklets.createRunOnJs
is unaware of the non default context. Would explain why it is working on default context.
You can try to export the context from RNVisionCam and use that to createRunOnJs
to see if it works
What's happening?
Everything works perfectly in debug mode for Android. But when I install the app with â--mode=releaseâ, the code in ârunAsyncâ is not executed or the app crashes. I was able to trace it back so far that it makes a difference in FrameProcessorPlugins.ts if I change the line âconst asyncContext = Worklets.createContext(âVisionCamera.asyncâ)â to âconst asyncContext = Worklets.defaultContextâ. Everything works with the DefaultContext, even in the release build. Could there be an error here, or am I doing something wrong in the usage? react-native-vision-camera:4.0.1 and react-native-worklets-core:1.2.0
Reproduceable Code
Relevant log output
Camera Device
Device
Samsung A55
VisionCamera Version
4.0.1
Can you reproduce this issue in the VisionCamera Example app?
Yes, I can reproduce the same issue in the Example app here
Additional information