Commit 8c2bc0ff authored by Stefan Zager's avatar Stefan Zager Committed by Commit Bot

Add CHECK to diagnose unexpected document lifecycle transition.

BUG=825854
R=bokan@chromium.org

Change-Id: Ic7533778665ce8e980b3f269d348aa0448f2bc3f
Reviewed-on: https://chromium-review.googlesource.com/1026529Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Commit-Queue: Stefan Zager <szager@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553374}
parent e18a5367
...@@ -86,7 +86,10 @@ DocumentLifecycle::DisallowThrottlingScope::~DisallowThrottlingScope() { ...@@ -86,7 +86,10 @@ DocumentLifecycle::DisallowThrottlingScope::~DisallowThrottlingScope() {
} }
DocumentLifecycle::DocumentLifecycle() DocumentLifecycle::DocumentLifecycle()
: state_(kUninitialized), detach_count_(0), disallow_transition_count_(0) {} : state_(kUninitialized),
detach_count_(0),
disallow_transition_count_(0),
check_no_transition_(false) {}
DocumentLifecycle::~DocumentLifecycle() = default; DocumentLifecycle::~DocumentLifecycle() = default;
...@@ -335,6 +338,7 @@ void DocumentLifecycle::AdvanceTo(LifecycleState next_state) { ...@@ -335,6 +338,7 @@ void DocumentLifecycle::AdvanceTo(LifecycleState next_state) {
<< "Cannot advance document lifecycle from " << StateAsDebugString(state_) << "Cannot advance document lifecycle from " << StateAsDebugString(state_)
<< " to " << StateAsDebugString(next_state) << "."; << " to " << StateAsDebugString(next_state) << ".";
#endif #endif
CHECK(state_ == next_state || !check_no_transition_);
state_ = next_state; state_ = next_state;
} }
...@@ -348,6 +352,7 @@ void DocumentLifecycle::EnsureStateAtMost(LifecycleState state) { ...@@ -348,6 +352,7 @@ void DocumentLifecycle::EnsureStateAtMost(LifecycleState state) {
<< "Cannot rewind document lifecycle from " << StateAsDebugString(state_) << "Cannot rewind document lifecycle from " << StateAsDebugString(state_)
<< " to " << StateAsDebugString(state) << "."; << " to " << StateAsDebugString(state) << ".";
#endif #endif
CHECK(state_ == state || !check_no_transition_);
state_ = state; state_ = state;
} }
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h" #include "third_party/blink/renderer/platform/wtf/allocator.h"
#include "third_party/blink/renderer/platform/wtf/assertions.h" #include "third_party/blink/renderer/platform/wtf/assertions.h"
#include "third_party/blink/renderer/platform/wtf/auto_reset.h"
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
#include "third_party/blink/renderer/platform/wtf/forward.h" #include "third_party/blink/renderer/platform/wtf/forward.h"
...@@ -196,6 +197,17 @@ class CORE_EXPORT DocumentLifecycle { ...@@ -196,6 +197,17 @@ class CORE_EXPORT DocumentLifecycle {
DocumentLifecycle& document_lifecycle_; DocumentLifecycle& document_lifecycle_;
}; };
class CheckNoTransitionScope {
STACK_ALLOCATED();
public:
explicit CheckNoTransitionScope(DocumentLifecycle& document_lifecycle)
: auto_reset_(&document_lifecycle.check_no_transition_, true) {}
private:
AutoReset<bool> auto_reset_;
};
DocumentLifecycle(); DocumentLifecycle();
~DocumentLifecycle(); ~DocumentLifecycle();
...@@ -233,6 +245,7 @@ class CORE_EXPORT DocumentLifecycle { ...@@ -233,6 +245,7 @@ class CORE_EXPORT DocumentLifecycle {
#endif #endif
private: private:
friend class PostponeTransitionScope; friend class PostponeTransitionScope;
friend class CheckNoTransitionScope;
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
bool CanAdvanceTo(LifecycleState) const; bool CanAdvanceTo(LifecycleState) const;
bool CanRewindTo(LifecycleState) const; bool CanRewindTo(LifecycleState) const;
...@@ -245,6 +258,7 @@ class CORE_EXPORT DocumentLifecycle { ...@@ -245,6 +258,7 @@ class CORE_EXPORT DocumentLifecycle {
int detach_count_; int detach_count_;
int disallow_transition_count_; int disallow_transition_count_;
bool life_cycle_postponed_; bool life_cycle_postponed_;
bool check_no_transition_;
DISALLOW_COPY_AND_ASSIGN(DocumentLifecycle); DISALLOW_COPY_AND_ASSIGN(DocumentLifecycle);
}; };
......
...@@ -1078,28 +1078,32 @@ void LocalFrameView::PerformLayout(bool in_subtree_layout) { ...@@ -1078,28 +1078,32 @@ void LocalFrameView::PerformLayout(bool in_subtree_layout) {
// functions so that a single human could understand what layout() is actually // functions so that a single human could understand what layout() is actually
// doing. // doing.
if (in_subtree_layout) { {
if (analyzer_) { // TODO(szager): Remove this after diagnosing crash.
analyzer_->Increment(LayoutAnalyzer::kPerformLayoutRootLayoutObjects, DocumentLifecycle::CheckNoTransitionScope check_no_transition(Lifecycle());
layout_subtree_root_list_.size()); if (in_subtree_layout) {
} if (analyzer_) {
for (auto& root : layout_subtree_root_list_.Ordered()) { analyzer_->Increment(LayoutAnalyzer::kPerformLayoutRootLayoutObjects,
if (!root->NeedsLayout()) layout_subtree_root_list_.size());
continue; }
LayoutFromRootObject(*root); for (auto& root : layout_subtree_root_list_.Ordered()) {
if (!root->NeedsLayout())
// We need to ensure that we mark up all layoutObjects up to the continue;
// LayoutView for paint invalidation. This simplifies our code as we LayoutFromRootObject(*root);
// just always do a full tree walk.
if (LayoutObject* container = root->Container()) // We need to ensure that we mark up all layoutObjects up to the
container->SetMayNeedPaintInvalidation(); // LayoutView for paint invalidation. This simplifies our code as we
// just always do a full tree walk.
if (LayoutObject* container = root->Container())
container->SetMayNeedPaintInvalidation();
}
layout_subtree_root_list_.Clear();
} else {
if (HasOrthogonalWritingModeRoots() &&
!RuntimeEnabledFeatures::LayoutNGEnabled())
LayoutOrthogonalWritingModeRoots();
GetLayoutView()->UpdateLayout();
} }
layout_subtree_root_list_.Clear();
} else {
if (HasOrthogonalWritingModeRoots() &&
!RuntimeEnabledFeatures::LayoutNGEnabled())
LayoutOrthogonalWritingModeRoots();
GetLayoutView()->UpdateLayout();
} }
frame_->GetDocument()->Fetcher()->UpdateAllImageResourcePriorities(); frame_->GetDocument()->Fetcher()->UpdateAllImageResourcePriorities();
......
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