From a7cc9723262daebd4e44db4482b838c88d56a0a6 Mon Sep 17 00:00:00 2001 From: Alex Maitland Date: Wed, 21 Aug 2024 18:42:31 +1000 Subject: [PATCH] WPF/OffScreen - NullReferenceException in the WaitForRenderIdleAsync method - Catch and throw exception back onto the calling thread so it doesn't crash the app Resovles #4902 --- CefSharp.OffScreen/ChromiumWebBrowser.cs | 4 ++++ CefSharp.Wpf/ChromiumWebBrowser.cs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CefSharp.OffScreen/ChromiumWebBrowser.cs b/CefSharp.OffScreen/ChromiumWebBrowser.cs index 7d4e02f24c..28ce08ff53 100644 --- a/CefSharp.OffScreen/ChromiumWebBrowser.cs +++ b/CefSharp.OffScreen/ChromiumWebBrowser.cs @@ -762,6 +762,10 @@ public async Task WaitForRenderIdleAsync(int idleTimeInMs = 500, TimeSpan? timeo // the same time, the timer maybe Disposed on a different thread. // https://github.com/cefsharp/CefSharp/issues/4597 } + catch(Exception ex) + { + renderIdleTcs.TrySetException(ex); + } }; idleTimer.Start(); diff --git a/CefSharp.Wpf/ChromiumWebBrowser.cs b/CefSharp.Wpf/ChromiumWebBrowser.cs index 3af233711f..4358c0606b 100644 --- a/CefSharp.Wpf/ChromiumWebBrowser.cs +++ b/CefSharp.Wpf/ChromiumWebBrowser.cs @@ -2754,6 +2754,10 @@ public async Task WaitForRenderIdleAsync(int idleTimeInMs = 500, TimeSpan? timeo // the same time, the timer maybe Disposed on a different thread. // https://github.com/cefsharp/CefSharp/issues/4597 } + catch (Exception ex) + { + renderIdleTcs.TrySetException(ex); + } }; idleTimer.Start();