Skip to content

Fix/eid wallet barcode scanner deadlock#978

Merged
coodos merged 2 commits into
mainfrom
fix/eid-wallet-barcode-scanner-deadlock
May 28, 2026
Merged

Fix/eid wallet barcode scanner deadlock#978
coodos merged 2 commits into
mainfrom
fix/eid-wallet-barcode-scanner-deadlock

Conversation

@coodos
Copy link
Copy Markdown
Contributor

@coodos coodos commented May 28, 2026

Description of change

Fixes a hard crash on iOS where the app froze and was killed by the watchdog (0x8BADF00D — "failed to terminate gracefully") whenever the barcode scanner was active — most reliably on pressing back out of the Scan QR screen.

Root cause was a re-entrancy deadlock in Tauri 2.10.3's mobile IPC: plugin_command_response_handler held the PENDING_PLUGIN_CALLS mutex across the handler callback (the MutexGuard lived for the whole if let Some(handler) = …lock()…remove() { handler() } block). When the barcode scanner's cancel() rejected the still-pending scan(), that re-entered the same handler on the main thread and deadlocked the lock against itself. Tauri 2.11.2 fixes this by removing the handler into a let binding so the lock is released before the handler runs.

Changes:

  • Upgrade tauri 2.10.3 → 2.11.2 (and tauri-build/runtime/macros), plus @tauri-apps/api^2.11.0. This is the actual fix.
  • Harden the Scan QR lifecycle (scanLogic.ts): a module-scoped scanInFlight guard that survives page re-mounts, and a cancel() before each scan() to tear down any stale native session. Defensive, prevents overlapping scans.

Note: the Scan QR page re-mount loop (repeated device re-registration) is a separate pre-existing issue and is not addressed here; it no longer crashes the app, but is worth a follow-up.

Issue Number

N/A

Type of change

  • Fix (a change which fixes an issue)

How the change has been tested

  • Reproduced the original crash on a physical iPhone 16 (iOS 26.5); captured and symbolicated the .ips crash reports confirming the deadlock in tauri::plugin::mobile::run_command::plugin_command_response_handlerMutex::lock, reached via BarcodeScannerPlugin.cancel.
  • Verified the fixed lock-release ordering is present in the vendored tauri 2.11.2 source.
  • cargo build --target aarch64-apple-ios compiles cleanly with all plugins on 2.11.2.
  • svelte-check passes (0 errors) for the scanLogic.ts change.
  • Manually verified on device via tauri ios dev: scanning and pressing back no longer hangs/crashes.

Change checklist

  • I have ensured that the CI Checks pass locally
  • I have removed any unnecessary logic
  • My code is well documented
  • I have signed my commits
  • My code follows the pattern of the application
  • I have self reviewed my code

Summary by CodeRabbit

  • Chores

    • Updated dependencies for improved compatibility.
  • Bug Fixes

    • Improved QR code scanning stability by preventing concurrent scan attempts during page transitions.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 63f36841-d951-41c9-8828-ace2dc23d128

📥 Commits

Reviewing files that changed from the base of the PR and between 48c43d5 and 04f6b1e.

⛔ Files ignored due to path filters (2)
  • infrastructure/eid-wallet/src-tauri/Cargo.lock is excluded by !**/*.lock
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • infrastructure/eid-wallet/package.json
  • infrastructure/eid-wallet/src/routes/(app)/scan-qr/scanLogic.ts

📝 Walkthrough

Walkthrough

Tauri API dependency is upgraded to ^2.11.0, and scanLogic implements a module-scoped scanInFlight guard to prevent overlapping native scan calls when the Svelte page remounts. Stale sessions are cleaned before new scans start, and the flag is reset on completion.

Changes

QR Scan Concurrency and Stale Session Management

Layer / File(s) Summary
Tauri API Dependency Upgrade
infrastructure/eid-wallet/package.json
@tauri-apps/api is bumped from ^2.9.0 to ^2.11.0.
Module-Scoped Scan Concurrency Guard
infrastructure/eid-wallet/src/routes/(app)/scan-qr/scanLogic.ts
Module-scoped scanInFlight boolean prevents concurrent scan entry by gating startScan() when a scan is already active. Before each new scan, any stale native session from a prior mount is cancelled. The flag is reset when the scan promise settles or when cancelScan() is called.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A QR code hops from page to page,
But oh, the scan guard saves the stage!
No double-scan shall overlap,
Re-mounts now sidestep the trap.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/eid-wallet-barcode-scanner-deadlock

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coodos coodos merged commit 35a8c6d into main May 28, 2026
3 of 4 checks passed
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