Commit efbd67fa authored by Alexander Timin's avatar Alexander Timin Committed by Commit Bot

[scheduler] Disable load throttling for pages with active connection.

Do not apply resource load throttling to background pages with active
websocket or webrtc connection to prevent breakage and disconnects.

Change-Id: Ifd603a2b55cae415b113095df9145217da2b4196
Reviewed-on: https://chromium-review.googlesource.com/1042313Reviewed-by: default avatarTakashi Toyoshima <toyoshim@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Alexander Timin <altimin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558340}
parent 1fcd606b
...@@ -589,11 +589,19 @@ void FrameSchedulerImpl::NotifyThrottlingObservers() { ...@@ -589,11 +589,19 @@ void FrameSchedulerImpl::NotifyThrottlingObservers() {
FrameScheduler::ThrottlingState FrameSchedulerImpl::CalculateThrottlingState( FrameScheduler::ThrottlingState FrameSchedulerImpl::CalculateThrottlingState(
ObserverType type) const { ObserverType type) const {
// Detached frames are not throttled.
if (!parent_page_scheduler_)
return FrameScheduler::ThrottlingState::kNotThrottled;
if (RuntimeEnabledFeatures::StopLoadingInBackgroundEnabled() && if (RuntimeEnabledFeatures::StopLoadingInBackgroundEnabled() &&
page_frozen_ && !keep_active_) { page_frozen_ && !keep_active_) {
DCHECK(page_visibility_ == PageVisibilityState::kHidden); DCHECK(page_visibility_ == PageVisibilityState::kHidden);
return FrameScheduler::ThrottlingState::kStopped; return FrameScheduler::ThrottlingState::kStopped;
} }
if (type == ObserverType::kLoader &&
parent_page_scheduler_->HasActiveConnection()) {
return FrameScheduler::ThrottlingState::kNotThrottled;
}
if (page_visibility_ == PageVisibilityState::kHidden) if (page_visibility_ == PageVisibilityState::kHidden)
return FrameScheduler::ThrottlingState::kThrottled; return FrameScheduler::ThrottlingState::kThrottled;
return FrameScheduler::ThrottlingState::kNotThrottled; return FrameScheduler::ThrottlingState::kNotThrottled;
......
...@@ -275,6 +275,10 @@ bool PageSchedulerImpl::IsExemptFromBudgetBasedThrottling() const { ...@@ -275,6 +275,10 @@ bool PageSchedulerImpl::IsExemptFromBudgetBasedThrottling() const {
} }
bool PageSchedulerImpl::HasActiveConnectionForTest() const { bool PageSchedulerImpl::HasActiveConnectionForTest() const {
return HasActiveConnection();
}
bool PageSchedulerImpl::HasActiveConnection() const {
return has_active_connection_; return has_active_connection_;
} }
...@@ -299,6 +303,7 @@ void PageSchedulerImpl::OnConnectionUpdated() { ...@@ -299,6 +303,7 @@ void PageSchedulerImpl::OnConnectionUpdated() {
if (has_active_connection_ != has_active_connection) { if (has_active_connection_ != has_active_connection) {
has_active_connection_ = has_active_connection; has_active_connection_ = has_active_connection;
UpdateFramePolicies();
UpdateBackgroundThrottlingState(); UpdateBackgroundThrottlingState();
} }
} }
......
...@@ -75,6 +75,9 @@ class PLATFORM_EXPORT PageSchedulerImpl : public PageScheduler { ...@@ -75,6 +75,9 @@ class PLATFORM_EXPORT PageSchedulerImpl : public PageScheduler {
virtual void ReportIntervention(const std::string& message); virtual void ReportIntervention(const std::string& message);
bool IsFrozen() const; bool IsFrozen() const;
// PageSchedulerImpl::HasActiveConnection can be used in non-test code,
// while PageScheduler::HasActiveConnectionForTest can't.
bool HasActiveConnection() const;
std::unique_ptr<FrameSchedulerImpl> CreateFrameSchedulerImpl( std::unique_ptr<FrameSchedulerImpl> CreateFrameSchedulerImpl(
base::trace_event::BlameContext*, base::trace_event::BlameContext*,
......
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