Repository navigation
Make the pairing QR bigger and faster to scan - #5863
azooz2003-bit wants to merge 2 commits into
Conversation
The Mac pairing window rendered the QR at 220pt and at 1x, so on Retina screens the phone saw a small, nearest-neighbor-doubled code. Render it at 340pt at the display's backing scale (nearest sampling through the scale so modules stay hard-edged) and grow the window to fit. On iOS, restrict the scanner's autofocus to the near range so the lens stops hunting through far focus when pointed at a screen at arm's length. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe PR improves QR code pairing by enhancing both the capture and display sides: the camera now restricts autofocus to the near range for better scanning reliability, while the QR image rendering incorporates device pixel scaling and sharp-edge sampling, and the displayed code is enlarged with corresponding window resizing. ChangesQR Pairing Display and Capture Optimization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (2 errors, 1 warning)
✅ Passed checks (18 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR improves QR-code scan speed on both sides of the pairing handshake — the macOS window now generates a Retina-native bitmap at the display's backing scale with hard module edges (
Confidence Score: 4/5Safe to merge; both changes are narrowly scoped, best-effort on the iOS side, and leave the payload and scan protocol untouched. The only notable issue is that CIContext() is created fresh on each qrImage evaluation — now at up to 680×680 pixels — rather than reusing a shared context. In practice SwiftUI struct-equality prevents frequent recomputation, so this is unlikely to be user-visible, but it is an avoidable allocation. Everything else — the autofocus guard, the samplingNearest pipeline, the window resize arithmetic — is well-reasoned and correct. Sources/Mobile/Pairing/MobilePairingQRImageView.swift — the CIContext allocation pattern is worth a second look. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
subgraph macOS_side["macOS – MobilePairingWindowController"]
A["show()"] --> B["NSWindow 460x760"]
B --> C["MobilePairingView\ndimension: 340pt"]
C --> D["MobilePairingQRImageView"]
D --> E["displayScale env\ne.g. 2.0 Retina"]
E --> F["CIQRCodeGenerator\ncorrectionLevel L"]
F --> G["samplingNearest\nscale = 340 x 2 / extent\n-> 680x680 px bitmap"]
G --> H["NSImage size=340x340pt\nnative @2x"]
end
subgraph ios_side["iOS – QRCodeCaptureController"]
I["viewDidLoad"] --> J["configureSession"]
J --> K{"isAutoFocusRange\nRestrictionSupported?"}
K -- Yes --> L["lock / set .near / unlock"]
K -- No --> M["skip, scan still works"]
L --> N["AVCaptureMetadataOutput\nQR scanning"]
M --> N
end
H -- shown on screen --> ios_side
Reviews (1): Last reviewed commit: "Make the pairing QR bigger and faster to..." | Re-trigger Greptile |
| let context = CIContext() | ||
| guard let cgImage = context.createCGImage(scaled, from: scaled.extent) else { |
There was a problem hiding this comment.
A new
CIContext() is allocated on every invocation of qrImage. CIContext initialization involves GPU pipeline setup and is one of the more expensive Core Image operations — Apple's documentation explicitly recommends reusing a single context. With the resolution now at dimension * displayScale (up to 680 × 680 pixels), each call is heavier than before. Because qrImage is a plain computed var called from body, SwiftUI's struct-equality diffing prevents redundant calls in practice, but any parent state update that causes the view's inputs to change (payload refresh, display-scale change) will recreate the context from scratch. A static or lazily-initialized shared context would avoid the allocation entirely.
| let context = CIContext() | |
| guard let cgImage = context.createCGImage(scaled, from: scaled.extent) else { | |
| let context = CIContext.shared | |
| guard let cgImage = context.createCGImage(scaled, from: scaled.extent) else { |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Main landed #5872 (full-width native-module QR render, routes-only payload) and scanner tuning that is a superset of this branch's near-focus restriction, so this merge takes main's side everywhere. The branch now carries no changes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Superseded by #5872, which landed a strictly better version of both halves: full-width native-module QR render on macOS (vs this PR's fixed 340pt) and iOS scanner tuning (multi-lens camera selection + near-range autofocus + exposure tuning, a superset of this PR's near-focus restriction). Branch merged to main's state; diff is empty. |
Scanning the pairing QR from the iOS app was slow to lock on.
Two changes, one per side of the scan:
samplingNearest()through the scale transform, so modules are both physically larger and hard-edged.QRCodeCaptureController): restrictautoFocusRangeRestrictionto.nearwhen supported. Pairing codes are scanned off a screen at arm's length; the near restriction stops the lens from hunting through far focus, which is the usual cause of a slow QR lock. Best-effort and guarded byisAutoFocusRangeRestrictionSupported.No payload change (the compact short-key ticket coder already minimizes QR version). No new user-facing strings, so no localization changes. A meaningful automated test is not practical for either change (render size and camera focus optics); verified by dogfood.
🤖 Generated with Claude Code
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by cubic
Superseded by the minimal pairing QR redesign on main. After merging main, this branch no longer changes macOS QR rendering or iOS scanner behavior.
Written for commit bd4c9e5. Summary will update on new commits.
Summary by CodeRabbit