Browse Source

fix: Avoid crashing in NativeViewHost::SetParentAccessible on Windows 10 (#26949)

* 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 <[email protected]>
Co-authored-by: Jeremy Rose <[email protected]>
Co-authored-by: Electron Bot <[email protected]>
trop[bot] 4 years ago
parent
commit
846412cdf1

+ 1 - 0
patches/chromium/.patches

@@ -122,3 +122,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
+fix_setparentacessibile_crash_win.patch

+ 28 - 0
patches/chromium/fix_setparentacessibile_crash_win.patch

@@ -0,0 +1,28 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Biru Mohanathas <[email protected]>
+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 4779e4f07d923b5af9ba05c2765cf294e75dcc14..6112217d532251f7f6850c23be5c312a908df1e2 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);
+ }
+