Skip to content

Comments

fix: make camera.flip() work more reliably with older devices#1781

Merged
oliverlaz merged 1 commit intomainfrom
camera-flip
May 7, 2025
Merged

fix: make camera.flip() work more reliably with older devices#1781
oliverlaz merged 1 commit intomainfrom
camera-flip

Conversation

@oliverlaz
Copy link
Member

💡 Overview

While optimizing the camera.flip() API in #1679, we introduced a regression that led to camera.flip() throwing a NotReadableError on devices with limited hardware capabilities.
Some devices are unable to provide two MediaStream instances at the same time.

📝 Implementation notes

We want to preserve the camera.flip() optimizations as they allow significantly faster direction change.
We always attempt to perform a fast direction change, but if it fails, we fall back to:
stop() -> flip() -> start() flow, which is slower, but it works.

🎫 Ticket: https://linear.app/stream/issue/REACT-367/

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR aims to fix a regression in camera.flip() for older devices by adding a fallback mechanism when a fast direction change fails. Key changes include:

  • Early exit if the device doesn't support direction changes.
  • Separating logic for React Native and web mobile.
  • Adding error handling to recover from NotReadableError via a stop–start (mute–unmute) flow.

@oliverlaz oliverlaz merged commit 9dfbc55 into main May 7, 2025
17 checks passed
@oliverlaz oliverlaz deleted the camera-flip branch May 7, 2025 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants