Commit 833ce076 authored by Alex Rudenko's avatar Alex Rudenko Committed by Commit Bot

Rename throttling reset variable and reduce throttling time

Renaming the variable that controls if the overlay will be repainted
ignoring the throttling for clarity and reducing the throttling time
to 50ms to reduce lags.

Change-Id: Ifca6c5e0badf2978fce595604e19082233bac8ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2401034Reviewed-by: default avatarPeter Marshall <petermarshall@chromium.org>
Reviewed-by: default avatarMathias Bynens <mathias@chromium.org>
Commit-Queue: Alex Rudenko <alexrudenko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805692}
parent 6ea9bf60
...@@ -993,15 +993,18 @@ void InspectorOverlayAgent::PaintOverlayPage() { ...@@ -993,15 +993,18 @@ void InspectorOverlayAgent::PaintOverlayPage() {
if (!view || !frame) if (!view || !frame)
return; return;
// Throttling rendering to avoid high CPU usage on highly active pages
// (animations). If force_overlay_paint_ is true, we rerender even if the last
// paint was less than 50ms ago.
auto now = base::Time::Now(); auto now = base::Time::Now();
if (!backend_node_id_changed_ && if (!force_overlay_paint_ &&
now - last_paint_time_ < base::TimeDelta::FromMilliseconds(100)) { now - last_paint_time_ < base::TimeDelta::FromMilliseconds(50)) {
OverlayMainFrame()->View()->UpdateAllLifecyclePhases( OverlayMainFrame()->View()->UpdateAllLifecyclePhases(
DocumentUpdateReason::kInspector); DocumentUpdateReason::kInspector);
return; return;
} }
if (backend_node_id_changed_) { if (force_overlay_paint_) {
backend_node_id_changed_ = false; force_overlay_paint_ = false;
} }
last_paint_time_ = now; last_paint_time_ = now;
...@@ -1287,7 +1290,7 @@ void InspectorOverlayAgent::Inspect(Node* inspected_node) { ...@@ -1287,7 +1290,7 @@ void InspectorOverlayAgent::Inspect(Node* inspected_node) {
DOMNodeId backend_node_id = DOMNodeIds::IdForNode(node); DOMNodeId backend_node_id = DOMNodeIds::IdForNode(node);
if (!enabled_.Get()) { if (!enabled_.Get()) {
backend_node_id_to_inspect_ = backend_node_id; backend_node_id_to_inspect_ = backend_node_id;
backend_node_id_changed_ = true; force_overlay_paint_ = true;
return; return;
} }
...@@ -1317,7 +1320,6 @@ Response InspectorOverlayAgent::setInspectMode( ...@@ -1317,7 +1320,6 @@ Response InspectorOverlayAgent::setInspectMode(
return response; return response;
inspect_mode_.Set(mode); inspect_mode_.Set(mode);
inspect_mode_protocol_config_.Set(serialized_config); inspect_mode_protocol_config_.Set(serialized_config);
PickTheRightTool(); PickTheRightTool();
return Response::Success(); return Response::Success();
} }
...@@ -1388,6 +1390,7 @@ void InspectorOverlayAgent::SetInspectTool(InspectTool* inspect_tool) { ...@@ -1388,6 +1390,7 @@ void InspectorOverlayAgent::SetInspectTool(InspectTool* inspect_tool) {
if (!hinge_) if (!hinge_)
DisableFrameOverlay(); DisableFrameOverlay();
} }
force_overlay_paint_ = true;
ScheduleUpdate(); ScheduleUpdate();
} }
......
...@@ -301,7 +301,7 @@ class CORE_EXPORT InspectorOverlayAgent final ...@@ -301,7 +301,7 @@ class CORE_EXPORT InspectorOverlayAgent final
InspectorAgentState::String inspect_mode_; InspectorAgentState::String inspect_mode_;
InspectorAgentState::Bytes inspect_mode_protocol_config_; InspectorAgentState::Bytes inspect_mode_protocol_config_;
base::Time last_paint_time_; base::Time last_paint_time_;
bool backend_node_id_changed_; bool force_overlay_paint_;
DISALLOW_COPY_AND_ASSIGN(InspectorOverlayAgent); DISALLOW_COPY_AND_ASSIGN(InspectorOverlayAgent);
}; };
......
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