Closed applefanbois closed 1 year ago
Hello @applefanbois,
Could you please provide some general info related to:
Thanks! Victor
-Latest update of Windows 10 Pro version 22H2 build 19045.2311 -Not sure MS changed then name 10x over the past 5 years : Universal App-> UWP -> Reunion-> Win32? -> WinUI3 not sure about the name.
Microsoft.Windows.SDK.BuildTools 10.0.22621.755 Microsoft.WindowsAppSDK 1.2.221116.1 Microsoft Edge WebView2 Runtime 107.0.1418.42
Running into the same issue here, which makes modifying the context menu impossible.
Thanks for the report, we will look into this.
@applefanbois @simon-knuth Looking into this now. Do you have a project you can share that's running into this issue? Also @simon-knuth , is this on WinUI3 for you as well?
Do a right click in the bing.com input box and you will see that MainWindows.xaml.cs->onContextMenuRequested will crash, even if you put a breakpoint in it before it does anything.
@srwei Yes, I'm referring to WinUI3 as well.
@applefanbois @simon-knuth Apologize for the delay on this. I'm able to repro the crash on Microsoft.WindowsAppSDK 1.2.221116.1 that contains our WebView2 SDK 1.0.1185.39. It looks like I can't repro the crash anymore in our 1.0.1245.22 SDK, which is picked up in the later WinAppSDK version. Can you try updating to the WinAppSDK version 1.3.230331000 and see if you still hit the crash? Thanks.
It does not crash, but when you attach that callback, the context menu will never appear ever again.
I can see that as well on my local WinUI3 app. It seems that when I right click near the edge of the webview window, part of it is visible outside the window. This is the case even when I don't add the Context menu handler, removing webView.CoreWebView2.ContextMenuRequested += WebView_ContextMenuRequested;. Can you confirm if you're seeing the same thing?
If you are seeing the same thing, there seems to be a separate Visual hosting bug. For now, you can workaround this in WinUI3 by setting environment variable WEBVIEW2_USE_VISUAL_HOSTING_FOR_OWNED_WINDOWS to 1. @applefanbois
Environment.SetEnvironmentVariable("WEBVIEW2_USE_VISUAL_HOSTING_FOR_OWNED_WINDOWS", "1");
is working for me, thank you @srwei
webView.CoreWebView2.ContextMenuRequested += WebView_ContextMenuRequested;
void WebView_ContextMenuRequested( object sender, CoreWebView2ContextMenuRequestedEventArgs args) { //Crash here even if you do nothing here }
I copied the sample code from MS but when the event actually trigger, it will crash the app. Weirder, if you put a break point inside that function it will go there, but trying to see or inspect args will crash the app. Never seen such a behaviour where the IDE will trigger the app to crash just for daring to inspect a variable.
AB#43157934