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

馃悰 After pauseRecording(), stopRecording() takes 4 seconds longer than if not paused #2732

Open
4 of 5 tasks
Mikewa33 opened this issue Apr 9, 2024 · 3 comments
Open
4 of 5 tasks
Labels
馃悰 bug Something isn't working

Comments

@Mikewa33
Copy link

Mikewa33 commented Apr 9, 2024

What's happening?

I logged every appendBuffer call at all if cases that are commented. While the video is recording we get a ton of

2024-04-09 16:05:17.089435-0400 Hetal[11959:1948327] [native] VisionCamera.appendBuffer(_:clock:type:): 3: Last Written Timestamp Buffer Optional(__C.CMTime(value: 204422346222041, timescale: 1000000000, flags: __C.CMTimeFlags(rawValue: 1), epoch: 0))

But our design calls for a pause function before saving. So we pause the video before calling stopRecording. When paused the buffer logs don't write cause the camera is paused. We have a button for the user to save and that calls stopRecording(). When that is called then these logs happen

2024-04-09 16:05:21.210329-0400 Hetal[11959:1948456] [native] VisionCamera.stop(clock:): Requesting stop at 204426.518807333 seconds for AssetWriter with status "writing"...
2024-04-09 16:05:25.410054-0400 Hetal[11959:1948327] [native] VisionCamera.stop(clock:): Waited 4.0 seconds but no late Frames came in, aborting capture...

On the react side the camera init looks like this

<Camera
       style={StyleSheet.absoluteFill}
       ref={cameraRef}
       device={device}
       isActive={true}
       format={format}
       video={true}
       fps={format.maxFps}
       enableZoomGesture={true}
     />

When the user pauses the recording we call
cameraRef.current.pauseRecording();

We then have buttons to save or retake the video. On save we call
cameraRef.current.stopRecording();

I think because it is in a pause state when we call stop no buffers are being called and that prevent finish() from happening as it normally would

Reproduceable Code

cameraRef.current.pauseRecording();
cameraRef.current.stopRecording();

Relevant log output

2024-04-09 16:05:17.089435-0400 Hetal[11959:1948327] [native] VisionCamera.appendBuffer(_:clock:type:): 3: Last Written Timestamp Buffer Optional(__C.CMTime(value: 204422346222041, timescale: 1000000000, flags: __C.CMTimeFlags(rawValue: 1), epoch: 0))
2024-04-09 16:05:21.210329-0400 Hetal[11959:1948456] [native] VisionCamera.stop(clock:): Requesting stop at 204426.518807333 seconds for AssetWriter with status "writing"...
2024-04-09 16:05:25.410054-0400 Hetal[11959:1948327] [native] VisionCamera.stop(clock:): Waited 4.0 seconds but no late Frames came in, aborting capture...

Camera Device

{
  "hardwareLevel": "full",
  "hasTorch": true,
  "formats": [],
  "isMultiCam": false,
  "sensorOrientation": "landscape-right",
  "maxExposure": 8,
  "supportsLowLightBoost": false,
  "minZoom": 1,
  "minExposure": -8,
  "hasFlash": true,
  "name": "Back Camera",
  "maxZoom": 123.75,
  "minFocusDistance": 10,
  "physicalDevices": [
    "wide-angle-camera"
  ],
  "supportsFocus": true,
  "supportsRawCapture": false,
  "neutralZoom": 1,
  "id": "com.apple.avfoundation.avcapturedevice.built-in_video:0",
  "position": "back"
}

Device

iPhone SE

VisionCamera Version

3.9.1

Can you reproduce this issue in the VisionCamera Example app?

No, I cannot reproduce the issue in the Example app

Additional information

@Mikewa33 Mikewa33 added the 馃悰 bug Something isn't working label Apr 9, 2024
@mrousavy mrousavy changed the title On iOS when camera goes from paused to stop the finish() call never happens with the buffer and the timeout error occurs馃悰 馃悰 After pauseRecording(), stopRecording() takes 4 seconds longer than if not paused Apr 22, 2024
@mrousavy
Copy link
Owner

yea, this is a bug.

@thanhtungkhtn
Copy link

Any update on this? facing similar issue

"react": "18.2.0",
"react-native": "0.74.1",
"react-native-vision-camera": "^4.0.3"

@mrousavy
Copy link
Owner

No update yet, if you want me to fix this for ya, contact me thru my agency or sponsor this issue.

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

3 participants