Commit 021019a1 authored by Daniel Cheng's avatar Daniel Cheng Committed by Chromium LUCI CQ

Centralize hack to avoid double-detaching an already detached main frame

Bug: 1154141
Change-Id: I8996510a69ca1fe1b6d4f1affca9a431961ac1cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2577762Reviewed-by: default avatarFergal Daly <fergal@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834549}
parent ec9f86b2
...@@ -2111,15 +2111,6 @@ bool LocalFrame::IsProvisional() const { ...@@ -2111,15 +2111,6 @@ bool LocalFrame::IsProvisional() const {
// this state can no longer be accurately calculated. // this state can no longer be accurately calculated.
CHECK(!IsDetached()); CHECK(!IsDetached());
// TODO(https://crbug.com/838348): Sadly, there are situations where Blink may
// attempt to detach a main frame twice due to a bug. That rewinds
// FrameLifecycle from kDetached to kDetaching, but GetPage() will already be
// null. Early returning false in that case is "safe enough", as the frame has
// already been detached, so any detach work gated on IsProvisional() has
// already been done.
if (!GetPage())
return false;
if (IsMainFrame()) { if (IsMainFrame()) {
return GetPage()->MainFrame() != this; return GetPage()->MainFrame() != this;
} }
......
...@@ -955,7 +955,15 @@ void Page::WillCloseAnimationHost(LocalFrameView* view) { ...@@ -955,7 +955,15 @@ void Page::WillCloseAnimationHost(LocalFrameView* view) {
void Page::WillBeDestroyed() { void Page::WillBeDestroyed() {
Frame* main_frame = main_frame_; Frame* main_frame = main_frame_;
main_frame->Detach(FrameDetachType::kRemove); // TODO(https://crbug.com/838348): Sadly, there are situations where Blink may
// attempt to detach a main frame twice due to a bug. That rewinds
// FrameLifecycle from kDetached to kDetaching, but GetPage() will already be
// null. Since Detach() has already happened, just skip the actual Detach()
// call to try to limit the side effects of this bug on the rest of frame
// detach.
if (main_frame->GetPage()) {
main_frame->Detach(FrameDetachType::kRemove);
}
DCHECK(AllPages().Contains(this)); DCHECK(AllPages().Contains(this));
AllPages().erase(this); AllPages().erase(this);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment