Closed santiagofm closed 1 week ago
While debugging I came accross the bindToLifecycle
doc that clearly states:
...
Currently up to 3 use cases may be bound to a Lifecycle at any time. Exceeding capability of target camera device will throw an IllegalArgumentException.
...
So this issue seems to be an api limitation?
I can consistently repro this when I ahve more than 3 "video outputs" enabled at the same time(preview, photo, codescanner, frame processors) and it works fine when I remove any of them.
Can you try setting qualityPrioritization="speed"
?
I built VisionCamera to not have that limitation (that was a huge issue in native Camera APIs, so it's hard to work around this issue)
Can you try setting
qualityPrioritization="speed"
?I built VisionCamera to not have that limitation (that was a huge issue in native Camera APIs, so it's hard to work around this issue)
I guess you meant photoQualityBalance
but yeah, same result.
Isn't it a limitation on the camera api itself?
...
Currently up to 3 use cases may be bound to a Lifecycle at any time. Exceeding capability of target camera device will throw an IllegalArgumentException.
...
@mrousavy Sorry if I'm missing something implementation wise, but it seems like we are assuming all devices will support binding any number of use casesβ or at least that the camera api will disregard if not supported. Which doesn't seem to be the case and the camera API will just throw an exception.
Seems like we should be using the hardware_level
of the device to determine the number of use cases that are supported? Not sure how the one thing translates to the other though.
I will try to fold the code scanner into my custom frame processor to reduce the number of use cases and workaround this. We cannot use multiple Camera
components at the same time right? Even if one of them has the preview disabled?
but it seems like we are assuming all devices will support binding any number of use cases
No;
but it seems like we are assuming all devices will support binding any number of use cases
No;
- On iOS, I am explicitly checking if this is supported and Frame Processors and Video Capture have been carefully put together into a single video stream
- On Android, CameraX already uses a similar feature under the hood called "stream sharing". So you could use any number of outputs here, although that feature is still in beta.
Aha! Sorry, I didn't know that was a thing on Android(iOS works perfectly btw); unfortunately it doesn't seem to work as we would want it to :/
Hey - just created a PR to maybe fix this - can you test if that works for you? https://github.com/mrousavy/react-native-vision-camera/pull/2897 π
Hey - just created a PR to maybe fix this - can you test if that works for you? #2897 π
Will test it later today ππ» !
I ended up implementing the barcode recognizer with mlkit on a frame processor to reduce the number of outputs btw, that seems to work fine.
Hey - just created a PR to maybe fix this - can you test if that works for you? #2897 π
Hey! I just tested on a Xiaomi Redmi 13C and it's still throwing the error. I'm using 4 video outputs: preview, take photo programatically, built-in code scanner, frame processors.
Well then that means that the StreamSharing feature is not working properly on that specific phone.
We'd need to report that bug to Google/CameraX. I don't have the time to do that right now, so I'd really appreciate it if you took the time to do that (I mean it's also in your interest to get that fixed)
What's happening?
When I try to use more than 3 camera outputs on Android it throws an exception:
I'm using the example app code for the code scanner use case and adding a few more "video outputs" for running a frame processor & being able to take photos programatically.
I need to be able to run 4 "video ouputs" at the same time: preview the camera, take photos programatically, scan codes using the built-in code-scanner & run a frame processor:
Reproduceable Code
Relevant log output
Camera Device
Device
Pixel 6 API 30 emulator, also repo on real Xiaomi Redmi 13C
VisionCamera Version
main branch
Can you reproduce this issue in the VisionCamera Example app?
Yes, I can reproduce the same issue in the Example app here
Additional information