From dd859c2f25b7e8e2ee810f2bfd0b3c346c1fe023 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Fri, 11 Dec 2020 12:51:05 -0800 Subject: [PATCH] fix: Avoid crashing in NativeViewHost::SetParentAccessible on Windows 10 (#26950) * fix: Avoid crashing in NativeViewHost::SetParentAccessible on Windows This fixes #26905. The patch was obtained from @deepak1556, who in turn got it from the Microsoft Teams folks. I believe the crash started happening due to the changes in https://chromium.googlesource.com/chromium/src.git/+/5c6c8e994bce2bfb867279ae5068e9f9134e70c3%5E!/#F15 This affects Electron 9 and later. Notes: Fix occasional crash on Windows * Update .patches * update patches Co-authored-by: Biru Mohanathas Co-authored-by: Jeremy Rose Co-authored-by: Electron Bot --- patches/chromium/.patches | 1 + .../fix_setparentacessibile_crash_win.patch | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 patches/chromium/fix_setparentacessibile_crash_win.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 276844e65b1d7..b30131f2b480d 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -163,3 +163,4 @@ cherry-pick-bbc6ab5bb49c.patch backport_1142331.patch backport_1151865.patch cherry-pick-ecdec1fb0f42.patch +fix_setparentacessibile_crash_win.patch diff --git a/patches/chromium/fix_setparentacessibile_crash_win.patch b/patches/chromium/fix_setparentacessibile_crash_win.patch new file mode 100644 index 0000000000000..10957b7cbe281 --- /dev/null +++ b/patches/chromium/fix_setparentacessibile_crash_win.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Biru Mohanathas +Date: Thu, 10 Dec 2020 19:02:37 +0200 +Subject: fix crash in NativeViewHost::SetParentAccessible + +This fixes random crashes on Windows 10. It presumably started happening +after the changes in +https://chromium.googlesource.com/chromium/src.git/+/5c6c8e994bce2bfb867279ae5068e9f9134e70c3%5E!/#F15 + +For context, see: https://github.com/electron/electron/issues/26905 + +This patch can likely be upstreamed. The crash cannot be fixed without +patching something in Chromium - this is the least invasive change. + +diff --git a/ui/views/controls/native/native_view_host.cc b/ui/views/controls/native/native_view_host.cc +index b29553ae8f7b0f8bff44bb74b725dab5d5b9fa59..f51fa29c6d76623d58c0f4eb633b26fdddc30d55 100644 +--- a/ui/views/controls/native/native_view_host.cc ++++ b/ui/views/controls/native/native_view_host.cc +@@ -54,6 +54,9 @@ void NativeViewHost::Detach() { + } + + void NativeViewHost::SetParentAccessible(gfx::NativeViewAccessible accessible) { ++ if (!native_wrapper_.get()) ++ return; ++ + native_wrapper_->SetParentAccessible(accessible); + } +