livekit / client-sdk-swift

LiveKit Swift Client SDK. Easily build live audio or video experiences into your mobile app, game or website.
https://livekit.io
Apache License 2.0
174 stars 84 forks source link

switchCameraPosition on CameraCapturer causes the VideoView to be flipped horizontally for split of a second #362

Closed patryk-sredzinski closed 2 months ago

patryk-sredzinski commented 3 months ago

Describe the bug When you want to switch camera between front and rear camera, VideoView shows frame flipped horizontally.

SDK Version 2.0.5

iOS/macOS Version iPhone 15 Pro, iOS 17.5

Minimal Example code I've made a few changes to uikit-minimal repository to show this effect.

branch: bug/switch-camera-position-flipped-horizontally

PR showing the changes: https://github.com/patryk-sredzinski/client-sdk-swift/pull/1/files

Steps to Reproduce

  1. Create LocalVideoTrack
  2. Create VideoView
  3. Start LocalVideoTrack
  4. Set VideoView's track to LocalVideoTrack
  5. Execute switchCameraPosition on LocalVideoTrack's capturer
  6. Observe
// If this myVideoTrack is added to a videoView, the ugly mirror/horizontal flip occours 
try await (myVideoTrack.capturer as? CameraCapturer)?.switchCameraPosition()

Expected behavior VideoView should probably just keep the last valid frame, and flip only when new frame from new camera is available

Screenshots output

This just looks bad and breaks a nice user experience. or maybe I am doing something wrong here?

hiroshihorie commented 3 months ago

Thanks I have noticed this too. It needs some timing tweaking etc.

hiroshihorie commented 1 month ago

Further improvements in this PR: https://github.com/livekit/client-sdk-swift/pull/383