mrousavy / react-native-vision-camera

📸 A powerful, high-performance React Native Camera library.
https://react-native-vision-camera.com
MIT License
6.62k stars 981 forks source link

🐛 runAsync not executing or app crash #2820

Open jodrescher opened 2 weeks ago

jodrescher commented 2 weeks ago

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

runAsync(frame, () => {
  'worklet';
  console.log('test');
  ...
});

//tested also with example app, and wrap the existing frameprocessor code inside runAsync:
const frameProcessor = useFrameProcessor((frame) => {
    'worklet'

    runAtTargetFps(10, () => {
    'worklet';
      runAsync(frame, () => {
        'worklet'
        console.log(`${frame.timestamp}: ${frame.width}x${frame.height} ${frame.pixelFormat} Frame (${frame.orientation})`)
        examplePlugin(frame)
        exampleKotlinSwiftPlugin(frame)
      })
    })
  }, [])

Relevant log output

no other log output or errors or something corresponding to the async function
or crash in example:
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A  Cmdline: com.mrousavy.camera.example
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A  pid: 29625, tid: 29657, name: ionCamera.video  >>> com.mrousavy.camera.example <<<
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A  uid: 10365
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A  tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A  signal 7 (SIGBUS), code 1 (BUS_ADRALN), fault addr 0x00040b360a06003a
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A      x0  b400007250c5e5c0  x1  00000073e7625be0  x2  000000746b604ae8  x3  000000745968edf8
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A      x4  0000000000000002  x5  0000000000000000  x6  00000073e7625b28  x7  00000073e7625b28
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A      x8  08040b360a06003a  x9  2707040a36090500  x10 000000745969c130  x11 00000000ffffffff
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A      x12 000000745968ee1c  x13 b400007250d22658  x14 b400007250d97120  x15 b400007250d22580
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A      x16 00000073e76fd930  x17 00000073e76c9658  x18 00000073e675a000  x19 b40000731d9af420
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A      x20 b40000731d9af420  x21 00000073e7629000  x22 b400007250c5e5c0  x23 00000073e7629000
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A      x24 b400007250d22658  x25 0000000000000003  x26 b40000731d9af420  x27 00000073e7625de0
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A      x28 0000007319de6428  x29 00000073e7625ad0
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A      lr  00000073e76d8e7c  sp  00000073e7625a50  pc  00000073e76c96d4  pst 0000000000001000
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A  72 total frames
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A  backtrace:
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #00 pc 00000000000496d4  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!librnworklets.so (offset 0x216a000) (RNWorklet::JsiWorkletContext::invokeOnWorkletThread(std::__ndk1::function<void (RNWorklet::JsiWorkletContext*, facebook::jsi::Runtime&)>&&)+124) (BuildId: def622fc74780b45fe49d34c0eaa42881d11191d)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #01 pc 0000000000058e78  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!librnworklets.so (offset 0x216a000) (BuildId: def622fc74780b45fe49d34c0eaa42881d11191d)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #02 pc 0000000000062f90  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!librnworklets.so (offset 0x216a000) (RNWorklet::JsiPromiseWrapper::runComputation(facebook::jsi::Runtime&, std::__ndk1::function<void (facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>)>)+112) (BuildId: def622fc74780b45fe49d34c0eaa42881d11191d)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #03 pc 0000000000062cd8  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!librnworklets.so (offset 0x216a000) (RNWorklet::JsiPromiseWrapper::createPromiseWrapper(facebook::jsi::Runtime&, std::__ndk1::function<void (facebook::jsi::Runtime&, std::__ndk1::shared_ptr<RNWorklet::PromiseParameter>)>)+160) (BuildId: def622fc74780b45fe49d34c0eaa42881d11191d)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #04 pc 0000000000055770  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!librnworklets.so (offset 0x216a000) (BuildId: def622fc74780b45fe49d34c0eaa42881d11191d)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #05 pc 000000000007f5c8  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #06 pc 000000000007f1dc  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #07 pc 00000000000859a0  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #08 pc 00000000000965d0  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #09 pc 0000000000097dcc  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #10 pc 00000000000975d4  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #11 pc 0000000000085aac  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #12 pc 00000000000781d8  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #13 pc 000000000003d578  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libVisionCamera.so (offset 0x5c8000) (RNWorklet::JsiWorklet::call(std::__ndk1::shared_ptr<facebook::jsi::Function>, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)+332) (BuildId: 304104e9d18a4e2082bff8f2739c5897781ec64a)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #14 pc 000000000003ca80  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libVisionCamera.so (offset 0x5c8000) (RNWorklet::WorkletInvoker::call(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)+156) (BuildId: 304104e9d18a4e2082bff8f2739c5897781ec64a)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #15 pc 000000000007f5c8  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #16 pc 000000000007f1dc  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #17 pc 00000000000859a0  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #18 pc 00000000000965d0  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #19 pc 0000000000097dcc  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #20 pc 00000000000975d4  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #21 pc 0000000000085aac  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #22 pc 00000000000781d8  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #23 pc 000000000003d578  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libVisionCamera.so (offset 0x5c8000) (RNWorklet::JsiWorklet::call(std::__ndk1::shared_ptr<facebook::jsi::Function>, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)+332) (BuildId: 304104e9d18a4e2082bff8f2739c5897781ec64a)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #24 pc 000000000003ca80  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libVisionCamera.so (offset 0x5c8000) (RNWorklet::WorkletInvoker::call(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)+156) (BuildId: 304104e9d18a4e2082bff8f2739c5897781ec64a)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #25 pc 000000000007f5c8  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #26 pc 000000000007f1dc  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #27 pc 00000000000859a0  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #28 pc 00000000000965d0  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #29 pc 0000000000097dcc  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #30 pc 00000000000975d4  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #31 pc 0000000000085aac  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #32 pc 00000000000781d8  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #33 pc 000000000003d578  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libVisionCamera.so (offset 0x5c8000) (RNWorklet::JsiWorklet::call(std::__ndk1::shared_ptr<facebook::jsi::Function>, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)+332) (BuildId: 304104e9d18a4e2082bff8f2739c5897781ec64a)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #34 pc 000000000003ca80  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libVisionCamera.so (offset 0x5c8000) (RNWorklet::WorkletInvoker::call(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)+156) (BuildId: 304104e9d18a4e2082bff8f2739c5897781ec64a)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #35 pc 000000000007f5c8  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #36 pc 000000000007f1dc  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #37 pc 00000000000859a0  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #38 pc 00000000000965d0  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #39 pc 0000000000097dcc  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #40 pc 00000000000975d4  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #41 pc 0000000000085aac  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #42 pc 00000000000781d8  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libhermes.so (offset 0xd7c000) (BuildId: 57d1ab37bbe6071a5fa070afe9b90db66fc1b8a5)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #43 pc 000000000003d578  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libVisionCamera.so (offset 0x5c8000) (RNWorklet::JsiWorklet::call(std::__ndk1::shared_ptr<facebook::jsi::Function>, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)+332) (BuildId: 304104e9d18a4e2082bff8f2739c5897781ec64a)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #44 pc 000000000003ca80  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libVisionCamera.so (offset 0x5c8000) (RNWorklet::WorkletInvoker::call(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)+156) (BuildId: 304104e9d18a4e2082bff8f2739c5897781ec64a)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #45 pc 000000000003c188  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libVisionCamera.so (offset 0x5c8000) (vision::JFrameProcessor::callWithFrameHostObject(std::__ndk1::shared_ptr<vision::FrameHostObject> const&) const+296) (BuildId: 304104e9d18a4e2082bff8f2739c5897781ec64a)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #46 pc 000000000003c2f8  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libVisionCamera.so (offset 0x5c8000) (vision::JFrameProcessor::call(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<vision::JFrame, facebook::jni::JObject, void>::_javaobject*>)+104) (BuildId: 304104e9d18a4e2082bff8f2739c5897781ec64a)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #47 pc 000000000003e8a0  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libVisionCamera.so (offset 0x5c8000) (facebook::jni::detail::MethodWrapper<void (vision::JFrameProcessor::*)(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<vision::JFrame, facebook::jni::JObject, void>::_javaobject*>), &(vision::JFrameProcessor::call(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<vision::JFrame, facebook::jni::JObject, void>::_javaobject*>)), vision::JFrameProcessor, void, facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<vision::JFrame, facebook::jni::JObject, void>::_javaobject*> >::dispatch(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<vision::JFrameProcessor, facebook::jni::detail::BaseHybridClass>::JavaPart, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<vision::JFrame, facebook::jni::JObject, void>::_javaobject*>&&)+48) (BuildId: 304104e9d18a4e2082bff8f2739c5897781ec64a)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #48 pc 000000000003e808  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libVisionCamera.so (offset 0x5c8000) (facebook::jni::detail::FunctionWrapper<void (*)(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<vision::JFrameProcessor, facebook::jni::detail::BaseHybridClass>::JavaPart, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<vision::JFrame, facebook::jni::JObject, void>::_javaobject*>&&), facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<vision::JFrameProcessor, facebook::jni::detail::BaseHybridClass>::JavaPart, facebook::jni::JObject, void>::_javaobject*, void, facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<vision::JFrame, facebook::jni::JObject, void>::_javaobject*> >::call(_JNIEnv*, _jobject*, facebook::jni::detail::JTypeFor<vision::JFrame, facebook::jni::JObject, void>::_javaobject*, void (*)(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<vision::JFrameProcessor, facebook::jni::detail::BaseHybridClass>::JavaPart, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<vision::JFrame, facebook::jni::JObject, void>::_javaobject*>&&))+72) (BuildId: 304104e9d18a4e2082bff8f2739c5897781ec64a)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #49 pc 000000000003c4ec  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/base.apk!libVisionCamera.so (offset 0x5c8000) (facebook::jni::detail::MethodWrapper<void (vision::JFrameProcessor::*)(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<vision::JFrame, facebook::jni::JObject, void>::_javaobject*>), &(vision::JFrameProcessor::call(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<vision::JFrame, facebook::jni::JObject, void>::_javaobject*>)), vision::JFrameProcessor, void, facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<vision::JFrame, facebook::jni::JObject, void>::_javaobject*> >::call(_JNIEnv*, _jobject*, facebook::jni::detail::JTypeFor<vision::JFrame, facebook::jni::JObject, void>::_javaobject*)+36) (BuildId: 304104e9d18a4e2082bff8f2739c5897781ec64a)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #50 pc 00000000000b6068  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/oat/arm64/base.odex (art_jni_trampoline+104)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #51 pc 000000000058b1b0  /apex/com.android.art/lib64/libart.so (nterp_helper+4016) (BuildId: 4427adefbdfb23059a45e82bebdaa2dc)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #52 pc 0000000000a2eacc  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/oat/arm64/base.vdex (com.mrousavy.camera.react.CameraView.onFrame+28)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #53 pc 000000000058bf74  /apex/com.android.art/lib64/libart.so (nterp_helper+7540) (BuildId: 4427adefbdfb23059a45e82bebdaa2dc)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #54 pc 0000000000a1ffea  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/oat/arm64/base.vdex (com.mrousavy.camera.core.FrameProcessorPipeline.analyze+30)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #55 pc 000000000058bf74  /apex/com.android.art/lib64/libart.so (nterp_helper+7540) (BuildId: 4427adefbdfb23059a45e82bebdaa2dc)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #56 pc 00000000001d4900  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/oat/arm64/base.vdex (androidx.camera.core.ImageAnalysis.lambda$setAnalyzer$2+0)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #57 pc 000000000058a234  /apex/com.android.art/lib64/libart.so (nterp_helper+52) (BuildId: 4427adefbdfb23059a45e82bebdaa2dc)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #58 pc 00000000001d2a50  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/oat/arm64/base.vdex (androidx.camera.core.ImageAnalysis$$ExternalSyntheticLambda2.analyze+4)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #59 pc 000000000058bf74  /apex/com.android.art/lib64/libart.so (nterp_helper+7540) (BuildId: 4427adefbdfb23059a45e82bebdaa2dc)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #60 pc 00000000001d3a0c  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/oat/arm64/base.vdex (androidx.camera.core.ImageAnalysisAbstractAnalyzer.lambda$analyzeImage$0$androidx-camera-core-ImageAnalysisAbstractAnalyzer+92)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #61 pc 000000000058b858  /apex/com.android.art/lib64/libart.so (nterp_helper+5720) (BuildId: 4427adefbdfb23059a45e82bebdaa2dc)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #62 pc 00000000001d3528  /data/app/~~Q0rifGhDGc6FVZy1OoHqSQ==/com.mrousavy.camera.example-Bd0DONF5kmG4TxjM4piGeA==/oat/arm64/base.vdex (androidx.camera.core.ImageAnalysisAbstractAnalyzer$$ExternalSyntheticLambda1.run+28)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #63 pc 00000000005b59c4  /system/framework/arm64/boot-framework.oat (android.os.Handler.dispatchMessage+84) (BuildId: 717132b69f4131cb861e24bf3751350f14e2c4a8)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #64 pc 00000000005b9014  /system/framework/arm64/boot-framework.oat (android.os.Looper.loopOnce+1044) (BuildId: 717132b69f4131cb861e24bf3751350f14e2c4a8)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #65 pc 00000000005b8b60  /system/framework/arm64/boot-framework.oat (android.os.Looper.loop+560) (BuildId: 717132b69f4131cb861e24bf3751350f14e2c4a8)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #66 pc 00000000005b7cc4  /system/framework/arm64/boot-framework.oat (android.os.HandlerThread.run+580) (BuildId: 717132b69f4131cb861e24bf3751350f14e2c4a8)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #67 pc 000000000035b3a4  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+612) (BuildId: 4427adefbdfb23059a45e82bebdaa2dc)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #68 pc 000000000034be08  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+144) (BuildId: 4427adefbdfb23059a45e82bebdaa2dc)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #69 pc 00000000004f41a4  /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*)+1888) (BuildId: 4427adefbdfb23059a45e82bebdaa2dc)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #70 pc 00000000000f85d8  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208) (BuildId: b42b6c8e53a5088950b04ec1bf752d21)
2024-04-29 15:15:14.177 30007-30007 DEBUG                   crash_dump64                         A        #71 pc 00000000000950f0  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: b42b6c8e53a5088950b04ec1bf752d21)

Camera Device

{
                             "formats": [],
                             "hardwareLevel": "limited",
                             "hasFlash": true,
                             "hasTorch": true,
                             "id": "0",
                             "isMultiCam": false,
                             "maxExposure": 20,
                             "maxZoom": 8,
                             "minExposure": -30,
                             "minFocusDistance": 0,
                             "minZoom": 1,
                             "name": "0 (BACK) androidx.camera.camera2",
                             "neutralZoom": 1,
                             "physicalDevices": [
                             "wide-angle-camera"
                             ],
                             "position": "back",
                             "sensorOrientation": "landscape-left",
                             "supportsFocus": true,
                             "supportsLowLightBoost": false,
                             "supportsRawCapture": false
                             }

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

mrousavy commented 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.

mrousavy commented 2 weeks ago

Ah nevermind you just posted error messages this second lol

mrousavy commented 2 weeks ago

Just to clarify; this works fine in Debug, but fails in Release?

jodrescher commented 2 weeks ago

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.

mrousavy commented 2 weeks ago

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')?

mrousavy commented 2 weeks ago

And does this crash on iOS as well, or only Android?

luicfrr commented 2 weeks ago

@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.

jodrescher commented 2 weeks ago

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?

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.

mrousavy commented 2 weeks ago

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.

mrousavy commented 2 weeks ago

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

mrousavy commented 2 weeks ago

For me, runAsync runs perfectly fine now

jodrescher commented 1 week ago

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 ()
namnotfake commented 1 week ago

When i use runAsyn but is not use runAsync app crash. image

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

luicfrr commented 1 week ago

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.

mrousavy commented 1 week ago

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.

luicfrr commented 1 week ago

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

mrousavy commented 1 week ago

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.

mrousavy commented 1 week ago

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.

luicfrr commented 1 week ago

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.

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, 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.

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

mrousavy commented 1 week ago

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.

jodrescher commented 1 week ago

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.

ismaelsousa commented 6 days ago

When i use runAsyn but is not use runAsync app crash. image

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

bglgwyng commented 6 days ago

I got a tombstone for this. tombstone.zip

nmajumder12 commented 4 days ago

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