tauri-apps / tauri-apps/plugins-workspace

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

Open
#2,717 4 comments 0 reactions 0 assignees View on GitHub
plugin: window-state type: bug type: question
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
![Image](https://github.com/user-attachments/assets/4145c1f0-d1d4-4568-a8fa-e13cb5136509)
https://github.com/clash-verge-rev/clash-verge-rev/issues/3237#issue-2965277377
![Image](https://github.com/user-attachments/assets/ad140b35-1872-4605-b02d-ee14cd367bb9)

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,
......
}
}
```
![Image](https://github.com/user-attachments/assets/2ebf262d-d0ea-471e-aa12-855ad07c32cf)
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.