WebView2Feedback icon indicating copy to clipboard operation
WebView2Feedback copied to clipboard

[Feature]: Persistence

Open Slion opened this issue 1 year ago • 4 comments

Describe the feature/enhancement you need

I need to persist WebView2 states when the application is restarted.

The scenario/use case where you would use this feature

For instance a web browser with multiple persistent tabs would need this. At the very least each tab should be able to persist its navigation history, including URLs and scroll positions.

How important is this request to you?

Critical. My app's basic functions wouldn't work without it.

Suggested implementation

Take a look at how this is done on Android WebView saveState and restoreState.

What does your app do? Is there a pending deadline for this request?

This is a showstopper. Can't release the app without that feature. We'll need to look at alternatives to Microsoft Edge WebView2.

References

#4711 StackOverflow #4712

Slion avatar Jul 28 '24 16:07 Slion

Could you better describe what are you trying to do with the state persistence? What does your application do, and why is this important for it?

victorhuangwq avatar Jul 29 '24 18:07 victorhuangwq

The application is a web browser and it needs to persist its tabs. Say you have 4 tabs open, each one is using a WebView, each of them are currently looking at a web page at a given scroll offset but they also each have a navigation history, sometimes called back and forward stack. We need to be able to persist at least all that information so that when the user closes the application and reopens it she can resume web browsing exactly as it was.

As mentioned above this is easily done on Android WebView. I have not seen anything like that with WebView2. Did I miss it somehow? This is about enabling persistence which is a fairly basic software concept. In the case of complex objects like WebView it is possibly not just about navigation history and scroll offset. Their is likely a bunch of other data you may need or want to persist.

As with Android WebView, it is often implemented as a pair of methods often called as follow:

  • load and save
  • internalize and externalize
  • deserialize and serialize

Hope that helps you understand what I'm looking for.

Slion avatar Jul 30 '24 15:07 Slion

Basically I have a WebView in my application with all its travellog history I want to be able to close the app and restore it exactly as it was. This is badly missing at the moment it seems, which I find is a major oversight considering how easy it is to achieve on other platforms such as Android.

Slion avatar Sep 06 '24 15:09 Slion

Even in Edge page scroll offset is not persisted only the travel logs. Though until you restart your session scroll offset is kept as expected as you go back or forward in your travel logs.

Slion avatar Sep 12 '24 14:09 Slion