Crash Caused by Re-Entrancy Due to Call to m_coreWebViewController.IsVisible(...) #10305
Open
Description
Describe the bug
When using WebView2 from XAML, there is an intermittent crash due to re-entrancy. This results when calling CoreWebView2Controller::IsVisible, which calls ShowWindow, which pumps messages.
Steps to reproduce the bug
I don't have a minimal repro, but can share the relevant part of the stack:
ntdll!KiUserCallbackDispatcherContinue
win32u!ZwUserShowWindow+0x14
EmbeddedBrowserWebView!embedded_browser_webview_current::Controller::SyncVisibility+0x64
EmbeddedBrowserWebView!embedded_browser_webview_current::Controller::put_IsVisible+0xb7
Microsoft_Web_WebView2_Core!winrt::Microsoft::Web::WebView2::Core::implementation::CoreWebView2Controller::IsVisible+0x57
Microsoft_Web_WebView2_Core!winrt::impl::produce<winrt::Microsoft::Web::WebView2::Core::implementation::CoreWebView2Controller,winrt::Microsoft::Web::WebView2::Core::ICoreWebView2Controller>::put_IsVisible+0x60
Microsoft_UI_Xaml_Controls!winrt::impl::consume_Microsoft_UI_Xaml_IUIElementOverrides<winrt::Microsoft::UI::Xaml::IUIElementOverrides>::OnDisconnectVisualChildren+0x14
Microsoft_UI_Xaml_Controls!WebView2::UpdateCoreWebViewVisibility::__l10::<lambda_2>::operator()+0x12
Microsoft_UI_Xaml_Controls!WebView2::CoreWebView2RunIgnoreInvalidStateSync<`WebView2::UpdateCoreWebViewVisibility'::`10'::<lambda_2> >+0x16
Microsoft_UI_Xaml_Controls!WebView2::UpdateCoreWebViewVisibility+0xed
Per @codendone, the fix here is to add a PauseNewDispatch
around the call to m_coreWebViewController.IsVisible(...)
.
Expected behavior
The application should not crash.
Screenshots
No response
NuGet package version
None
Windows version
Windows 11 (23H2): Build 22631
Additional context
No response