tauri-apps / tauri-apps/plugins-workspace
[window-state] Window not rendering correctly due to cache file
- Dominant language
- Rust
- Stars
- 1.8k
- Forks
- 602
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 9
Description
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:
https://github.com/clash-verge-rev/clash-verge-rev/issues/3493#issue-3055761025

https://github.com/clash-verge-rev/clash-verge-rev/issues/3237#issue-2965277377

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.
```json
{
"main": {
"width": 0,
"height": 0,
......
}
}
```
No visible window will be created by this.
```json
{
"main": {
"width": 400,
"height": 40,
"decorated": false,
......
}
}
```

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.
https://github.com/tauri-apps/plugins-workspace/blob/9bc4b2230ebb32bd30a4c0c2a21077829a729193/plugins/window-state/src/lib.rs#L210-L215
Contributor guide
Assessment
This issue has not been assessed yet.