Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Memory leaks when calling JS functions from frame processor #1953

Closed
4 of 5 tasks
bglgwyng opened this issue Oct 8, 2023 · 7 comments
Closed
4 of 5 tasks

馃悰 Memory leaks when calling JS functions from frame processor #1953

bglgwyng opened this issue Oct 8, 2023 · 7 comments
Labels
馃悰 bug Something isn't working

Comments

@bglgwyng
Copy link
Sponsor Contributor

bglgwyng commented Oct 8, 2023

What's happening?

The function created by Worklets.createRunInJsFn causes memory leaks, and the app gets crashed eventually.
It seems that the arguments passed are not garbage collected properly. With arguments of large size, for example, the buffer of a cropped image, we can observe this behavior more easily.

I tested it also with the release build and observed the same.

I'm not sure if it is VisionCamera issue or react-native-worklets-core issue. As I don't know how to reproduce this behavior only with react-native-worklets-core, I'm posting it here.

Reproduceable Code

const send = useMemo(() => Worklets.createRunInJsFn((x: any) => {}), []);
const frameProcessor = useFrameProcessor(
  (frame) => {
    'worklet';

    // Increasing 10000 to a larger value shows faster memory usage growing
    send(Array(10000).fill(0));
  },
[send]);

Relevant log output

* thread #7, queue = 'mrousavy/VisionCamera.video', stop reason = EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded) (limit=2098 MB)
  * frame #0: 0x0000000102345a40 AwesomeProject`std::__1::__shared_weak_count::__shared_weak_count[abi:v160006](this=0x00000002cdfebff0, __refs=0) at shared_ptr.h:178:11
    frame #1: 0x00000001028d7764 AwesomeProject`std::__1::__shared_ptr_emplace<RNWorklet::JsiWrapper, std::__1::allocator<RNWorklet::JsiWrapper>>::__shared_ptr_emplace[abi:v160006]<facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWrapper*&>(this=0x00000002cdfebff0, __a=allocator<RNWorklet::JsiWrapper> @ 0x000000016e0b81cf, __args=0x000000028033a940, __args=0x000000016e0b8418, __args=0x000000016e0b83b0) at shared_ptr.h:274:14
    frame #2: 0x00000001028d7470 AwesomeProject`std::__1::__shared_ptr_emplace<RNWorklet::JsiWrapper, std::__1::allocator<RNWorklet::JsiWrapper>>::__shared_ptr_emplace[abi:v160006]<facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWrapper*&>(this=0x00000002cdfebff0, __a=allocator<RNWorklet::JsiWrapper> @ 0x000000016e0b820f, __args=0x000000028033a940, __args=0x000000016e0b8418, __args=0x000000016e0b83b0) at shared_ptr.h:276:5
    frame #3: 0x00000001028d7368 AwesomeProject`std::__1::shared_ptr<RNWorklet::JsiWrapper> std::__1::allocate_shared[abi:v160006]<RNWorklet::JsiWrapper, std::__1::allocator<RNWorklet::JsiWrapper>, facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWrapper*&, void>(__a=0x000000016e0b82cf, __args=0x000000028033a940, __args=0x000000016e0b8418, __args=0x000000016e0b83b0) at shared_ptr.h:995:55
    frame #4: 0x00000001028d63a8 AwesomeProject`std::__1::shared_ptr<RNWorklet::JsiWrapper> std::__1::make_shared[abi:v160006]<RNWorklet::JsiWrapper, facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWrapper*&, void>(__args=0x000000028033a940, __args=0x000000016e0b8418, __args=0x000000016e0b83b0) at shared_ptr.h:1004:12
    frame #5: 0x00000001028d6094 AwesomeProject`RNWorklet::JsiWrapper::wrap(runtime=0x000000028033a940, value=0x000000016e0b8418, parent=0x00000002801d6f58) at WKTJsiWrapper.cpp:36:14
    frame #6: 0x00000001028d9c18 AwesomeProject`RNWorklet::JsiArrayWrapper::setValue(this=0x00000002801d6f58, runtime=0x000000028033a940, value=0x000000016e0b8d18) at WKTJsiArrayWrapper.h:324:11
    frame #7: 0x00000001028d62f0 AwesomeProject`RNWorklet::JsiWrapper::wrap(runtime=0x000000028033a940, value=0x000000016e0b8d18, parent=0x0000000000000000) at WKTJsiWrapper.cpp:54:11
    frame #8: 0x00000001027be714 AwesomeProject`RNWorklet::JsiWrapper::wrap(runtime=0x000000028033a940, value=0x000000016e0b8d18) at WKTJsiWrapper.h:62:12
    frame #9: 0x00000001028a4ec8 AwesomeProject`RNWorklet::ArgumentsWrapper::ArgumentsWrapper(this=0x000000016e0b88a8, runtime=0x000000028033a940, arguments=0x000000016e0b8d18, count=1) at WKTArgumentsWrapper.h:19:23
    frame #10: 0x00000001028a4d34 AwesomeProject`RNWorklet::ArgumentsWrapper::ArgumentsWrapper(this=0x000000016e0b88a8, runtime=0x000000028033a940, arguments=0x000000016e0b8d18, count=1) at WKTArgumentsWrapper.h:16:23
    frame #11: 0x00000001028b7a78 AwesomeProject`RNWorklet::JsiWorkletContext::createCallInContext(facebook::jsi::Runtime&, facebook::jsi::Value const&, RNWorklet::JsiWorkletContext*)::$_5::operator()(this=0x0000000283a07728, runtime=0x000000028033a940, thisValue=0x000000016e0b8c98, arguments=0x000000016e0b8d18, count=1) const at WKTJsiWorkletContext.cpp:215:22
    frame #12: 0x00000001028b79ec AwesomeProject`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:v160006]<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>(__f=0x0000000283a07728, __args=0x000000028033a940, __args=0x000000016e0b8c98, __args=0x000000016e0b8ad8, __args=0x000000016e0b8ad0) at invoke.h:394:23
    frame #13: 0x00000001028b7974 AwesomeProject`facebook::jsi::Value std::__1::__invoke_void_return_wrapper<facebook::jsi::Value, false>::__call<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>(__args=0x0000000283a07728, __args=0x000000028033a940, __args=0x000000016e0b8c98, __args=0x000000016e0b8ad8, __args=0x000000016e0b8ad0) at invoke.h:478:16
    frame #14: 0x00000001028b7928 AwesomeProject`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:v160006](this=0x0000000283a07728, __arg=0x000000028033a940, __arg=0x000000016e0b8c98, __arg=0x000000016e0b8ad8, __arg=0x000000016e0b8ad0) at function.h:185:16
    frame #15: 0x00000001028b6698 AwesomeProject`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()(this=0x0000000283a07720, __arg=0x000000028033a940, __arg=0x000000016e0b8c98, __arg=0x000000016e0b8ad8, __arg=0x000000016e0b8ad0) at function.h:356:12
    frame #16: 0x0000000102682bc8 AwesomeProject`std::__1::__function::__value_func<facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>::operator()[abi:v160006](this=0x0000000283a076f8, __args=0x000000028033a940, __args=0x000000016e0b8c98, __args=0x000000016e0b8ad8, __args=0x000000016e0b8ad0) const at function.h:510:16
    frame #17: 0x0000000102682b34 AwesomeProject`std::__1::function<facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>::operator()(this=0x0000000283a076f8, __arg=0x000000028033a940, __arg=0x000000016e0b8c98, __arg=0x000000016e0b8d18, __arg=1) const at function.h:1156:12
    frame #18: 0x0000000102894d08 AwesomeProject`RNWorklet::JsiWorkletApi::createRunInJsFn(this=0x0000000283a076f8, runtime=0x000000028033a940, thisValue=0x000000016e0b8c98, arguments=0x000000016e0b8d18, count=1)::'lambda'(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) const at WKTJsiWorkletApi.h:90:18
    frame #19: 0x0000000102894cbc AwesomeProject`decltype(std::declval<RNWorklet::JsiWorkletApi::createRunInJsFn(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)&>()(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:v160006]<RNWorklet::JsiWorkletApi::createRunInJsFn(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long>(__f=0x0000000283a076f8, __args=0x000000028033a940, __args=0x000000016e0b8c98, __args=0x000000016e0b8da0, __args=0x000000016e0b8d98) at invoke.h:394:23
    frame #20: 0x0000000102894c44 AwesomeProject`facebook::jsi::Value std::__1::__invoke_void_return_wrapper<facebook::jsi::Value, false>::__call<RNWorklet::JsiWorkletApi::createRunInJsFn(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long>(__args=0x0000000283a076f8, __args=0x000000028033a940, __args=0x000000016e0b8c98, __args=0x000000016e0b8da0, __args=0x000000016e0b8d98) at invoke.h:478:16
    frame #21: 0x0000000102894bf8 AwesomeProject`std::__1::__function::__alloc_func<RNWorklet::JsiWorkletApi::createRunInJsFn(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long), std::__1::allocator<RNWorklet::JsiWorkletApi::createRunInJsFn(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>, facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>::operator()[abi:v160006](this=0x0000000283a076f8, __arg=0x000000028033a940, __arg=0x000000016e0b8c98, __arg=0x000000016e0b8da0, __arg=0x000000016e0b8d98) at function.h:185:16
    frame #22: 0x00000001028939a8 AwesomeProject`std::__1::__function::__func<RNWorklet::JsiWorkletApi::createRunInJsFn(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long), std::__1::allocator<RNWorklet::JsiWorkletApi::createRunInJsFn(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>, facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>::operator()(this=0x0000000283a076f0, __arg=0x000000028033a940, __arg=0x000000016e0b8c98, __arg=0x000000016e0b8da0, __arg=0x000000016e0b8d98) at function.h:356:12
    frame #23: 0x0000000105995480 hermes`___lldb_unnamed_symbol838 + 524
    frame #24: 0x00000001059a8d70 hermes`___lldb_unnamed_symbol1219 + 156
    frame #25: 0x00000001059c7da8 hermes`___lldb_unnamed_symbol1739 + 2752
    frame #26: 0x00000001059c72b4 hermes`___lldb_unnamed_symbol1738 + 132
    frame #27: 0x00000001059a9018 hermes`___lldb_unnamed_symbol1225 + 40
    frame #28: 0x000000010598ddd4 hermes`___lldb_unnamed_symbol680 + 600
    frame #29: 0x00000001027892cc AwesomeProject`facebook::jsi::Function::callWithThis(this=0x00000002835fc538, runtime=0x000000028033a940, jsThis=0x0000000283608580, args=0x000000016e0b97f8, count=1) const at jsi-inl.h:280:18
    frame #30: 0x00000001027869e4 AwesomeProject`RNWorklet::JsiWorklet::call(this=0x0000000280f54eb8, workletFunction=std::__1::shared_ptr<facebook::jsi::Function>::element_type @ 0x00000002835fc538 strong=2 weak=1, runtime=0x000000028033a940, thisValue=0x000000016e0b9778, arguments=0x000000016e0b97f8, count=1) at WKTJsiWorklet.h:218:31
    frame #31: 0x0000000102785ed0 AwesomeProject`RNWorklet::WorkletInvoker::call(this=0x000000028177a1d8, runtime=0x000000028033a940, thisValue=0x000000016e0b9778, arguments=0x000000016e0b97f8, count=1) at WKTJsiWorklet.h:389:22
    frame #32: 0x00000001028ec83c AwesomeProject`RNWorklet::JsiObjectWrapper::setFunctionValue(this=0x0000000283a076c8, runtime=0x000000028033a940, thisValue=0x000000016e0b9778, arguments=0x000000016e0b97f8, count=1)::'lambda'(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) const at WKTJsiObjectWrapper.h:202:36
    frame #33: 0x00000001028ec7e8 AwesomeProject`decltype(std::declval<RNWorklet::JsiObjectWrapper::setFunctionValue(facebook::jsi::Runtime&, facebook::jsi::Value const&)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)&>()(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:v160006]<RNWorklet::JsiObjectWrapper::setFunctionValue(facebook::jsi::Runtime&, facebook::jsi::Value const&)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long>(__f=0x0000000283a076c8, __args=0x000000028033a940, __args=0x000000016e0b9778, __args=0x000000016e0b9880, __args=0x000000016e0b9878) at invoke.h:394:23
    frame #34: 0x00000001028ec770 AwesomeProject`facebook::jsi::Value std::__1::__invoke_void_return_wrapper<facebook::jsi::Value, false>::__call<RNWorklet::JsiObjectWrapper::setFunctionValue(facebook::jsi::Runtime&, facebook::jsi::Value const&)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)&, facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long>(__args=0x0000000283a076c8, __args=0x000000028033a940, __args=0x000000016e0b9778, __args=0x000000016e0b9880, __args=0x000000016e0b9878) at invoke.h:478:16
    frame #35: 0x00000001028ec724 AwesomeProject`std::__1::__function::__alloc_func<RNWorklet::JsiObjectWrapper::setFunctionValue(facebook::jsi::Runtime&, facebook::jsi::Value const&)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long), std::__1::allocator<RNWorklet::JsiObjectWrapper::setFunctionValue(facebook::jsi::Runtime&, facebook::jsi::Value const&)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>, facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>::operator()[abi:v160006](this=0x0000000283a076c8, __arg=0x000000028033a940, __arg=0x000000016e0b9778, __arg=0x000000016e0b9880, __arg=0x000000016e0b9878) at function.h:185:16
    frame #36: 0x00000001028eb39c AwesomeProject`std::__1::__function::__func<RNWorklet::JsiObjectWrapper::setFunctionValue(facebook::jsi::Runtime&, facebook::jsi::Value const&)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long), std::__1::allocator<RNWorklet::JsiObjectWrapper::setFunctionValue(facebook::jsi::Runtime&, facebook::jsi::Value const&)::'lambda'(facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>, facebook::jsi::Value (facebook::jsi::Runtime&, facebook::jsi::Value const&, facebook::jsi::Value const*, unsigned long)>::operator()(this=0x0000000283a076c0, __arg=0x000000028033a940, __arg=0x000000016e0b9778, __arg=0x000000016e0b9880, __arg=0x000000016e0b9878) at function.h:356:12
    frame #37: 0x0000000105995480 hermes`___lldb_unnamed_symbol838 + 524
    frame #38: 0x00000001059a8d70 hermes`___lldb_unnamed_symbol1219 + 156
    frame #39: 0x00000001059c7da8 hermes`___lldb_unnamed_symbol1739 + 2752
    frame #40: 0x00000001059c72b4 hermes`___lldb_unnamed_symbol1738 + 132
    frame #41: 0x00000001059a9018 hermes`___lldb_unnamed_symbol1225 + 40
    frame #42: 0x000000010598ddd4 hermes`___lldb_unnamed_symbol680 + 600
    frame #43: 0x00000001027892cc AwesomeProject`facebook::jsi::Function::callWithThis(this=0x00000002835fc658, runtime=0x000000028033a940, jsThis=0x0000000283608300, args=0x000000016e0ba150, count=1) const at jsi-inl.h:280:18
    frame #44: 0x00000001027869e4 AwesomeProject`RNWorklet::JsiWorklet::call(this=0x0000000280f56308, workletFunction=std::__1::shared_ptr<facebook::jsi::Function>::element_type @ 0x00000002835fc658 strong=2 weak=1, runtime=0x000000028033a940, thisValue=0x000000016e0ba130, arguments=0x000000016e0ba150, count=1) at WKTJsiWorklet.h:218:31
    frame #45: 0x0000000102785ed0 AwesomeProject`RNWorklet::WorkletInvoker::call(this=0x0000000281715cd8, runtime=0x000000028033a940, thisValue=0x000000016e0ba130, arguments=0x000000016e0ba150, count=1) at WKTJsiWorklet.h:389:22
    frame #46: 0x0000000102785a34 AwesomeProject`-[FrameProcessor callWithFrameHostObject:](self=0x0000000283a166d0, _cmd=<no summary available>, frameHostObject=<unavailable>) at FrameProcessor.mm:43:22
    frame #47: 0x0000000102785fe4 AwesomeProject`-[FrameProcessor call:](self=<no summary available>, _cmd=<no summary available>, frame=<no summary available>) at FrameProcessor.mm:58:3
    frame #48: 0x00000001027f7078 AwesomeProject`CameraView.captureOutput(captureOutput=<no summary available>, sampleBuffer=<unavailable>, _2=<no summary available>, self=<no summary available>) at CameraView+RecordVideo.swift:208:26
    frame #49: 0x00000001027f7c08 AwesomeProject`@objc CameraView.captureOutput(_:didOutput:from:) at <compiler-generated>:0
    frame #50: 0x00000001a4c4a63c AVFCapture`-[AVCaptureVideoDataOutput _processSampleBuffer:] + 244
    frame #51: 0x00000001a4c4a508 AVFCapture`__47-[AVCaptureVideoDataOutput _updateRemoteQueue:]_block_invoke + 88
    frame #52: 0x00000001a7df7608 CMCapture`__FigRemoteOperationReceiverCreateMessageReceiver_block_invoke + 308
    frame #53: 0x00000001a7fc2728 CMCapture`__rqReceiverSetSource_block_invoke + 256
    frame #54: 0x00000001924f3eac libdispatch.dylib`_dispatch_client_callout + 20
    frame #55: 0x00000001924f7330 libdispatch.dylib`_dispatch_continuation_pop + 504
    frame #56: 0x000000019250a908 libdispatch.dylib`_dispatch_source_invoke + 1588
    frame #57: 0x00000001924fb40c libdispatch.dylib`_dispatch_lane_serial_drain + 372
    frame #58: 0x00000001924fc0a4 libdispatch.dylib`_dispatch_lane_invoke + 384
    frame #59: 0x0000000192506cdc libdispatch.dylib`_dispatch_workloop_worker_thread + 648
    frame #60: 0x00000001eae5dddc libsystem_pthread.dylib`_pthread_wqthread + 288

Camera Device

{
  "hardwareLevel": "full",
  "id": "com.apple.avfoundation.avcapturedevice.built-in_video:0",
  "sensorOrientation": "portrait",
  "minZoom": 1,
  "isMultiCam": false,
  "maxZoom": 121.875,
  "hasTorch": true,
  "hasFlash": true,
  "name": "Back Camera",
  "supportsLowLightBoost": false,
  "neutralZoom": 1,
  "physicalDevices": [
    "wide-angle-camera"
  ],
  "supportsRawCapture": false,
  "supportsFocus": true,
  "position": "back"
}

Device

iPhone 13, iOS 16.6.1

VisionCamera Version

3.2.2

Can you reproduce this issue in the VisionCamera Example app?

Yes, I can reproduce the same issue in the Example app here

Additional information

@bglgwyng bglgwyng added the 馃悰 bug Something isn't working label Oct 8, 2023
@bglgwyng bglgwyng changed the title 馃悰 Memory leaks when calling runInJs functions from frame processor 馃悰 Memory leaks when calling JS functions from frame processor Oct 8, 2023
@mrousavy
Copy link
Owner

Interesting, nice catch! We'll try to fix that in RN Worklets soon!

@chrfalch
Copy link
Contributor

chrfalch commented Oct 23, 2023

The problem here is that when we allocate data in a JSI object there is no information available for the Hermes garbage collector about the inner allocation - read more here: facebook/hermes#982

I'm unsure how this will be / can be fixed when using Hermes (JSC handles this a bit differently) to be honest.

馃煩馃煩馃煩馃煩馃煩馃煩馃煩馃煩 (馃)

@chrfalch
Copy link
Contributor

chrfalch commented Oct 23, 2023

馃コ After some thinking I believe I麓ve found a solution and a way forward. Thanks for reporting this @bglgwyng

@induRaju
Copy link

@chrfalch - I am also facing the same issue, If you could explain about your fix it would be really helpful.

@mrousavy
Copy link
Owner

according to @bglgwyng this is still a problem. reopening for now (cc @chrfalch )

@mrousavy
Copy link
Owner

mrousavy commented Apr 3, 2024

Maybe related: margelo/react-native-worklets-core#154

@mrousavy
Copy link
Owner

Hey - I think this issue has been fixed in VisionCamera 4.0.0. 馃コ

Please try V4 and let me know if you still experience this issue;

  • if not, please consider 馃挅 sponsoring me on GitHub 馃挅 to support the development of VisionCamera and thank me for my time spent on fixing bugs and building new features.
  • if you still see this issue, please comment and we can re-open this. But please update your native logs with the native (Xcode/Android Studio) logs from running VisionCamera V4 so I can investigate this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
馃悰 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants