Skip to content

[Problem/Bug]: WebView2CompositionControl regressions compared to WebView2 #5566

@ScarletKuro

Description

@ScarletKuro

What happened?

After upgrading Microsoft.AspNetCore.Components.WebView.Wpf from 9.0.120 to 10.0.51 that switches from Microsoft.Web.WebView2.Wpf.WebView2 to Microsoft.Web.WebView2.Wpf.WebView2CompositionControl.

  1. Problem with Blazor WPF Hybrid is that during the initialization phase it doesn't show the index.html loading from Blazor. Just blank screen. If you downgrade to v9 you won't have this problem. Also latest winform control doesn't have this problem.
  2. Second problem, if you won't WebView2CompositionControl dispose the control explicitly, and Blazor will send IPC the control will throw that WebView was is "WebView2 control is Disposed" exception propagating to apps unhandled exception. You can download the repro here "WebView2 control is Disposed" exception, close the app during "loading" and see "WebView2 control is Disposed", if you downgrade to v9 it will no happen, it will throw another exception that is not related to this problem

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

No response

SDK Version

No response

Framework

WPF

Operating System

Windows 11

OS Version

10.0.26200 Build 26200

Repro steps

After upgrading Microsoft.AspNetCore.Components.WebView.Wpf from 9.0.120 to 10.0.51, which switches the underlying control from Microsoft.Web.WebView2.Wpf.WebView2 to Microsoft.Web.WebView2.Wpf.WebView2CompositionControl, the following issues occur:

  1. During initialization, the Blazor WPF Hybrid app does not render loading coming from index.html and shows a blank screen instead. Downgrading back to v9 resolves the issue. The latest WinForms control does not exhibit this behavior.

  2. If WebView2CompositionControl is not explicitly disposed and Blazor sends IPC messages afterward, the control throws a "WebView2 control is disposed" exception, which propagates as an unhandled exception in the application.
    Steps to reproduce:
    https://github.com/ScarletKuro/WpfIssueThreading

    • Run the sample app
    • Close the app while it is still loading
    • Observe the "WebView2 control is disposed" exception

    When using v9, this issue does not occur. A different exception will be thrown, but it is unrelated to this problem (it's another one related to aspnetcore).

An argument that controls should be disposed will be valid, but before was better, and it's weird that it acts like this when the window that owned the control doesn't even exist anymore.

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

Was fine with WebView2, but seems WebView2CompositionControl behaving differently.

Last working version (if regression)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions