Repository navigation
fix(webview): prevent crash when game width is 0 - #2734
Conversation
Closes #2733 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
The focused validation and runtime guards consistently prevent zero-width zoom crashes.
0 open findings
What changed in this PR
Prevents invalid zero-width configurations from crashing Electron’s game webview.
Changes:
- Enforces a shared 100 px minimum width.
- Repairs invalid saved widths during startup.
- Skips zoom synchronization for non-positive factors.
| File | Description |
|---|---|
views/services/utils.ts |
Defines the shared minimum width. |
views/services/layout.ts |
Resets invalid saved widths. |
views/components/settings/display/resolution-config.tsx |
Rejects widths below the minimum. |
views/components/etc/webview.tsx |
Guards Electron zoom calls. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Review:
No actionable findings.
The change is internally consistent and closes the reported failure path: the non-positive factor is now rejected before both view.setZoomFactor(zoomFactor) calls (views/components/etc/webview.tsx:96 and :232), persisted sub-minimum widths are normalized to 1200 for both poi.webview.width and poi.webview.windowWidth (views/services/layout.ts:10-15, which runs before adjustSize() in the same module), and the settings handler plus the numeric input's minimum both use the shared MIN_WEBVIEW_WIDTH (views/components/settings/display/resolution-config.tsx:95,180). I could not construct a concrete, diff-introduced correctness, security, or reliability defect from these changes.
|
I reviewed the 4-file diff on top of examining the full call chain ( Overall this is a well-scoped defensive fix. I found one concrete, reviewable issue plus a couple of items I checked and explicitly did not flag (wrong premise on Electron throwing — verified it does throw; the runtime non-fixed 0-width case being left black — that's inherent to a 0-width area, and the crash is now prevented). Finding (1):
Everything else checked out:
No security, permission, or CI concerns. |
Closes #2733
Problem
Setting the fixed game width to 0 in the display settings leaves poi with a black, unresponsive window, and since the value is saved to config it happens again on every launch.
The webview zoom factor is derived from the measured webview width, so a 0 width yields a zoom factor of 0. Electron's
setZoomFactorrequires a factor greater than 0; the call is made from a React effect inviews/components/etc/webview.tsx.Changes
views/components/etc/webview.tsx: skip the zoom sync (andforceSyncZoom) unless the factor is positive. This also covers a 0 width reached other ways, e.g. dragging the game area fully closed in non-fixed mode.views/components/settings/display/resolution-config.tsx: ignore widths belowMIN_WEBVIEW_WIDTH(100 px) and use it as the numeric input's minimum instead of 0.views/services/layout.ts: on startup, reset a savedpoi.webview.width/poi.webview.windowWidthbelow the minimum to 1200, so a config that already holds 0 recovers without manual editing.views/services/utils.ts: add the sharedMIN_WEBVIEW_WIDTHconstant.Testing
npm run lint:json the touched files andnpm run typecheckpass.🤖 Generated with Claude Code