Wrong aspectRatio displayed on mobile (Android & iOS)
See original GitHub issueDescribe the bug
I want to create an fullscreen scanner, so I setted the aspectRatio = window.innerWidth / window.innerHeight
(the result on iphone 8 is 0.6843065693430657).
But the video was rendered with a wrong aspect ratio (landscape instead of portrait).
Additionally, It worked great on MacOs’s Chrome and was not stable on MacOs’s Safari (sometime correct, sometime wrong).
To Reproduce
this.html5QrCode = new Html5Qrcode('qr-reader')
const camera = { facingMode: 'environment' }
const qrBoxSize = 250
const width = window.innerWidth
const height = window.innerHeight
const aspectRatio = width / height
const config = {
fps: 20, // frame per seconds for qr code scanning
aspectRatio,
qrbox: { width: qrBoxSize, height: qrBoxSize },
}
await this.html5QrCode.start(
camera,
config,
(decodedText, decodedResult) => this.onScanSuccess(decodedText, decodedResult),
(error) => this.onScanFailure(error),
)
Expected behavior
The camera’s video should be display with correct aspect ratio (fullscreen)
Screenshots
Desktop (please complete the following information):
- OS: macOS
- Browser: safari + chrome on iPhone, safari on macOS.
- Version: 96
Smartphone (please complete the following information):
- Device: iphone 6, Xiaomi Redmi
- OS: iOS 15.1
- Browser: safari, chrome
- Version: latest
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
How to Change the Screen Resolution on Your Android
1. Open your Android's {"smallUrl":"https:\/\/www.wikihow.com\/images\/e\/ed\/Android7settingsapp.png","bigUrl":"\/images\/thumb\/e\/ed\/Android7settingsapp ... 2. Tap Display. It's next to an icon that resembles a sun in the Settings menu.
If you...
Read more >Wrong aspect ratio in apps - Apple Community
Wrong aspect ratio in apps. Some apps, like YouTube, are cut by the black bar on top of my iPhone screen. How can...
Read more >How to change the aspect ratio of a video on an Android phone
There are two ways. The first is by changing the aspect ratio, and then adjusting the width and height of the video; the...
Read more >Is it possible to change iPhone X, iPhone XS, XS Max, XR, to ...
No, it is not possible to generally change the aspect ratio of the screen for any third party app. You'll have to contact...
Read more >Declare restricted screen support - Android Developers
We recommend a ratio of 2.4 (12:5). Your app will be letterboxed when it runs on a device with an aspect ratio greater...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can try the hack below, which worked perfectly for me.
@bahung1221
Where is this variable set?