-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebView2 crash on startup #3117
Comments
For searchability, here's the full call stack for me:
|
I just tried upgrading to WinAppSDK 1.2 (non-preview) and I get the same crash. What's odd is that the WinUI 3 Gallery app has a WebView2 example which works fine with WinAppSDK 1.2. |
I get this crash with 1.2 and just a TextBox. |
@asklar What Windows version are you on? I'm on Win 10 21H2 (19044) and I'm also able to repro with TextBox. I'm wondering if this is a Win 10 only issue. |
This is on windows 11. I'm talking to the folks on the team, @codendone is investigating. |
this looks like a bug in imm32 where it doesn't properly reinitialize itself if it is loaded, unloaded, then re-loaded. The fix is to not unload it in the first place. The unload happens "for free" in generated code, so to work around it for the time being: In pch.h, add: #define DISABLE_XAML_GENERATED_MAIN Then in app.xaml.cpp, add: int __stdcall wWinMain(HINSTANCE, HINSTANCE, PWSTR, int)
{
{
void (WINAPI * pfnXamlCheckProcessRequirements)();
auto module = ::LoadLibrary(L"Microsoft.ui.xaml.dll");
if (module)
{
pfnXamlCheckProcessRequirements = reinterpret_cast<decltype(pfnXamlCheckProcessRequirements)>(GetProcAddress(module, "XamlCheckProcessRequirements"));
if (pfnXamlCheckProcessRequirements)
{
(*pfnXamlCheckProcessRequirements)();
}
// ::FreeLibrary(module);
}
}
winrt::init_apartment(winrt::apartment_type::single_threaded);
::winrt::Microsoft::UI::Xaml::Application::Start(
[](auto&&)
{
::winrt::make<::winrt::CompletionControlTest::implementation::App>();
});
return 0;
} Note the call to |
@asklar any idea under what conditions this crash occurs? I have a WinUI 3 app where I have that |
@lyahdav if imm32 gets loaded before XAML by something else (e.g. user32, or you manually link to it, etc.), then the bug wouldn't repro. The bug happens when imm32 gets unloaded because the only outstanding loader reference gets released. |
For us it was becoming a blocker issue to migrating to WinAppSDK 1.2. Thank you verymuch @asklar for the temporary solution. |
🎉 Handy links: |
Describe the bug
After following the guide here to set up WebView2 with WinAppSDK here and upgrading the WinAppSDK version to 1.2.220930.4-preview2, the WebView2 crashes on startup.
Output Error:
Exception thrown at 0x00007FFC8506407A (imm32.dll) in WebView2Simple.exe: 0xC0000005: Access violation reading location 0x0000000000000000.
Callstack traces back to EmbeddedBrowserWebView.dll Initialize()
This error does not occur in the latest stable version 1.1.5.
Steps to reproduce the bug
Expected behavior
For WebView2 to startup and show webpage.
Screenshots
No response
NuGet package version
1.2.220930.4-preview2
Packaging type
No response
Windows version
Insider Build (xxxxx)
IDE
Visual Studio 2022
Additional context
No response
The text was updated successfully, but these errors were encountered: