Skip to content

Fix Windows crash: prefer EdgeChromium backend over WinForms#3

Merged
uncle-hedgehog merged 1 commit into
mainfrom
claude/practical-diffie-256fcd
May 26, 2026
Merged

Fix Windows crash: prefer EdgeChromium backend over WinForms#3
uncle-hedgehog merged 1 commit into
mainfrom
claude/practical-diffie-256fcd

Conversation

@uncle-hedgehog

Copy link
Copy Markdown
Contributor

Summary

  • Prefer the EdgeChromium (WebView2) backend on Windows instead of letting pywebview auto-detect, which often picks WinForms first
  • Add cascading fallback: EdgeChromium → auto-detect → browser mode, so the app never crashes on startup
  • Update spec file comment to reflect the new backend strategy

Problem

Users on Windows with missing or misconfigured .NET Framework 4.x hit a RuntimeError from pythonnet when pywebview tries the WinForms backend. Because pywebview's fallback logic only catches ImportError, the RuntimeError propagates and crashes the app with no recovery.

Fix

EdgeChromium uses the Edge WebView2 runtime (ships with Windows 10/11) and has no .NET dependency, sidestepping the issue entirely. If EdgeChromium is unavailable, we fall back to pywebview's default auto-detection, and if that also fails, the app opens in the user's default browser as a last resort.

Test plan

  • Verify Windows build launches with EdgeChromium backend (WebView2)
  • Verify macOS build is unaffected (no gui param passed)
  • Simulate EdgeChromium failure to confirm fallback to auto-detect
  • Simulate all-backends failure to confirm browser fallback

🤖 Generated with Claude Code

pywebview's WinForms backend requires pythonnet/.NET Framework 4.x.
On machines with missing or misconfigured .NET, pythonnet throws a
RuntimeError that bypasses pywebview's fallback logic and crashes the
app on startup.

Switch to the EdgeChromium backend (Edge WebView2) on Windows — it
ships with Windows 10/11 and needs no .NET dependency. If EdgeChromium
is unavailable, fall back to auto-detection, then to browser mode as
a last resort so the app never crashes.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@uncle-hedgehog uncle-hedgehog merged commit 68c3d18 into main May 26, 2026
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