MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
452 stars 55 forks source link

WebView2 DevToolsProtocolEventReceiver crashes #2017

Open minesworld opened 2 years ago

minesworld commented 2 years ago

Description

webView.CoreWebView2.GetDevToolsProtocolEventReceiver("Overlay.nodeHighlightRequested").DevToolsProtocolEventReceived += OnOverlayNodeHighlightRequested;
webView.CoreWebView2.GetDevToolsProtocolEventReceiver("Overlay.inspectNodeRequested").DevToolsProtocolEventReceived += OnInspectNodeRequested;

await webView.CoreWebView2.CallDevToolsProtocolMethodAsync("DOM.enable", "{}");                
await webView.CoreWebView2.CallDevToolsProtocolMethodAsync("Overlay.enable", "{}");         
await webView.CoreWebView2.CallDevToolsProtocolMethodAsync("Overlay.setInspectMode", "{\"mode\":\"searchForNode\",\"highlightConfig\":{\"showInfo\":true,\"contentColor\":{\"r\": 155, \"g\": 11, \"b\": 239, \"a\": 0.7}}}");

receiving the inpectNodeRequested stops working after some time or it will crash.

Exception thrown at 0x00007FF8C32FF3F0 (Microsoft.Web.WebView2.Core.dll) in WinUI3.exe: 0xC0000005: Access violation writing location 0x00000001000002C7.

00007FF8C32FF3B6  call        qword ptr [rax+8]  
00007FF8C32FF3B9  nop  
00007FF8C32FF3BA  lea         rax,[winrt::impl::heap_implements<winrt::Microsoft::Web::WebView2::Core::implementation::CoreWebView2DevToolsProtocolEventReceivedEventArgs>::`vftable' (07FF8C3343028h)]  
00007FF8C32FF3C1  mov         qword ptr [rbx],rax  
00007FF8C32FF3C4  mov         qword ptr [rsp+28h],rdi  
00007FF8C32FF3C9  mov         rsi,qword ptr [r15]  
00007FF8C32FF3CC  mov         qword ptr [rsp+20h],r14  
00007FF8C32FF3D1  lea         rcx,[rsi+28h]  
00007FF8C32FF3D5  call        AcquireSRWLockExclusive (07FF8C3333897h)  
00007FF8C32FF3DA  mov         rdi,qword ptr [rsi+20h]  
00007FF8C32FF3DE  lea         rcx,[rsi+28h]  
00007FF8C32FF3E2  test        rdi,rdi  
00007FF8C32FF3E5  je          <lambda_1614a4de527adbc7ae79ce87febc4e38>::operator()+19Dh (07FF8C32FF49Dh)  
00007FF8C32FF3EB  mov         qword ptr [rsp+20h],rdi  
00007FF8C32FF3F0  lock xadd   dword ptr [rdi],ebp  
00007FF8C32FF3F4  call        ReleaseSRWLockExclusive (07FF8C3333891h)

Version SDK: 1.0.0 Runtime: WinRT.Runtime 1.3.0.0, Microsoft.Windows.SDK.NET 10.0.19041.21 Framework: WindowsAppSDK OS: Win11

Repro Steps

  1. Sample VS2022 project in https://github.com/minesworld/WebView2Tests

  2. Crash reports (copy & paste) in folder crashes

  3. Build & Start WinUI3 project

  4. Select some options: 4.1. "Async": second async call to intialize the WebView2 4.2. "DT-Overlay": enable Developer Tools Overlay mode 4.3. "DT-Event": receive Overlay events 4.4. "WebMessage": run a JavaScript interval function and receive them 4.5 "Navigation": receive NagivationComplete events

  5. Press "Start" Button

  6. watch Debug/Diagnostic output

  7. if DT-Overlay & DT-Event checked and clicking does not bring up a new output line, click "No DT-Event" button to have this logged

  8. do some clicks, wait, use another app, etc. . Crashes come unexpected, but it seems to depend on the website (my "favorite" for crashing: https://www.bundestag.de/abgeordnete/biografien )

Besides the crash:

Expeced Behaviour

Additional context filed also as https://github.com/microsoft/WindowsAppSDK/issues/1911

AB#37414485

champnic commented 2 years ago

Thanks for the bug report @minesworld! I've opened this as a bug on our backlog to take a look.