From b4c1e54ed38d8d0ab6e3edbf6370e589bf0f4c7f Mon Sep 17 00:00:00 2001 From: Biru Mohanathas Date: Fri, 11 Dec 2020 19:47:55 +0200 Subject: [PATCH] fix: Avoid crashing in NativeViewHost::SetParentAccessible on Windows (#26924) --- 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 f13b242c28df9..7a2bb32902233 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -103,3 +103,4 @@ fix_use_electron_generated_resources.patch chore_expose_v8_initialization_isolate_callbacks.patch export_gin_v8platform_pageallocator_for_usage_outside_of_the_gin.patch use_public_apis_to_determine_if_a_font_is_a_system_font_in_mas_build.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..502100cab95eb --- /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 f9e1aa1b455ae49b59d53a75ae0634d0c092a130..4785f0c0368e0ab22db0cc968ad85d23a9b26240 100644 +--- a/ui/views/controls/native/native_view_host.cc ++++ b/ui/views/controls/native/native_view_host.cc +@@ -55,6 +55,9 @@ void NativeViewHost::Detach() { + } + + void NativeViewHost::SetParentAccessible(gfx::NativeViewAccessible accessible) { ++ if (!native_wrapper_.get()) ++ return; ++ + native_wrapper_->SetParentAccessible(accessible); + } +