Skip to content

fix(desktop qr): scale large camera frames down before scanning - #1489

Open
sneurlax wants to merge 2 commits into
fix/linux-qr-camera-timeoutfrom
fix/qr-camera-frame-scaling
Open

sneurlax wants to merge 2 commits into
fix/linux-qr-camera-timeoutfrom
fix/qr-camera-frame-scaling

Conversation

@sneurlax

@sneurlax sneurlax commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Base: fix/linux-qr-camera-timeout. Last of three stacked PRs on top of the Windows QR camera fix.

Large camera frames make live QR scanning on desktop slow, and a QR code held up to a webcam doesn't need that resolution.

Cause

Decoding and binarizing a full-size camera frame is expensive. Before #1485 moved the Windows scanner to in-memory preview captures, camera_windows' takePicture() returned the camera's largest still mode regardless of preset: a Depstech USB webcam gave 3264x2448 photos at the medium preset, and each one took 2 to 3 seconds to decode on an older laptop. Windows no longer captures at that size, but nothing in the decode path limits frame size for other cameras or platforms.

Change

  • decodeQrFromImage takes an optional maxDimension. Images with a longer side above it are scaled down (area-averaging) before decoding, and smaller images are left alone.
  • The dialog passes 1280 for camera frames only. Files picked with "Select file" are still scanned at full size, since a QR code there can be small relative to the image.
  • The Windows preview capture from Desktop QR: official camera_windows 0.3.0+1, scan Windows frames in memory #1485 now uses the same constant for its size cap, so there is one 1280 px limit for camera frames.
  • Two tests are added:
    • a 3264x2448 JPEG frame with a QR code in it decodes after scaling to 1280
    • an image already within the limit decodes unchanged

The scaling applies on every desktop platform, to any camera frame larger than 1280 px.

Camera frames are now scaled to fit 1280 px before scanning, which keeps
decoding fast when a camera hands back a large frame. Before the Windows
scanner read frames from the preview, a USB webcam there returned
3264x2448 photos even at the medium preset, which took 2-3 s per frame
to decode and scan on an older laptop. Windows preview captures now use
the same 1280 px cap. Files from Select file are still scanned at full
size.
@julian-CStack
julian-CStack force-pushed the fix/qr-camera-frame-scaling branch from e902a58 to 1ae0ee7 Compare November 2, 2026 21:13
@codecov

codecov Bot commented Nov 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 44.44444% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 11.64%. Comparing base (fa844f4) to head (5b2c330).

Files with missing lines Patch % Lines
lib/widgets/desktop/qr_code_scanner_dialog.dart 0.00% 4 Missing ⚠️
lib/utilities/qr_image_decoder.dart 80.00% 1 Missing ⚠️
Additional details and impacted files
@@                     Coverage Diff                      @@
##           fix/linux-qr-camera-timeout    #1489   +/-   ##
============================================================
  Coverage                        11.64%   11.64%           
============================================================
  Files                             1136     1136           
  Lines                           114351   114356    +5     
============================================================
+ Hits                             13319    13322    +3     
- Misses                          101032   101034    +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant