fix(tauri-runtime-cef): exit cleanly instead of panic when cef::initialize fails (TAURI-RUST-F)#17
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThis PR replaces a panic-on-failure CEF initialization path with a guarded handler that logs the failure, attempts a platform-native blocking notice (macOS NSAlert, Windows MessageBoxW, Linux GTK), and then exits the process cleanly. ChangesCEF Initialization Guard
Sequence Diagram(s)sequenceDiagram
participant CEF as CEF Runtime
participant InitGuard as cef_init_guard::fail_cef_init_and_exit
participant Dialog as Platform Dialog
participant Proc as Process Exit
CEF->>InitGuard: cef::initialize() returns non-1
InitGuard->>InitGuard: log(init_result, cache_path)
InitGuard->>Dialog: show_blocking_notice() (NSAlert / MessageBoxW / GTK)
Dialog-->>InitGuard: dialog dismissed or error
InitGuard->>Proc: exit(0)
🎯 3 (Moderate) | ⏱️ ~25 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
…alize fails (TAURI-RUST-F) cef::initialize() returns 1 on success and 0 on failure. The runtime asserted the result equals 1, so any failure (a live prior instance holding the CEF user-data-dir cache lock, or a GPU/sandbox/permission failure) became a fatal 'panic: assertion left == right' with no actionable message — Sentry TAURI-RUST-F, thousands of events across Windows, Linux and macOS. This is the single chokepoint every platform funnels through, so handle the failure here: log the actual return code + cache_path (preserving the Sentry-triage signal a panic used to give, via the stable TAURI-RUST-F marker), show a best-effort native notice, and exit cleanly (code 0) instead of asserting. The dialog is wrapped in catch_unwind and the process always exits afterwards, so a misbehaving dialog backend can never re-introduce the crash. Per-platform native dialog uses deps the crate already links (NSAlert / MessageBoxW / GtkMessageDialog). Supersedes the diagnostic-panic approach of tinyhumansai#13 (orphaned when its companion openhuman#1510 merged without the bump): a still-fatal panic does not meet the 'no recurrence' bar now that TAURI-RUST-F is frequent and cross-platform; this keeps the diagnostic context but removes the crash.
334d55f to
98c7752
Compare
|
@senamakel — flagging overlap with your #13 (same line, History as I read it:
Why supersede rather than revive #13:
What this PR keeps from #13: the actionable diagnostic — the pre-exit Companion openhuman PR (tauri-apps#3337) adds a bounded macOS/Linux pre-CEF cache-lock wait so the common relaunch race resolves before init, with this as the universal backstop. Happy to defer to your preference on the line — does graceful-exit-with-diagnostics work for you, or do you want to keep the panic-as-Sentry-signal? Can close #13 if this lands. |
What
CefRuntime::initassertedcef::initialize(...) == 1. On failurecef::initializereturns0, so the assert firedpanic: assertion \left == right` failed, left: 0, right: 1` — a fatal, actionless crash.In the OpenHuman embedder this is Sentry TAURI-RUST-F (thousands of events across Windows, Linux and macOS). The dominant cause is a sequential relaunch race (auto-update relaunch / fast quit+reopen / restart flow) where a dying prior instance still holds the CEF user-data-dir cache lock;
cef::initializethen returns0. GPU / sandbox / permission failures hit the same assert.Why here
init()is the single chokepoint every platform funnels through.initis atauri_runtime::Runtimetrait impl returningSelf, so it cannot returnErrwithout a trait change — but the failure is unrecoverable in-process anyway (no webview runtime), so the correct action is to inform the user and exit cleanly rather than panic.Change
assert_eq!(cef::initialize(...), 1)withif result != 1 { cef_init_guard::fail_cef_init_and_exit(result) }.cef_init_guardmodule: logs the failure, shows a best-effort native notice, thenstd::process::exit(0).catch_unwindand the process always exits afterwards, so a misbehaving dialog backend can never re-introduce the panic.NSAlert(macOS),MessageBoxW(Windows),GtkMessageDialog(Linux). Adds only the cargo features needed (Win32_UI_WindowsAndMessaging, objc2-app-kitNSAlert/NSApplication, objc2-foundationNSString).This prevents the panic structurally; it does not catch/suppress it — the assert is gone.
Test
cargo fmt/cargo check/cargo clippyclean on macOS (new module: zero warnings).cef::initializereturns 1 → proceeds toRunEvent::Readynormally.Companion PR in the embedder adds a bounded macOS/Linux pre-CEF cache-lock wait so the common relaunch race resolves before init, with this as the universal backstop.
Summary by CodeRabbit