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

馃悰 finally on a Promise stops camera on Android #2895

Closed
5 tasks done
bglgwyng opened this issue May 21, 2024 · 3 comments
Closed
5 tasks done

馃悰 finally on a Promise stops camera on Android #2895

bglgwyng opened this issue May 21, 2024 · 3 comments
Labels
馃悰 bug Something isn't working

Comments

@bglgwyng
Copy link
Sponsor Contributor

What's happening?

The following reproducible example causes the camera to stop.
It only happens when you attach a finally chain to a Promise, not then or catch.

The real-world example includes the usage of await for run-on-JS function return.
Also this problem only exists on Android.

I used react-native-worklets-core 1.3.3.

Reproduceable Code

const frameProcessor = useFrameProcessor(
  (frame) => {
    "worklet";
    Promise.resolve().finally(() => {});
    Promise.resolve().then(() => {}); // it's ok
    Promise.resolve().catch(() => {}); // it's ok
  },
[])

Relevant log output

no relevant log output

Camera Device

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

Device

iPhone 13 (iOS 17.5)

VisionCamera Version

4.0.4

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 May 21, 2024
@mrousavy
Copy link
Owner

This is an issue with Worklets. Please create an issue in react-native-worklets-core.

@mrousavy mrousavy closed this as not planned Won't fix, can't repro, duplicate, stale May 21, 2024
@bglgwyng
Copy link
Sponsor Contributor Author

@mrousavy I tried to reproduce the behavior with react-native-worklets-core only but nothing happened.

Worklets.defaultContext
  .runAsync(() => {
    'worklet'
    Promise.resolve().finally(() => {})
  })

The behavior of VisionCamera with finally is stopping the camera preview.
Which behavior do you expect from this code?

@mrousavy
Copy link
Owner

We also saw a similar issue on a separate Worklet context (in our upcoming 3d library), so this is def. an issue with Worklets, just maybe not the defaultContext. Try to create a new separate context.

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

2 participants