[Problem/Bug]: Crash on hibernate
What happened?
The app crashes when the PC is set to hibernate, and Crash dialog is seen the next day in office on login.
The callstack to this System.NullReferenceException as follows:
at System.Object.GetType()
at Microsoft.Web.WebView2.Core.CoreWebView2PrivateHostObjectHelper.RawHelper.<>c__DisplayClass10_0.<SetAsyncMethodContinuation>b__0()
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) in f:\dd\ndp\clr\src\BCL\system\threading\executioncontext.cs:line 980
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) in f:\dd\ndp\clr\src\BCL\system\threading\executioncontext.cs:line 928
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) in f:\dd\ndp\clr\src\BCL\system\threading\executioncontext.cs:line 917
at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at Our.Company.App.Main()
I had some crashes in async function called from the jsBridge earlier too, but this one is hitting regularly for the last few days.
Importance
Important. My app's user experience is significantly compromised.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
121.0.2277.106
SDK Version
1.0.2194-prerelease
Framework
WPF
Operating System
Windows 10
OS Version
No response
Repro steps
Happening when leaving the office and choosing "Hibernate" from the power options.
Repros in Edge Browser
No
Regression
Don't know
Last working version (if regression)
No response
Hi, @ray007!
It seems that your issue contains the word "crash". If you have not already, could you attach a crash dump as a comment?
WV2 crash dumps are located in a subfolder of the app's user data folder (UDF): <UDF>\EBWebView\Crashpad\reports\. By default, the user data folder is created in the app's folder with a name like <App Exe Name>.exe.WebView2. Refer to Crash Diagnostics for more information.
Thank you for your cooperation!
Does this folder get cleared when the app starts again? It's currently empty.
The folder shouldn't be cleared upon restart
Hi @ray007,
This is a crash in the app process, not the runtime, so dumps won't be in User Data Folder. Can you provide either of the following?
- (preferred) Dump from the application. For example, you can try to Collect Dumps on Crash
- Event Viewer log (
%SystemRoot%\System32\Winevt\Logs\Application.evtx) - A sample project where the issue can be reproduced
Thanks, Luis
No crash&debug dialog this morning, but the app still crashed and left the usual 2 lines in the event log, see attached file. appcrash.zip
Today a crash to debug from visual studio, saved minidump from there. Get it here.
I now have some more users for this, some of which are reporting the same problem with sleep and/or hibernate.
Just a few minutes ago I caught it (or a very similar looking case) in the debugger, in visual studio it also look quite similar to #3402.
For testing purposes I did a quick and dirty upgrade to .NET 8 from the currently used .NET Framework 4.7.2.
While not everything is working, the sleep/hibernate crash seems to have vanished.
Unfortunately, the main part of my app also has to work as plugin in a legacy application using .NET 4.7.x, so going with the .NET upgrade into production is currently not feasible.
Thinking about the differences between the .NET 4 and .NET 8 application, I had a new idea:
Wrap the application.Run() call in Main() with a application.Dispatcher.Invoke(...) - and suddenly the crash on sleep/hibernate seems to be gone.
Not sure why it makes a difference, maybe there's an Invoke() missing somewhere in the WebView2 .NET lib?