Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changes/barcode-scanner-ios-cancel-main-thread.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"barcode-scanner": patch
"barcode-scanner-js": patch
---

Fix a crash on iOS when `cancel()` is invoked. The pending camera
teardown (`removeFromSuperview`, webView background/opacity updates)
was running on the background dispatch queue that Tauri uses to
deliver plugin commands, which caused UIKit to abort the app with an
`NSAssertionHandler` failure inside `_didMoveFromWindow:toWindow:`.
The cancel handler now dispatches the UIKit work to the main thread,
matching the existing pattern used by `scan()` and `openAppSettings()`.
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,11 @@ class BarcodeScannerPlugin: Plugin, AVCaptureMetadataOutputObjectsDelegate {
}

@objc private func cancel(_ invoke: Invoke) {
self.invoke?.reject("cancelled")

destroy()
invoke.resolve()
DispatchQueue.main.async { [self] in
self.invoke?.reject("cancelled")
self.destroy()
invoke.resolve()
}
}
}

Expand Down