Skip to content

Commit 66d0d01

Browse files
authored
fix: Fix reset when window.close is called OS-18755 (#90)
Fix reset when window.close is called OS-18755 If an html page calls window.close we end up getting a reset in View::GetTransformRelativeTo. This issue has been found to be caused by View::ConvertPointFromWidget being called after the View has been freed (i.e. pointer use after being freed). The exact sequence of events and what is the top level method that results in calling ConvertPointFromWidget for a view after its been freed is not possible to work out, due to the back trace in all the dumps not showing where the call came from. However, by adding traces in the code it was found that WebContentsView::NonClientHitTest calls View::ConvertPointFromWidget in this scenario and is always done so in the error case after WebContentsView::WebContentsDestroyed. Although this is not the root cause of the issue, this was a good place to a fix where we check that api_web_contents_ is not null in WebContentsView::NonClientHitTest before calling View::ConvertPointFromWidget.
1 parent 6e9c0ed commit 66d0d01

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

shell/browser/api/electron_api_web_contents_view.cc

+6-4
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ gin::Handle<WebContents> WebContentsView::GetWebContents(v8::Isolate* isolate) {
5454

5555
int WebContentsView::NonClientHitTest(const gfx::Point& point) {
5656
gfx::Point local_point(point);
57-
views::View::ConvertPointFromWidget(view(), &local_point);
58-
SkRegion* region = api_web_contents_->draggable_region();
59-
if (region && region->contains(local_point.x(), local_point.y()))
60-
return HTCAPTION;
57+
if (api_web_contents_) {
58+
views::View::ConvertPointFromWidget(view(), &local_point);
59+
SkRegion* region = api_web_contents_->draggable_region();
60+
if (region && region->contains(local_point.x(), local_point.y()))
61+
return HTCAPTION;
62+
}
6163
return HTNOWHERE;
6264
}
6365

0 commit comments

Comments
 (0)