Skip to content

fix: never pass -0 or NaN to BrowserWindow.setPosition - #236

Merged
alvinunreal merged 1 commit into
OpenPetsHQ:mainfrom
pinoybear:fix/window-position-negative-zero
Sep 25, 2026
Merged

alvinunreal merged 1 commit into
OpenPetsHQ:mainfrom
pinoybear:fix/window-position-negative-zero

Conversation

@pinoybear

Copy link
Copy Markdown
Contributor

Fixes #235

Math.round() returns -0 for values between -0.5 and 0, and Electron's setPosition throws on -0 and NaN. The Calendar Airmail flight crosses x=0 on a display at the origin, so some flights threw an uncaught main-process exception. With the lid closed, that locks up the whole app.

Changes

  • New apps/desktop/src/window-position.ts with setWindowPosition(window, x, y, animate?). It rounds, turns -0 into 0, and skips the move if either coordinate isn't finite.
  • All 12 setPosition calls in apps/desktop/src now go through it: plugin-delivery.ts, default-pet-controller.ts, agent-pet-controller.ts, lan-pet-controller.ts, plugin-pet-registry.ts and pet-window-context-menu.ts.
  • New tests/window-position.test.ts, which covers the exact Airmail tick that lands on -0.

Testing

  • pnpm test in apps/desktop passes.
  • A standalone Electron script that replays the flight math with a tick forced onto -0 throws before the change and completes the full flight after it.
  • 10 Test delivery flights on a dev build, on a 2560x1600 display at 0,0, with no errors.

Tested on CachyOS, kernel 7.2.7-1-cachyos, KDE Plasma 6.7.5, Electron 42.0.0.

Math.round() returns -0 for values in [-0.5, 0), and Electron's
setPosition throws "conversion failure" on -0 and NaN. The Calendar
Airmail flight crosses x=0 on a display at the origin, so roughly one
flight in five threw an uncaught main-process exception.

Add setWindowPosition() and route every setPosition call through it.
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.

Calendar Airmail flight can crash the main process when it crosses x=0 (setPosition gets -0)

2 participants