Bug 220326 - [iOS] Camera preview gets cropped or zoomed after device rotation
Summary: [iOS] Camera preview gets cropped or zoomed after device rotation
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: Safari 14
Hardware: iPhone / iPad iOS 14
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-01-05 06:50 PST by Stefan Benicke
Modified: 2024-03-19 00:51 PDT (History)
2 users (show)

See Also:


Attachments
Screenshots of different states of camera preview before and after rotation (647.10 KB, image/jpeg)
2021-01-05 06:50 PST, Stefan Benicke
no flags Details
ios sysdiagnose (674.24 KB, text/plain)
2021-05-18 06:41 PDT, Stefan Benicke
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Benicke 2021-01-05 06:50:38 PST
Created attachment 417000 [details]
Screenshots of different states of camera preview before and after rotation

A simple preview of `getUserMedia` video stream is cropped or zoomed after device rotation. It happens randomly and unpredictable.

Steps to reproduce:
- Open https://webrtc.github.io/samples/src/content/getusermedia/gum/ and click "Open camera", confirm camera access to see the preview
- Rotate device for 90°
- Rotate device back
- Repeat to see different results

What happens on my iPhone SE (v14.3, Safari v14.0.2):
- When rotated to landscape - sometimes - cam seems like zoomed out to just fill a quarter of the video element (rest is black)
- When rotated to portrait - sometimes - cam seems like zoomed in to double size
- When rotated to portrait - sometimes - cam seems like cropped the bottom half (black bars)
- Sometimes after a rotation cam is correct

What should happen instead:
- No cropped parts
- No zoom

My observations:
I have tested with another device iPad Air 3 (v14.3) and it worked perfectly! I know that other users with their iPhones or iPads also have issues like black bars, cropped cam preview or even an offset of the cam preview within the video element.

I have tried to force video width and height in `getUserMedia` video constraints and/or force fixed width and height of video element, trigger stream update with `applyConstraints({ height: … })` or similar after `window.onrotationchange` event but nothing has solved the issue for me.

I've noticed that video track dimensions change after device orientation change event. It starts with 480x640 and after rotation it reports 640x480. ( `stream.getVideoTracks()[0].getSettings()` ) And for me on the iPhone SE it shows the same issues either with front- or backcamera.
Comment 1 Radar WebKit Bug Importer 2021-01-05 07:00:50 PST
<rdar://problem/72811863>
Comment 2 youenn fablet 2021-05-17 04:00:39 PDT
I was not able to reproduce.
We fixed a regression in how we animate such changes but this does not seem related.
If you can still reproduce on latest iOS, could you send a sysdiagnose (youenn@apple.com)?
Comment 3 Stefan Benicke 2021-05-18 06:41:00 PDT
Created attachment 428930 [details]
ios sysdiagnose

Hi, thanks for your reply!
I still have this issue, but I'm still on iOS 14.4.2
Please find the sysdiagnose attached. I hope it's the correct one since I was creating this for the first time.
Best regards!
Comment 4 youenn fablet 2024-03-19 00:51:51 PDT
Marking as Configuration changed, please reopen if you still experience this issue.