Skip to content

Commit

Permalink
fix: Avoid crashing in NativeViewHost::SetParentAccessible on Windows…
Browse files Browse the repository at this point in the history
… 10 (#26951)

* 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

Co-authored-by: Biru Mohanathas <birunthan@mohanathas.com>
Co-authored-by: Electron Bot <electron@github.com>
  • Loading branch information
3 people committed Dec 11, 2020
1 parent 5942c84 commit d58812b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions patches/chromium/.patches
Expand Up @@ -106,3 +106,4 @@ cherry-pick-8f5a08079948.patch
cherry-pick-275865e8c237.patch
use_public_apis_to_determine_if_a_font_is_a_system_font_in_mas_build.patch
cherry-pick-47e21abe349a.patch
fix_setparentacessibile_crash_win.patch
28 changes: 28 additions & 0 deletions patches/chromium/fix_setparentacessibile_crash_win.patch
@@ -0,0 +1,28 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Biru Mohanathas <birunthan@mohanathas.com>
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 d8e5cf4ddb625519863837544c2f91b4e015029b..e1c2e2e41eed722a7989bc8e97e2ea73119b1f70 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);
}

0 comments on commit d58812b

Please sign in to comment.