Commit 19ab802b authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Freezing on load.

In change https://crrev.com/0daefdcf34ba9a8c21ab907b2159c5652169a45b
caused a dcheck failure occasionally because of an implicit open of a
document inside an implicit close while running the
wpt/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/abort-while-navigating.window.html
wpt test.

See: https://chromium-swarm.appspot.com/task?id=44fb7387f8411e10
for the failure.

https://chromium-review.googlesource.com/c/chromium/src/+/1628499
reverted the original code so this is a reland of some of that code.

Because of the complexity of that value use a simpler
approach and use the Frame::IsLoading attribute instead which doesn't
exhibit these cycles.

BUG=907125

Change-Id: Ifb805cf8ab90b6a228f47d88cb2ee872d9a21239
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1626956
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664344}
parent ebd0df00
......@@ -3471,8 +3471,6 @@ void RenderFrameHostImpl::OnDidStopLoading() {
// of this RenderFrameHost is being tracked.
if (is_active())
frame_tree_node_->DidStopLoading();
UpdateFrameFrozenState();
}
void RenderFrameHostImpl::OnDidChangeLoadProgress(double load_progress) {
......@@ -6926,10 +6924,6 @@ RenderFrameHostImpl::BuildNavigationClientCommitFailedNavigationCallback(
}
void RenderFrameHostImpl::UpdateFrameFrozenState() {
// If the document is in the loading state keep it still loading.
if (is_loading_)
return;
if (!IsFeatureEnabled(
blink::mojom::FeaturePolicyFeature::kExecutionWhileNotRendered) &&
visibility_ == blink::mojom::FrameVisibility::kNotRendered) {
......
......@@ -1703,8 +1703,19 @@ void LocalFrame::UnpauseContext() {
}
void LocalFrame::SetLifecycleState(mojom::FrameLifecycleState state) {
// If we have asked to be frozen we will only do this once the
// load event has fired.
if ((state == mojom::FrameLifecycleState::kFrozen ||
state == mojom::FrameLifecycleState::kFrozenAutoResumeMedia) &&
IsLoading()) {
pending_lifecycle_state_ = state;
return;
}
pending_lifecycle_state_ = base::nullopt;
if (state == lifecycle_state_)
return;
bool is_frozen = lifecycle_state_ != mojom::FrameLifecycleState::kRunning;
bool freeze = state != mojom::FrameLifecycleState::kRunning;
......@@ -1762,4 +1773,13 @@ void LocalFrame::CountUseIfFeatureWouldBeBlockedByFeaturePolicy(
}
}
void LocalFrame::FinishedLoading() {
DomWindow()->FinishedLoading();
if (pending_lifecycle_state_) {
DCHECK(!IsLoading());
SetLifecycleState(pending_lifecycle_state_.value());
}
}
} // namespace blink
......@@ -433,6 +433,8 @@ class CORE_EXPORT LocalFrame final : public Frame,
mojom::WebFeature blocked_cross_origin,
mojom::WebFeature blocked_same_origin);
void FinishedLoading();
private:
friend class FrameNavigationDisabler;
......@@ -564,6 +566,7 @@ class CORE_EXPORT LocalFrame final : public Frame,
mojom::FrameLifecycleState lifecycle_state_ =
mojom::FrameLifecycleState::kRunning;
base::Optional<mojom::FrameLifecycleState> pending_lifecycle_state_;
};
inline FrameLoader& LocalFrame::Loader() const {
......
......@@ -414,7 +414,7 @@ void FrameLoader::DidFinishNavigation() {
RestoreScrollPositionAndViewState();
if (document_loader_)
document_loader_->SetLoadType(WebFrameLoadType::kStandard);
frame_->DomWindow()->FinishedLoading();
frame_->FinishedLoading();
}
Frame* parent = frame_->Tree().Parent();
......
......@@ -1083,7 +1083,6 @@
},
{
name: "PauseExecutionContextOnBackgroundFreeze",
status: "experimental",
},
{
name: "PaymentApp",
......
<!DOCTYPE html>
<meta charset="utf-8">
<img src="/common/slow.py">
<script>
window.addEventListener('load', () => {
window.parent.postMessage('load');
......
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