-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 V3 runAsync doesn't work #1791
🐛 V3 runAsync doesn't work #1791
Comments
@manolo-battista did you find any solution for this ? |
no, unfortunately I still didn't find any solution. For my projects at the moment I'm using
|
Hi. Would've been great if you could've sent a PR for that to fix it in docs. But in my tests, Can you reproduce it in the example app? |
hey @mrousavy i think we should keep this issue open, i'm facing the same issue since this function was released, can you provide a minimal example that's working for you? |
some weirdness scope things happening UseCase1:
const frameProcessor = useFrameProcessor(
(frame) => {
"worklet";
runAsync(frame, () => {
"worklet";
console.log("my awesome log");
});
},
[]
);
UseCase2:do not throws anything on const myFn = (frameContext) => {
"worklet";
console.log("Here", frameContext);
};
const frameProcessor = useFrameProcessor(
(frame) => {
"worklet";
runAsync(frame, myFn);
},
[myFn]
);
|
Oh! Hm that's weird, I remember this worked when I built it. @chrfalch do you maybe have any insights? |
oh wait it seems that by design the frame it's not being passed to react-native-vision-camera/package/src/FrameProcessorPlugins.ts Lines 50 to 55 in 764897d
|
Wait what? not sure if I follow -
no you're right, you can just use the Frame inside your lambda directly, the lambda has no parameters.
Why not? It runs in |
@mrousavy yep you are totally right, i was very drunk that day sorry found a pattern that doesn't make sense for me, |
i have a serie of frame processors at this moment running in sequence something like this const frameProcessor = (frame) => {
'worklet';
// processors
const faces = faceDetectorProcessor(frame)
const luminanceResults = luminanceDetectionProcessor(frame, faces)
const spoofResults = antiSpoofingProcessor(frame);
// callbacks
handleSpoofingDetection(spoofResults)
handleLuminanceDetection(luminanceResults)
},[handleSpoofingDetection, handleLuminanceDetection]) the problem is that at this point the frame are being deallocated before i finish my operations, const frameProcessor = (frame) => {
'worklet';
// just drop the frame
if(!jsiUtil.finishedOperations) return;
const frameCopy = jsiUtil.copyFrame(frame);
// processors
const faces = faceDetectorProcessor(frameCopy)
const luminanceResults = luminanceDetectionProcessor(frameCopy, faces)
const spoofResults = antiSpoofingProcessor(frameCopy);
// cleanup frame copy
jsiUtil.ReleaseFrameCopy()
// callbacks
handleSpoofingDetection(spoofResults)
handleLuminanceDetection(luminanceResults)
},[handleSpoofingDetection, handleLuminanceDetection]) would be nice to hear your opinion on this temporary solution to make sure i'm not missing anything some final notes: i'm linking my lib with |
Woah, that's a weird error. Can you add This is weird and you shouldn't need such workarounds - it should just work magically with ref counting. |
i still couldn't figure out what's happening, i'll try to upload something reproducible |
Haaa I found out, i have a monorepo with this structure -- packages if i have reanimated in my lib i face this issue, removed reanimated from mylib and now i'm using it only in the playground, working like a charm Edit1: if i try a simple useFrameProcessor(frame => .....
runAsync(frame, () => {
'worklet'
console.log('hello from runAsync')
})
},[]) if i try to use any function inside of it, it crashes exactly with same error as before const myFunc = () => {
'worklet'
console.log('hello from runAsync')
}
useFrameProcessor(frame => .....
runAsync(frame, () => {
'worklet'
myFunc();
})
},[myFunc])
|
@mrousavy fyi it's reproducible on example app now |
Wait so Reanimated makes it break? Yea it's a bit weird that Worklets and reanimated do the same thing... Maybe we can fix this compatibility for now and think about a better solution in the future. |
that's what i thought because after removing reanimated i can do a |
Similar issue here. Using
Running the same exact same code using I'm not using Reanimated in my project. |
Btw.; here's an explanation and a fix: margelo/react-native-worklets-core#136 |
This is not related to VisionCamera, but rather about Reanimated. If you do not use Reanimated, |
Enabling This is my code (from react-native-fast-tflite), note that the model is printed out, but then it shows the error, I'm trying to make the model not interfere with how the camera output is displayed in my app (it interferes on Android but not iOS):
If I pass the frame into runAsync, I get this error: Not sure if I'm misunderstanding some fundamentals here.
|
ArrayBuffers can't be shared (right @chrfalch?), do the resize also in runAsynx. |
Correct. |
Sorry, I meant that I passed the |
Yeah - try to move the resize call also into runAsync. |
I did that, and I get this error: When I use this code:
Edit: If I have both resize outside and inside runAsync, it just crashes with no symbolic stack trace:
|
that so weird, same problem here |
From reading the error message, it looks like the reason the JNI class cannot be found in Is that not called when invoking a worklet from JS, @chrfalch ? |
Hey @rodgomesc and @Cosmorider - a discord user posted a SIGABRT stacktrace with symbols attached so I was able to figure out that this came from |
I'm not seeing the same error. I have this one when using runAsync:
The new PR does not fix this particular one. |
@MSchmidt can you try to add a facebook::jni::ThreadScope scope; right at the top of this method: Lines 35 to 45 in 02bc8a9
? Let me know if that works for you |
A second idea would be that I am using react-native-vision-camera/package/android/src/main/cpp/frameprocessor/JSIJNIConversion.cpp Lines 155 to 166 in 02bc8a9
..maybe you are using an older version of fbjni where the map iterator part doesn't exist yet, hence it cannot find |
It's the same as this one: #1791 (comment) It's somehow related to reanimated still. Their plugin does something different from vision camera's. It works when reanimated is thrown out of the project. Which isn't an option though. |
Yea I still need a symbolicated stacktrace. The error linked above just tells me that something inside the Frame Processor crashed, but I need the native C++ stacktrace. Also the guy (@gbark) said he is not using Reanimated in his project, which makes me doubt that this is something coming from reanimated. |
Okay nevermind - I was able to reproduce this 💪 - this fixes the issue: margelo/react-native-worklets-core#141 🎉 |
Fixed in react-native-worklets-core 0.3.0 🎉🥳 |
I tried to fix it but it didn't work |
@mrousavy do you think it would be a good idea to include the worklet config param |
What's happening?
On docs is described:
But I think it needs update, cause request
frame
as first parameter andfunc (callback)
as second parameter.The callback function is never called. I saw that code reach the func on
runOnAsyncContext
function, but I think enter always onfinally
cause I can't see my logok 2
.Reproduceable Code
No response
Relevant log output
No response
Camera Device
No response
Device
iPhone 14 Pro
VisionCamera Version
3.0.0
Can you reproduce this issue in the VisionCamera Example app?
Additional information
The text was updated successfully, but these errors were encountered: