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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Example app broken when switching devices #834

Closed
3 of 4 tasks
AdamTyler opened this issue Feb 17, 2022 · 11 comments · Fixed by #1466
Closed
3 of 4 tasks

🐛 Example app broken when switching devices #834

AdamTyler opened this issue Feb 17, 2022 · 11 comments · Fixed by #1466
Labels
🐛 bug Something isn't working

Comments

@AdamTyler
Copy link

What were you trying to do?

Switch devices while recording. Is this a supported feature?

Its not working in my own app so I tried to reproduce in example app and see the same issue.

Reproduceable Code

Example app. bootstrapped and running android.

What happened instead?

Upon flipping the camera device between front or back when recording (double tap on the screen), an error message comes up and the recording will not finish properly

Relevant log output

LOG  Re-rendering Navigator. Camera: authorized | Microphone: authorized
 LOG  re-rendering camera page without active camera
 LOG  re-rendering camera page without active camera
 LOG  Re-rendering camera page with active camera. Device: "back (0)" (4032x1816 @ 30fps)
 LOG  Camera initialized!
 LOG  Re-rendering camera page with active camera. Device: "back (0)" (4032x1816 @ 30fps)
 DEBUG  state: BEGAN
 LOG  calling startRecording()...
 LOG  called startRecording()!
 LOG  Re-rendering camera page with active camera. Device: "front (1)" (3648x1640 @ 30fps)
 ERROR  [device/invalid-device: [device/invalid-device] The given Camera device could not be found for use-case binding!]
 ERROR  Recording failed! {"cause": {"message": "[capture/inactive-source] The recording failed because the source becomes inactive and stops sending frames.
One case is that if camera is closed due to lifecycle stopped, the active recording will be finalized with this error, and the output will be generated, containing the frames produced before camera closing. Attempting to start a new recording will be finalized immediately if the source remains inactive and no output will be generated.", "stacktrace": "com.mrousavy.camera.InactiveSourceError: [capture/inactive-source] The recording failed because the source becomes inactive and stops sending frames.
One case is that if camera is closed due to lifecycle stopped, the active recording will be finalized with this error, and the output will be generated, containing the frames produced before camera closing. Attempting to start a new recording will be finalized immediately if the source remains inactive and no output will be generated.
	at com.mrousavy.camera.CameraView_RecordVideoKt$startRecording$1.accept(CameraView+RecordVideo.kt:64)
	at com.mrousavy.camera.CameraView_RecordVideoKt$startRecording$1.accept(CameraView+RecordVideo.kt:52)
	at androidx.camera.video.Recorder$RecordingRecord.lambda$updateVideoRecordEvent$6$Recorder$RecordingRecord(Recorder.java:2611)
	at androidx.camera.video.-$$Lambda$Recorder$RecordingRecord$Uo40MCKPuma4aZ5df1-_fzufzHg.run(Unknown Source:4)
	at android.os.Handler.handleCallback(Handler.java:938)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loopOnce(Looper.java:226)
	at android.os.Looper.loop(Looper.java:313)
	at android.app.ActivityThread.main(ActivityThread.java:8641)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1133)
"}, "code": "capture/inactive-source", "message": "[capture/inactive-source] The recording failed because the source becomes inactive and stops sending frames.
One case is that if camera is closed due to lifecycle stopped, the active recording will be finalized with this error, and the output will be generated, containing the frames produced before camera closing. Attempting to start a new recording will be finalized immediately if the source remains inactive and no output will be generated.", "userInfo": null}
 LOG  stopped recording video!
 DEBUG  state: ACTIVE
 DEBUG  state: END
 LOG  calling stopRecording()...
 LOG  called stopRecording()!

Device

Samsung Galaxy S20+

VisionCamera Version

2.12.0

Additional information

@AdamTyler AdamTyler added the 🐛 bug Something isn't working label Feb 17, 2022
@mrousavy
Copy link
Owner

Hey, thanks for the bug report! I think on iOS this works, but on Android it does not work because the native camera library (CameraX) does not support this. I have created an issue in their issuetracker, no response yet.

@AdamTyler
Copy link
Author

@mrousavy thanks for the quick response!
I went ahead and verified that it does work on iOS which is awesome.
One thing I do notice though is a quick flash of the wrong orientation stretched to fit when switching between them that shows up in the final recording.

Hopefully CameraX can add support soon!

@AdamTyler
Copy link
Author

@mrousavy here is an example of how it’s recording

IMG_0002.MOV

@mrousavy
Copy link
Owner

Interesting! This might be a bug due to the orientation change I have added?

@usaidather
Copy link

@mrousavy any update on this issue ? because I am also facing the same issue.

@rogeriocassares

This comment was marked as spam.

@Aakash359
Copy link

The recording failed because the source becomes inactive and stops sending frames. One case is that if camera is closed due to lifecycle stopped, the active recording will be finalized with this error, and the output will be generated, containing the frames produced before camera closing. Attempting to start a new recording will be finalized immediately if the source remains inactive and no output will be generated...... gtting error in android, this is perfectly working in iOS but not in android can any tell me what the issues is there

@showtan001

This comment was marked as spam.

@zzzkasper-1995
Copy link

@AdamTyler I have same issue with stretch and orientation

@ratz6
Copy link

ratz6 commented Apr 15, 2023

Any fix for the Video being stretched while switching cameras on iOS ?

@mrousavy
Copy link
Owner

Hey! I've rewritten the entire Android codebase of VisionCamera from CameraX to Camera2 in the efforts of ✨ VisionCamera V3.

I just now completed the Camera2 rewrite and I believe the core structure is running, but there might be some edge cases to iron out. Can you try and test the PR #1674 for me to see if you can still reproduce this issue here?

Here's an instruction on how you can test that: #1674 (comment)

If the issue cannot be reproduced with that version/PR anymore, then hoorayy, I fixed it! 🎉
Otherwise please let me know and I'll keep this issue open to keep track of it.

Thank you!

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

Successfully merging a pull request may close this issue.

8 participants