Repository navigation
Conversation
sneurlax
force-pushed
the
fix/windows-qr-camera
branch
3 times, most recently
from
November 2, 2026 21:01
8e25aab to
edfc787
Compare
…ow camera errors ResolutionPreset.low caps the camera_windows preview at 240 px, so webcams without a mode that small fail with "Failed to initialize video preview". Try medium then max on each camera (IR cameras last), delete the JPEG that takePicture leaves in Pictures, show init and capture failures instead of an endless spinner, and decode with HybridBinarizer before the global one.
Replace the cypherstack/packages image-streaming fork (0.2.4, from flutter/packages#7067, which upstream merged and later reverted). The app only polls takePicture on Windows and never streams images. 0.3.0+1 falls back to a physical stream when a multi-stream USB camera rejects the preferred-stream selectors, which fixes "Failed to initialize video preview" (flutter/flutter#140014). camera_platform_interface resolves to 2.15.0.
camera_windows' takePicture() always saves a JPEG in the user's Pictures folder. Deleting it afterwards still puts a QR code, which may hold a seed or private key, on disk, where OneDrive sync, file recovery or the indexer can pick it up. Show the live preview texture instead and capture it in memory with RepaintBoundary.toImage(), at the camera's own resolution capped at 1280 px. camera_windows mirrors its preview, so the capture is flipped back before decoding. Drop the capture cleanup code and its test. Errors are drawn over the preview rather than replacing it, so capture keeps running and the error clears when frames come back. Blank frames (nothing drawn yet, or a covered lens) are logged once and skipped with the usual delay, and a spinner shows until the first frame arrives. Tested on Windows 11 with a USB webcam under Impeller and Skia: preview captures are 640x480, two QR codes (one about 260 characters) scan in the add-node view, and nothing is written to Pictures.
julian-CStack
force-pushed
the
fix/windows-qr-camera
branch
from
November 2, 2026 21:13
edfc787 to
7c4996a
Compare
julian-CStack
approved these changes
Nov 3, 2026
julian-CStack
left a comment
Collaborator
There was a problem hiding this comment.
setState probably doesn't need to be called as often on windows and the widget building helper functions could be extracted as stateless widgets. Performance gain would probably be negligible
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tester report: QR scanning does not work on Windows for any coin. The log shows
CameraException(camera_error, Failed to initialize video preview)frominitializeCameraon every attempt.Cause
Two Windows camera issues contribute to the failure:
camera_windowsbased on version 0.2.4. It lacks the upstream 0.3.0+1 fix for cameras that reject the preferred-stream selector. The app does not use the fork's Windows image-stream functionality.ResolutionPreset.low.camera_windowsrequires a compatible preview mode at 15 fps or higher, and some webcams do not provide one below the preset's 240-pixel cap.Initialization failures were not shown in the dialog, leaving the user with a loading indicator and no useful recovery path.
There was also a privacy problem: the scanner polled
takePicture, which always writes the capture to%USERPROFILE%\Pictures\PhotoCapture_*.jpeg. The app never removed those files, even though they may contain wallet addresses, seeds, FROST material, or node credentials and may be synchronized by services such as OneDrive. Deleting each file after reading it would still put it on disk, where sync, file recovery or the search indexer can pick it up, so this PR stops writing it at all.Changes
Three commits:
fix(desktop qr): open Windows cameras at a preset they support and show camera errorsResolutionPreset.medium, followed byResolutionPreset.max, for each camera.HybridBinarizerbefore falling back toGlobalHistogramBinarizerwhen decoding live camera frames under uneven lighting.deps: use official camera_windows 0.3.0+1 from pub.devcamera_windowsfork with officialcamera_windows: ^0.3.0+1.camera_platform_interfaceresolves to 2.15.0.fix(desktop qr): scan Windows camera frames from the preview in memoryRepaintBoundary.toImage(), at the camera's own resolution capped at 1280 px.takePictureis no longer called, so nothing is written to Pictures.camera_windowsmirrors its preview, so each capture is flipped back before decoding.lib/utilities/camera_preview_frame.dartwith unit tests, plus a widget test that runs a realtoImage()capture of a mirrored QR code and decodes it.Commit 1's message mentions deleting the
takePictureJPEG; commit 3 replaces that path entirely.Testing
On Windows 11 with a Depstech USB webcam, release build:
camera_windowsuses, decoded 40/40 captures under both Impeller (the default) and Skia.Scope
This PR does not include:
Those changes are stacked on this branch. On this PR alone, a Windows camera that opens but never delivers a frame shows the spinner with no error; #1488's 10-second timeout covers that case.