mawie81 / electron-window-state

A library to store and restore window sizes and positions for your Electron app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Window with width and height 0

alexstrat opened this issue · comments

For reasons I was not able to seize, users of my app find themselves with a window of height and width of 0.
Here is an example of window-state.json I saw:

{
  "width": 0,
  "height": 0,
  "x": 40,
  "y": 23,
  "isMaximized": false,
  "isFullScreen": false,
  "displayBounds": {
    "x": 0,
    "y": 0,
    "width": 1440,
    "height": 900
  }
}

It's on macOS with electron@v1.4.7 and electron-window-state@v4.0.1
I don't do anything particular with my window sizing in the code, I let electron-window-state handle that.
Nevertheless, I tend to notice that affected users use a secondary display from time to time.

While finding the actual cause of the bug would be better, shouldn't we implement a safeguard in electron-window-state? a size with 0 as width or 0 as height is not a valid state.

While I still haven´t been able to look into the possible root cause I agree: adding a > 0 check to the state validation makes sense.
In case you want to submit a PR feel free to do so. Otherwise I can do that too.

This should be fixed by the linked PR 😄