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

🐛 Android: Changing device front to back mid video record stops recording #354

Closed
3 of 4 tasks
jehartzog opened this issue Aug 13, 2021 · 4 comments · Fixed by #1466
Closed
3 of 4 tasks

🐛 Android: Changing device front to back mid video record stops recording #354

jehartzog opened this issue Aug 13, 2021 · 4 comments · Fixed by #1466
Labels
🤖 android Issue affects the Android platform 🐛 bug Something isn't working

Comments

@jehartzog
Copy link

What were you trying to do?

We wanted to allow users to swap between front/back devices

Reproduceable Code

const devices = useCameraDevices();
  const isFocused = useIsFocused();
  const [cameraType, setCameraType] = React.useState<'front' | 'back'>('front');

  const device = cameraType === 'front' ? devices.front : devices.back;
  const preset = 'hd-1280x720';

  if (!device) return null;

  return (
   <>
      <Camera
        style={StyleSheet.absoluteFill}
        device={device}
        preset={preset}
        isActive={isFocused}
        video
        audio
        ref={cameraRef}
      />
      <TouchableOpacity style={localStyles.flip} onPress={() => setCameraType(cameraType === 'front' ? 'back' : 'front' )} />
    </>
   );

What happened instead?

iOS: Works great. A few frames of oddness when we swap, but nothing big
Android: It swaps the preview, but onRecordingFinished is called.

Relevant log output

No response

Device

Pixel 2 XL, OnePlus 8T

VisionCamera Version

2.5.0

Additional information

@jehartzog jehartzog added the 🐛 bug Something isn't working label Aug 13, 2021
@mrousavy
Copy link
Owner

I don't think this is supported by CameraX. I've created an issue in Google's CameraX issue tracker here but haven't received any responses.

You can easily take a look at this yourself by playing around with the code and shooting me a PR if you manage to get it working :)

@jehartzog
Copy link
Author

@mrousavy Awesome for the response, thanks. We were not actually sure this was possible but wanted to explore a bit. This lib allows us to do this swap using iOS. We did noticed most Android apps don't allow this, but did find that the Android Snapchat app supports it. I see that you actually have more info on how they do this.

I guess this is probably an enhancement request rather than a bug, and one likely that needs to come from underlying Android lib, so happy to close this issue. Thanks again!

@mrousavy
Copy link
Owner

don't close, let's keep track of it here.

@mrousavy mrousavy added the 🤖 android Issue affects the Android platform label Aug 18, 2021
@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
🤖 android Issue affects the Android platform 🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants