Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 938123003: Prevent hang monitor restarts when hidden (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 153
154 /////////////////////////////////////////////////////////////////////////////// 154 ///////////////////////////////////////////////////////////////////////////////
155 // RenderWidgetHostImpl 155 // RenderWidgetHostImpl
156 156
157 RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, 157 RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate,
158 RenderProcessHost* process, 158 RenderProcessHost* process,
159 int routing_id, 159 int routing_id,
160 bool hidden) 160 bool hidden)
161 : view_(NULL), 161 : view_(NULL),
162 renderer_initialized_(false), 162 renderer_initialized_(false),
163 hung_renderer_delay_ms_(kHungRendererDelayMs), 163 hung_renderer_delay_(
164 base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)),
164 delegate_(delegate), 165 delegate_(delegate),
165 process_(process), 166 process_(process),
166 routing_id_(routing_id), 167 routing_id_(routing_id),
167 surface_id_(0), 168 surface_id_(0),
168 is_loading_(false), 169 is_loading_(false),
169 is_hidden_(hidden), 170 is_hidden_(hidden),
170 repaint_ack_pending_(false), 171 repaint_ack_pending_(false),
171 resize_ack_pending_(false), 172 resize_ack_pending_(false),
172 screen_info_out_of_date_(false), 173 screen_info_out_of_date_(false),
173 auto_resize_enabled_(false), 174 auto_resize_enabled_(false),
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 Details<bool>(&is_visible)); 531 Details<bool>(&is_visible));
531 } 532 }
532 533
533 void RenderWidgetHostImpl::WasShown(const ui::LatencyInfo& latency_info) { 534 void RenderWidgetHostImpl::WasShown(const ui::LatencyInfo& latency_info) {
534 if (!is_hidden_) 535 if (!is_hidden_)
535 return; 536 return;
536 is_hidden_ = false; 537 is_hidden_ = false;
537 538
538 SendScreenRects(); 539 SendScreenRects();
539 540
541 // When hidden, timeout monitoring for input events is disabled. Restore it
542 // now to ensure consistent hang detection.
543 if (in_flight_event_count_)
544 RestartHangMonitorTimeout();
545
540 // Always repaint on restore. 546 // Always repaint on restore.
541 bool needs_repainting = true; 547 bool needs_repainting = true;
542 needs_repainting_on_restore_ = false; 548 needs_repainting_on_restore_ = false;
543 Send(new ViewMsg_WasShown(routing_id_, needs_repainting, latency_info)); 549 Send(new ViewMsg_WasShown(routing_id_, needs_repainting, latency_info));
544 550
545 process_->WidgetRestored(); 551 process_->WidgetRestored();
546 552
547 bool is_visible = true; 553 bool is_visible = true;
548 NotificationService::current()->Notify( 554 NotificationService::current()->Notify(
549 NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED, 555 NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED,
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 return true; 862 return true;
857 } 863 }
858 864
859 void RenderWidgetHostImpl::StartHangMonitorTimeout(base::TimeDelta delay) { 865 void RenderWidgetHostImpl::StartHangMonitorTimeout(base::TimeDelta delay) {
860 if (hang_monitor_timeout_) 866 if (hang_monitor_timeout_)
861 hang_monitor_timeout_->Start(delay); 867 hang_monitor_timeout_->Start(delay);
862 } 868 }
863 869
864 void RenderWidgetHostImpl::RestartHangMonitorTimeout() { 870 void RenderWidgetHostImpl::RestartHangMonitorTimeout() {
865 if (hang_monitor_timeout_) 871 if (hang_monitor_timeout_)
866 hang_monitor_timeout_->Restart( 872 hang_monitor_timeout_->Restart(hung_renderer_delay_);
867 base::TimeDelta::FromMilliseconds(hung_renderer_delay_ms_));
868 } 873 }
869 874
870 void RenderWidgetHostImpl::StopHangMonitorTimeout() { 875 void RenderWidgetHostImpl::StopHangMonitorTimeout() {
871 if (hang_monitor_timeout_) 876 if (hang_monitor_timeout_)
872 hang_monitor_timeout_->Stop(); 877 hang_monitor_timeout_->Stop();
873 RendererIsResponsive(); 878 RendererIsResponsive();
874 } 879 }
875 880
876 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { 881 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) {
877 ForwardMouseEventWithLatencyInfo(mouse_event, ui::LatencyInfo()); 882 ForwardMouseEventWithLatencyInfo(mouse_event, ui::LatencyInfo());
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 // We need to at least make sure that the RenderProcessHost is notified about 1208 // We need to at least make sure that the RenderProcessHost is notified about
1204 // the |is_hidden_| change, so that the renderer will have correct visibility 1209 // the |is_hidden_| change, so that the renderer will have correct visibility
1205 // set when respawned. 1210 // set when respawned.
1206 if (is_hidden_) { 1211 if (is_hidden_) {
1207 process_->WidgetRestored(); 1212 process_->WidgetRestored();
1208 is_hidden_ = false; 1213 is_hidden_ = false;
1209 } 1214 }
1210 1215
1211 // Reset this to ensure the hung renderer mechanism is working properly. 1216 // Reset this to ensure the hung renderer mechanism is working properly.
1212 in_flight_event_count_ = 0; 1217 in_flight_event_count_ = 0;
1218 StopHangMonitorTimeout();
1213 1219
1214 if (view_) { 1220 if (view_) {
1215 GpuSurfaceTracker::Get()->SetSurfaceHandle(surface_id_, 1221 GpuSurfaceTracker::Get()->SetSurfaceHandle(surface_id_,
1216 gfx::GLSurfaceHandle()); 1222 gfx::GLSurfaceHandle());
1217 view_->RenderProcessGone(status, exit_code); 1223 view_->RenderProcessGone(status, exit_code);
1218 view_ = NULL; // The View should be deleted by RenderProcessGone. 1224 view_ = NULL; // The View should be deleted by RenderProcessGone.
1219 view_weak_.reset(); 1225 view_weak_.reset();
1220 } 1226 }
1221 1227
1222 // Reconstruct the input router to ensure that it has fresh state for a new 1228 // Reconstruct the input router to ensure that it has fresh state for a new
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 return INPUT_EVENT_ACK_STATE_UNKNOWN; 1792 return INPUT_EVENT_ACK_STATE_UNKNOWN;
1787 1793
1788 if (event.type == WebInputEvent::MouseDown) 1794 if (event.type == WebInputEvent::MouseDown)
1789 OnUserGesture(); 1795 OnUserGesture();
1790 1796
1791 return view_ ? view_->FilterInputEvent(event) 1797 return view_ ? view_->FilterInputEvent(event)
1792 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; 1798 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
1793 } 1799 }
1794 1800
1795 void RenderWidgetHostImpl::IncrementInFlightEventCount() { 1801 void RenderWidgetHostImpl::IncrementInFlightEventCount() {
1796 StartHangMonitorTimeout(
1797 TimeDelta::FromMilliseconds(hung_renderer_delay_ms_));
1798 increment_in_flight_event_count(); 1802 increment_in_flight_event_count();
1803 if (!is_hidden_)
1804 StartHangMonitorTimeout(hung_renderer_delay_);
1799 } 1805 }
1800 1806
1801 void RenderWidgetHostImpl::DecrementInFlightEventCount() { 1807 void RenderWidgetHostImpl::DecrementInFlightEventCount() {
1802 if (decrement_in_flight_event_count() <= 0) { 1808 if (decrement_in_flight_event_count() <= 0) {
1803 // Cancel pending hung renderer checks since the renderer is responsive. 1809 // Cancel pending hung renderer checks since the renderer is responsive.
1804 StopHangMonitorTimeout(); 1810 StopHangMonitorTimeout();
1805 } else { 1811 } else {
1806 // The renderer is responsive, but there are in-flight events to wait for. 1812 // The renderer is responsive, but there are in-flight events to wait for.
1807 RestartHangMonitorTimeout(); 1813 if (!is_hidden_)
1814 RestartHangMonitorTimeout();
1808 } 1815 }
1809 } 1816 }
1810 1817
1811 void RenderWidgetHostImpl::OnHasTouchEventHandlers(bool has_handlers) { 1818 void RenderWidgetHostImpl::OnHasTouchEventHandlers(bool has_handlers) {
1812 has_touch_handler_ = has_handlers; 1819 has_touch_handler_ = has_handlers;
1813 } 1820 }
1814 1821
1815 void RenderWidgetHostImpl::DidFlush() { 1822 void RenderWidgetHostImpl::DidFlush() {
1816 if (synthetic_gesture_controller_) 1823 if (synthetic_gesture_controller_)
1817 synthetic_gesture_controller_->OnDidFlushInput(); 1824 synthetic_gesture_controller_->OnDidFlushInput();
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
2178 } 2185 }
2179 #endif 2186 #endif
2180 2187
2181 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { 2188 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() {
2182 if (view_) 2189 if (view_)
2183 return view_->PreferredReadbackFormat(); 2190 return view_->PreferredReadbackFormat();
2184 return kN32_SkColorType; 2191 return kN32_SkColorType;
2185 } 2192 }
2186 2193
2187 } // namespace content 2194 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/browser/renderer_host/render_widget_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698