wailsapp / wails

Create beautiful applications using Go
https://wails.io
MIT License
24.55k stars 1.18k forks source link

Data in window lost after resume from sleep mode. #3360

Closed daydream123 closed 5 months ago

daydream123 commented 5 months ago

Description

Every time the Windows computer resumes from sleep mode, the data in the app window is no longer displayed. However, the data is still held in memory by Go because I can retrieve the "lost" data by calling the Go API from the frontend. It seems that the WebView memory has been reclaimed.

To Reproduce

  1. Launch App, in fronend, set text's content by clicking a button to retrieve data from golang, it canbe a string.
  2. Press power button to enter sleep mode.
  3. Press power button again to leave sleep mode.
  4. Finally, the text would be blank.

Expected behaviour

Like other Apps developed with native gui framework, data showing in window should not be reclaimed after resume from sleep mode.

Screenshots

No response

Attempted Fixes

No response

System Details

# Wails
Version | v2.8.0

# System
┌─────────────────────────────────────────────────────────────────────────────────────────────────┐
| OS           | Windows 10 Pro                                                                   |
| Version      | 2009 (Build: 22631)                                                              |
| ID           | 23H2                                                                             |
| Go Version   | go1.21.6                                                                         |
| Platform     | windows                                                                          |
| Architecture | amd64                                                                            |
| CPU          | AMD Ryzen 7 6800H with Radeon Graphics                                           |
| GPU          | AMD Radeon(TM) Graphics (Advanced Micro Devices, Inc.) - Driver: 30.0.14064.6002 |
| Memory       | 16GB                                                                             |
└─────────────────────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌───────────────────────────────────────────────────────┐
| Dependency | Package Name | Status    | Version       |
| WebView2   | N/A          | Installed | 123.0.2420.65 |
| Nodejs     | N/A          | Installed | 20.11.1       |
| npm        | N/A          | Installed | 10.2.4        |
| *upx       | N/A          | Installed | upx 4.2.1     |
| *nsis      | N/A          | Available |               |
└─────────────── * - Optional Dependency ───────────────┘

# Diagnosis
Optional package(s) installation details:
  - nsis : More info at https://wails.io/docs/guides/windows-installer/

 SUCCESS  Your system is ready for Wails development!

Additional context

No response

leaanthony commented 5 months ago

Thanks for reporting this. Sounds like it's reloading on resume. Is there a way for you to confirm this? Thanks.

daydream123 commented 5 months ago

Thanks for reporting this. Sounds like it's reloading on resume. Is there a way for you to confirm this? Thanks.

Yes, my temporary solution is to save my workflow step enum in backend, after resume from sleep mode, I'll query the saved step in vue's onMounted, and then get the related data with that step enum from backend. This approach can solve the problem, it's a bit cumbersome. I've been unsure of a more elegant solution

leaanthony commented 5 months ago

I couldn't find anything in the webview2 feedback repo about this. I was hoping there was some sort of snapshotting feature

fyonecon commented 5 months ago

Webview下会冻结web状态,我用onshow的时候重新加载这个路由的页面就可以了。web页面休眠这个特性,没办法,go不能主动更新web状态。还有一种解决办法就是用go-webview代替mac的webview,你可以试试。

daydream123 commented 5 months ago

Webview下会冻结web状态,我用onshow的时候重新加载这个路由的页面就可以了。web页面休眠这个特性,没办法,go不能主动更新web状态。还有一种解决办法就是用go-webview代替mac的webview,你可以试试。

Thanks for your suggestion~