Commit 48d98205 authored by Jonathan Ross's avatar Jonathan Ross Committed by Commit Bot

Fix Mac ContextLost Surface Sync Crash

On Mac there is a race between the Browser resizing and a Renderer
reconnecting to a frame sink.

Due to this the Browser can end up sending a merge LocalSurfaceId to the
Renderer, which it already used for a previous size.

This is in part because on Mac we are currently accepting all resize
requests from child Renderers. Which is not what we do on other
platforms. This change updates BrowserCompositorViewMac to only merge
LocalSurfaceIds, and to not change the sizes, when requested. Unless
auto_resize is enabled on the RenderWidgetHostImpl. This is also inline
with RenderWidgetHostViewMac::UpdateNSViewAndDisplayProperties

TEST= ContextLost_WebGLContextLostFromGPUProcessExit
      ContextLost_WebGLUnblockedAfterUserInitiatedReload
      GpuCrash_GPUProcessCrashesExactlyOncePerVisitToAboutGpuCrash

Bug: 1031095

Change-Id: Ie8ef6283ec36169f422af10831001b7c0ee757f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1975014Reviewed-by: default avatarYuly Novikov <ynovikov@chromium.org>
Reviewed-by: default avatarSaman Sami <samans@chromium.org>
Reviewed-by: default avatarccameron <ccameron@chromium.org>
Commit-Queue: Jonathan Ross <jonross@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728629}
parent 4ada619d
...@@ -82,6 +82,7 @@ class CONTENT_EXPORT BrowserCompositorMac : public DelegatedFrameHostClient, ...@@ -82,6 +82,7 @@ class CONTENT_EXPORT BrowserCompositorMac : public DelegatedFrameHostClient,
// Update the renderer's SurfaceId to reflect |new_size_in_pixels| in // Update the renderer's SurfaceId to reflect |new_size_in_pixels| in
// anticipation of the NSView resizing during auto-resize. // anticipation of the NSView resizing during auto-resize.
void UpdateSurfaceFromChild( void UpdateSurfaceFromChild(
bool auto_resize_enabled,
float new_device_scale_factor, float new_device_scale_factor,
const gfx::Size& new_size_in_pixels, const gfx::Size& new_size_in_pixels,
const viz::LocalSurfaceIdAllocation& child_local_surface_id_allocation); const viz::LocalSurfaceIdAllocation& child_local_surface_id_allocation);
......
...@@ -150,20 +150,23 @@ bool BrowserCompositorMac::UpdateSurfaceFromNSView( ...@@ -150,20 +150,23 @@ bool BrowserCompositorMac::UpdateSurfaceFromNSView(
} }
void BrowserCompositorMac::UpdateSurfaceFromChild( void BrowserCompositorMac::UpdateSurfaceFromChild(
bool auto_resize_enabled,
float new_device_scale_factor, float new_device_scale_factor,
const gfx::Size& new_size_in_pixels, const gfx::Size& new_size_in_pixels,
const viz::LocalSurfaceIdAllocation& child_local_surface_id_allocation) { const viz::LocalSurfaceIdAllocation& child_local_surface_id_allocation) {
if (dfh_local_surface_id_allocator_.UpdateFromChild( if (dfh_local_surface_id_allocator_.UpdateFromChild(
child_local_surface_id_allocation)) { child_local_surface_id_allocation)) {
dfh_display_.set_device_scale_factor(new_device_scale_factor); if (auto_resize_enabled) {
dfh_size_dip_ = gfx::ConvertSizeToDIP(dfh_display_.device_scale_factor(), dfh_display_.set_device_scale_factor(new_device_scale_factor);
new_size_in_pixels); dfh_size_dip_ = gfx::ConvertSizeToDIP(dfh_display_.device_scale_factor(),
dfh_size_pixels_ = new_size_in_pixels; new_size_in_pixels);
root_layer_->SetBounds(gfx::Rect(dfh_size_dip_)); dfh_size_pixels_ = new_size_in_pixels;
if (recyclable_compositor_) { root_layer_->SetBounds(gfx::Rect(dfh_size_dip_));
recyclable_compositor_->UpdateSurface(dfh_size_pixels_, if (recyclable_compositor_) {
dfh_display_.device_scale_factor(), recyclable_compositor_->UpdateSurface(
dfh_display_.color_space()); dfh_size_pixels_, dfh_display_.device_scale_factor(),
dfh_display_.color_space());
}
} }
delegated_frame_host_->EmbedSurface( delegated_frame_host_->EmbedSurface(
dfh_local_surface_id_allocator_.GetCurrentLocalSurfaceIdAllocation() dfh_local_surface_id_allocator_.GetCurrentLocalSurfaceIdAllocation()
......
...@@ -846,7 +846,8 @@ void RenderWidgetHostViewMac::EnsureSurfaceSynchronizedForWebTest() { ...@@ -846,7 +846,8 @@ void RenderWidgetHostViewMac::EnsureSurfaceSynchronizedForWebTest() {
void RenderWidgetHostViewMac::OnDidUpdateVisualPropertiesComplete( void RenderWidgetHostViewMac::OnDidUpdateVisualPropertiesComplete(
const cc::RenderFrameMetadata& metadata) { const cc::RenderFrameMetadata& metadata) {
browser_compositor_->UpdateSurfaceFromChild( browser_compositor_->UpdateSurfaceFromChild(
metadata.device_scale_factor, metadata.viewport_size_in_pixels, host()->auto_resize_enabled(), metadata.device_scale_factor,
metadata.viewport_size_in_pixels,
metadata.local_surface_id_allocation.value_or( metadata.local_surface_id_allocation.value_or(
viz::LocalSurfaceIdAllocation())); viz::LocalSurfaceIdAllocation()));
} }
......
...@@ -43,11 +43,6 @@ crbug.com/609629 [ android qualcomm-adreno-(tm)-420 ] GpuCrash_GPUProcessCrashes ...@@ -43,11 +43,6 @@ crbug.com/609629 [ android qualcomm-adreno-(tm)-420 ] GpuCrash_GPUProcessCrashes
crbug.com/609629 [ android qualcomm-adreno-(tm)-420 ] ContextLost_WebGLContextLostFromGPUProcessExit [ Skip ] crbug.com/609629 [ android qualcomm-adreno-(tm)-420 ] ContextLost_WebGLContextLostFromGPUProcessExit [ Skip ]
crbug.com/609629 [ android qualcomm-adreno-(tm)-420 ] ContextLost_WebGLContextLostInHiddenTab [ Skip ] crbug.com/609629 [ android qualcomm-adreno-(tm)-420 ] ContextLost_WebGLContextLostInHiddenTab [ Skip ]
# RetryOnFailure flaky mac test until root cause can be investigated.
crbug.com/965268 [ mac ] ContextLost_WebGLUnblockedAfterUserInitiatedReload [ RetryOnFailure ]
crbug.com/1031095 [ mac ] GpuCrash_GPUProcessCrashesExactlyOncePerVisitToAboutGpuCrash [ RetryOnFailure ]
crbug.com/1031567 [ mac ] ContextLost_WebGLContextLostFromGPUProcessExit [ RetryOnFailure ]
# Mac NVIDIA only uses the low-power GPU. # Mac NVIDIA only uses the low-power GPU.
crbug.com/681341 [ mac nvidia ] ContextLost_MacWebGLMultisamplingHighPowerSwitchLosesContext [ Skip ] crbug.com/681341 [ mac nvidia ] ContextLost_MacWebGLMultisamplingHighPowerSwitchLosesContext [ Skip ]
crbug.com/681341 [ mac nvidia ] ContextLost_MacWebGLPreserveDBHighPowerSwitchLosesContext [ Skip ] crbug.com/681341 [ mac nvidia ] ContextLost_MacWebGLPreserveDBHighPowerSwitchLosesContext [ Skip ]
......
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