Skip to content

Fix WebCamTexture orientation on the wire#276

Merged
MaxHeimbrock merged 2 commits intomainfrom
max/fix-webcam-rotation-issues
May 7, 2026
Merged

Fix WebCamTexture orientation on the wire#276
MaxHeimbrock merged 2 commits intomainfrom
max/fix-webcam-rotation-issues

Conversation

@MaxHeimbrock
Copy link
Copy Markdown
Contributor

@MaxHeimbrock MaxHeimbrock commented May 7, 2026

Summary

Fixes two related bugs that caused remote participants to see local video at the wrong orientation:

  • Rotation passthrough. WebCameraSource.GetVideoRotation was mismapping cases (0→_180, 180→_0, 270→_180). Android front cam in portrait reports videoRotationAngle == 270, so remotes saw the stream 90° off. Replaced with a straight passthrough across all four angles.
  • Buffer Y-flip. GetPixels32 returns rows bottom-up but WebRTC expects top-down, so the buffer was being sent vertically flipped. The previous 0→_180 mapping was masking this on desktop (180° rotation visually approximates a Y-flip on roughly-symmetric subjects), but it was never actually correct. Flip rows during the buffer copy.

Also includes a missing .meta file for TaskYieldInstruction.cs.

Test plan

  • Android front cam, portrait — remote sees upright
  • Android back cam, portrait — remote sees upright
  • iOS front cam, portrait — remote sees upright
  • iOS back cam, portrait — remote sees upright
  • iOS landscape (front + back) — remote sees upright (this is the path the old broken mapping happened to compensate for; verify the passthrough is correct here)
  • Editor / macOS desktop webcam — remote sees upright (no longer relying on the _180 hack to mask the Y-flip)

🤖 Generated with Claude Code

MaxHeimbrock and others added 2 commits May 7, 2026 14:59
Two related issues caused remote participants to see local video at
wrong orientations:

1. GetVideoRotation was mismapping cases: 0→_180, 180→_0, 270→_180.
   Android front cam in portrait reports videoRotationAngle == 270, so
   remotes saw the stream 90° off. Replaced with a straight passthrough
   across all four angles.

2. GetPixels32 returns rows bottom-up but WebRTC expects top-down, so
   the buffer was being sent vertically flipped. The previous "0→_180"
   mapping was masking this on desktop (180° rotation visually
   approximates a Y-flip on roughly-symmetric subjects), but it was
   never actually correct. Flip rows during the buffer copy.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@MaxHeimbrock MaxHeimbrock merged commit f7a33be into main May 7, 2026
21 of 23 checks passed
@MaxHeimbrock MaxHeimbrock deleted the max/fix-webcam-rotation-issues branch May 7, 2026 13:54
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.

1 participant