Skip to content

[window-state] Window not rendering correctly due to cache file #2717

@Tunglies

Description

@Tunglies

Due to unknown behavior, the .window-state.json cache file may record unexpected values for the width and height fields, resulting in abnormal window sizes when users launch the application.

For related issue examples:
clash-verge-rev/clash-verge-rev#3493 (comment)
Image
clash-verge-rev/clash-verge-rev#3237 (comment)
Image

Since these feedbacks was submitted by users of our downstream repository, the available clues are limited. However, according to community reports, when this issue occurs, triggering a window resize using system shortcuts or deleting the {identifier}\.window-state.json file and restarting the application can restore the window to its normal size.

I tried to manually reproduce this unexpected behavior by modifying the width and height values in the cache file.

{
  "main": {
    "width": 0,
    "height": 0,
   ......
  }
}

No visible window will be created by this.

{
  "main": {
    "width": 400,
    "height": 40,
     "decorated": false,
   ......
  }
}

Image
The window created is very similar to what has been reported in the community issues.

I found the following code to handle the window size settings, but I haven’t seen any width and height validation elsewhere.

if flags.contains(StateFlags::SIZE) {
self.set_size(PhysicalSize {
width: state.width,
height: state.height,
})?;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions