From b174a32e23c82001aae7cf8177dc1d5cbb95f003 Mon Sep 17 00:00:00 2001 From: Biru Mohanathas Date: Thu, 10 Dec 2020 19:09:01 +0200 Subject: [PATCH 1/3] 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 --- patches/chromium/.patches | 3 ++ .../fix_setparentacessibile_crash_win.patch | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 patches/chromium/fix_setparentacessibile_crash_win.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 9ffcbfe7bc61d..92b149d38db4c 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -121,3 +121,6 @@ cherry-pick-5ffbb7ed173a.patch ui_check_that_unpremultiply_is_passed_a_32bpp_image.patch cherry-pick-ecdec1fb0f42.patch merge_m86_ensure_that_buffers_used_by_imagedecoder_haven_t_been.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); + } + From 7edc8ff36191393eb97f971ebe74d48a7708f78e Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Fri, 11 Dec 2020 10:00:42 -0800 Subject: [PATCH 2/3] Update .patches --- patches/chromium/.patches | 2 -- 1 file changed, 2 deletions(-) diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 92b149d38db4c..2acd19d512ba5 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -121,6 +121,4 @@ cherry-pick-5ffbb7ed173a.patch ui_check_that_unpremultiply_is_passed_a_32bpp_image.patch cherry-pick-ecdec1fb0f42.patch merge_m86_ensure_that_buffers_used_by_imagedecoder_haven_t_been.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 From 8ac73fd2adbc08deb5ffca785b49725d17348068 Mon Sep 17 00:00:00 2001 From: Electron Bot Date: Fri, 11 Dec 2020 18:11:51 +0000 Subject: [PATCH 3/3] update patches --- patches/chromium/fix_setparentacessibile_crash_win.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patches/chromium/fix_setparentacessibile_crash_win.patch b/patches/chromium/fix_setparentacessibile_crash_win.patch index 502100cab95eb..9e1a8c3b403f7 100644 --- a/patches/chromium/fix_setparentacessibile_crash_win.patch +++ b/patches/chromium/fix_setparentacessibile_crash_win.patch @@ -13,10 +13,10 @@ 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 +index 4779e4f07d923b5af9ba05c2765cf294e75dcc14..6112217d532251f7f6850c23be5c312a908df1e2 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() { +@@ -54,6 +54,9 @@ void NativeViewHost::Detach() { } void NativeViewHost::SetParentAccessible(gfx::NativeViewAccessible accessible) {