Skip to content

fix(ios): keep QR capture work off main thread - #2853

Open
wgqqqqq wants to merge 1 commit into
GCWing:mainfrom
wgqqqqq:wgq/ios-qr-scanner-session-queue
Open

fix(ios): keep QR capture work off main thread#2853
wgqqqqq wants to merge 1 commit into
GCWing:mainfrom
wgqqqqq:wgq/ios-qr-scanner-session-queue

Conversation

@wgqqqqq

@wgqqqqq wgqqqqq commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Problem

Scanning a pairing QR code could freeze the iOS UI because AVCaptureSession.startRunning() and stopRunning() executed synchronously on the main thread. The scanner also let UIKit and SwiftUI dismiss the same cover independently.

Changes

  • create and operate the capture session on a dedicated serial queue
  • deliver QR results to the main thread only after capture stops
  • ignore duplicate metadata callbacks
  • stop capture when the scanner disappears
  • make SwiftUI the single owner of scanner dismissal

Validation

  • iPhone 16 Pro simulator Debug build
  • signed generic iOS device Debug build
  • ./Testing/run-pure-swift-tests.sh
  • git diff --check upstream/main...HEAD
  • iPhone 13 Pro, iOS 26.3: QR recognition stopped capture off the main thread, pairing requests returned HTTP 200, subsequent 15-second heartbeats succeeded, the process stayed alive, and no crash report was produced

The live device run verified the queue and dismissal fix. The final lazy-initialization refinement was then device-build verified after the log exposed a separate capture-session initialization stall.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant