Skip to content

Winforms Application crashes when WebView2 and CefSharp are used at the same time with WebView2 v121 #4702

@TurmCoder

Description

@TurmCoder

Is there an existing issue for this?

  • I have searched both open/closed issues, no issue already exists.

CefSharp Version

120.2.70

Operating System

Windows 10

Architecture

x64

.Net Version

.Net 4.7.2

Implementation

WinForms

Reproduction Steps

We have the same problem in our main application, but for reproduction purposes I created a very small windows forms test solution, consisting only of a window with a docked tablelayoutpanel inside to show both controls side by side. the exact same error occurs.
It started with Microsofts rollout of webview2 121. With webview2 120 this problem does not occur.
Microsoft stopped the rollout of webview2 and re-released it on the second of february, but we have the same problem with both versions of webview 121.

This happens only when having webview2 121 installed. Be warned, that downgrading webview2 is quite hard,
so when testing this, try webview <=120 first, before updating through windows installer or the resource download from the Microsoft update catalog:
https://www.catalog.update.microsoft.com/Search.aspx?q=Microsoft%20Edge%20WebView2%20Runtime

using System;
using System.Windows.Forms;

namespace WindowsFormsApp1;

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        var browser = new CefSharp.WinForms.ChromiumWebBrowser("https://www.google.com");
        browser.Dock = DockStyle.Fill;
        tableLayoutPanel.Controls.Add(browser, 0, 0);
        
        var webView2 = new Microsoft.Web.WebView2.WinForms.WebView2();
        webView2.Dock = DockStyle.Fill;
        webView2.Source = new Uri("https://www.google.com");
        tableLayoutPanel.Controls.Add(webView2, 1, 0);
    }
}

Expected behavior

Both controls should load and render any html.

Actual behavior

If both controls are enabled, the process crashes with following error in console:
[0202/152150.230:FATAL:hwnd_util.cc(64)] 1400
This is also the only information, that is logged into the debug.log file.

Trying to try/catch this, does not work. The client directly closing. In the windows event viewer, I can then find:

Faulting application name: WindowsFormsApp1.exe, version: 1.0.0.0, time stamp: 0xe06b492d
Faulting module name: libcef.dll, version: 120.2.7.0, time stamp: 0x65a1d154
Exception code: 0x4000001f
Fault offset: 0x044cfcd1
Faulting process id: 0x40ac
Faulting application start time: 0x01da55e34d557372
Faulting application path: C:\devel\System3\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.exe
Faulting module path: C:\devel\System3\WindowsFormsApp1\bin\Debug\libcef.dll
Report Id: 8170fe33-095e-4aac-970d-3b3aafd7aabc
Faulting package full name: 
Faulting package-relative application ID: 

When removing or commenting one or the other control, the test application runs and loads without problem.s

Regression?

No response

Known Workarounds

Downgrading WebView2 to 120 is "a workaround" but not feasible for our hundreds of customers,
because it is deployed through windows update and they are not that tech-savvy.

Does this problem also occur in the CEF Sample Application

Not Tested

Other information

I placed the libcef.dll.pdbs of version 120.2.7 next to the libcef.dll.
It did not add any additional line to the debug.log.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions