Index: chrome/browser/renderer_host/render_widget_host_view_mac.mm |
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm |
index bf4ce950865f2af8515c63ac99c92a43520098c6..68cfce0b844a679230fdc9c0ef43071552332e81 100644 |
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm |
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm |
@@ -574,6 +574,7 @@ void RenderWidgetHostViewMac::RenderViewGone(base::TerminationStatus status, |
} |
void RenderWidgetHostViewMac::Destroy() { |
+ TRACE_EVENT0("browser", "RenderWidgetHostViewMac::Destroy"); |
// On Windows, popups are implemented with a popup window style, so that when |
// an event comes in that would "cancel" it, it receives the OnCancelMode |
// message and can kill itself. Alas, on the Mac, views cannot capture events |
@@ -703,6 +704,9 @@ RenderWidgetHostViewMac::AllocateFakePluginWindowHandle(bool opaque, |
// Create an NSView to host the plugin's/compositor's pixels. |
gfx::PluginWindowHandle handle = |
plugin_container_manager_.AllocateFakePluginWindowHandle(opaque, root); |
+ TRACE_EVENT1("browser", |
+ "RenderWidgetHostViewMac::AllocateFakePluginWindowHandle", |
+ "window", handle); |
scoped_nsobject<AcceleratedPluginView> plugin_view( |
[[AcceleratedPluginView alloc] initWithRenderWidgetHostViewMac:this |
@@ -718,6 +722,9 @@ RenderWidgetHostViewMac::AllocateFakePluginWindowHandle(bool opaque, |
void RenderWidgetHostViewMac::DestroyFakePluginWindowHandle( |
gfx::PluginWindowHandle window) { |
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ TRACE_EVENT1("browser", |
+ "RenderWidgetHostViewMac::DestroyFakePluginWindowHandle", |
+ "window", window); |
PluginViewMap::iterator it = plugin_views_.find(window); |
DCHECK(plugin_views_.end() != it); |
if (plugin_views_.end() == it) { |
@@ -734,6 +741,9 @@ void RenderWidgetHostViewMac::DestroyFakePluginWindowHandle( |
// This is called by AcceleratedPluginView's -dealloc. |
void RenderWidgetHostViewMac::DeallocFakePluginWindowHandle( |
gfx::PluginWindowHandle window) { |
+ TRACE_EVENT1("browser", |
+ "RenderWidgetHostViewMac::DeallocFakePluginWindowHandle", |
+ "window", window); |
// When a browser window with a GpuScheduler is closed, the render process |
// will attempt to finish all GL commands. It will busy-wait on the GPU |
// process until the command queue is empty. If a paint is pending, the GPU |
@@ -759,7 +769,6 @@ void RenderWidgetHostViewMac::DeallocFakePluginWindowHandle( |
AcceleratedPluginView* RenderWidgetHostViewMac::ViewForPluginWindowHandle( |
gfx::PluginWindowHandle window) { |
PluginViewMap::iterator it = plugin_views_.find(window); |
- DCHECK(plugin_views_.end() != it); |
if (plugin_views_.end() == it) |
return nil; |
return it->second; |
@@ -810,23 +819,34 @@ void RenderWidgetHostViewMac::AcceleratedSurfaceBuffersSwapped( |
int32 route_id, |
int gpu_host_id, |
uint64 swap_buffers_count) { |
- TRACE_EVENT0("browser", |
- "RenderWidgetHostViewMac::AcceleratedSurfaceBuffersSwapped"); |
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ TRACE_EVENT2("browser", |
+ "RenderWidgetHostViewMac::AcceleratedSurfaceBuffersSwapped", |
+ "window", window, |
+ "frame", swap_buffers_count); |
+ |
AcceleratedPluginView* view = ViewForPluginWindowHandle(window); |
- DCHECK(view); |
- if (!view) |
- return; |
+ if (!view) { |
+ // TODO: Fix the root cause of invalid PluginWindowHandles. |
+ LOG(ERROR) << "ViewForPluginWindowHandle returned NULL. " |
+ << "Did the renderer specify an invalid PluginWindowHandle?"; |
+ } else { |
+ plugin_container_manager_.SetSurfaceWasPaintedTo(window, surface_id); |
+ |
+ // The surface is hidden until its first paint, to not show gargabe. |
+ if (plugin_container_manager_.SurfaceShouldBeVisible(window)) |
+ [view setHidden:NO]; |
- plugin_container_manager_.SetSurfaceWasPaintedTo(window, surface_id); |
+ // Present the frame. |
+ [view drawView]; |
+ } |
- // The surface is hidden until its first paint, to not show gargabe. |
- if (plugin_container_manager_.SurfaceShouldBeVisible(window)) |
- [view setHidden:NO]; |
- [view updateSwapBuffersCount:swap_buffers_count |
- fromRenderer:renderer_id |
- routeId:route_id |
- gpuHostId:gpu_host_id]; |
+ // Always acknowledge swap buffers to avoid renderer->GPU deadlocks. |
+ if (renderer_id != 0 || route_id != 0) |
+ AcknowledgeSwapBuffers(renderer_id, |
+ route_id, |
+ gpu_host_id, |
+ swap_buffers_count); |
} |
void RenderWidgetHostViewMac::UpdateRootGpuViewVisibility( |
@@ -863,8 +883,8 @@ void RenderWidgetHostViewMac::AcknowledgeSwapBuffers( |
int32 route_id, |
int gpu_host_id, |
uint64 swap_buffers_count) { |
- TRACE_EVENT1("gpu", "RenderWidgetHostViewMac::AcknowledgeSwapBuffers", |
- "swap_buffers_count", swap_buffers_count); |
+ TRACE_EVENT1("browser", "RenderWidgetHostViewMac::AcknowledgeSwapBuffers", |
+ "frame", swap_buffers_count); |
// Called on the display link thread. Hand actual work off to the IO thread, |
// because |GpuProcessHost::Get()| can only be called there. |
// Currently, this is never called for plugins. |
@@ -1545,7 +1565,6 @@ void RenderWidgetHostViewMac::SetTextInputActive(bool active) { |
DCHECK(view); |
if (view && ![view isHidden]) { |
NSRect frame = [view frame]; |
- frame.size = [view cachedSize]; |
gpuRect = [self flipNSRectToRect:frame]; |
} |
} |