Search code examples
wpfperformancewebview2

WebView2 - Improving Load Times and/or Considering Alternatives


I recently built a .NET WPF utility app for Windows around the MS WebView2 control, and in some ways, it has worked very nicely. The app is expected to prevent browsing other than the task at hand and is parameterized so that it can be configured, varying the URL, navigation options, visuals aspects, size, and new window behavior, allowing them to use it in many situations, and replacing IE. The only issue is slowness. It is slower than launching a new window in an already loaded browser, and it is faster than loading a full browser from scratch, but it still takes a few seconds to load. I looked at my code, and tried a little bit of optimization, converting the load process into a couple of async methods, but that saves only 0.2 seconds, with the bulk of the load time the actual site load and render.

This brings me to a few questions:

  1. Is there a way to optimize the WebView control to load faster, say by changing options?
  2. Are there alternative web view controls I could use to replace WebView2, and if so, could I keep the UI, or would I need to write in a different language/platform?
  3. I haven't written this before, but was wondering if I could reuse an existing window, and treat the app like a browser adding tabs, possibly by using something like NamePipes to send the app messages. I think I can see limitations, since WebView2 is topmost, possibly preventing me from using a tab control.

Any thoughts?


Solution

  • To improve performance, or at least the perception of it, I loaded up my app configurations first, set the view properties, and then awaited loading of the control:

    Await EnsureCoreWebView2Async