Saner fallback path when RasterBuffer failed to create a GPU resource
Currently, in particular on Mac, CreateGpuMemoryBuffer can fail, in which case
we can't rasterize the corresponding tile in ZeroCopyRasterBufferImpl, and we
just create a GL texture without binding anything to it, which ends up showing
black when we display. This is somewhat problematic to emulate with SharedImage
where it is not a valid state (SharedImages must have well-defined dimensions
and format).
Instead, we handle the failure by not creating a texture at all, keeping a zero
mailbox, and falling back to OOM rendering mode (checkerboarding) for the
corresponding tile.
Bug: 882513, 554541
Change-Id: Iffd29a660f655c2dee8179fd90baa2a15ae42bf7
Reviewed-on: https://chromium-review.googlesource.com/c/1303393
Commit-Queue: Antoine Labour <piman@chromium.org>
Reviewed-by: Eric Karl <ericrk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603661}
diff --git a/cc/raster/zero_copy_raster_buffer_provider.cc b/cc/raster/zero_copy_raster_buffer_provider.cc
index 7007959..bde805a 100644
--- a/cc/raster/zero_copy_raster_buffer_provider.cc
+++ b/cc/raster/zero_copy_raster_buffer_provider.cc
@@ -81,6 +81,14 @@
gpu_memory_buffer_(std::move(backing_->gpu_memory_buffer)) {}
~ZeroCopyRasterBufferImpl() override {
+ // If GpuMemoryBuffer allocation failed (https://crbug.com/554541), then
+ // we don't have anything to give to the display compositor, so we report a
+ // zero mailbox that will result in checkerboarding.
+ if (!gpu_memory_buffer_) {
+ DCHECK(backing_->mailbox.IsZero());
+ return;
+ }
+
// This is destroyed on the compositor thread when raster is complete, but
// before the backing is prepared for export to the display compositor. So
// we can set up the texture and SyncToken here.
@@ -125,19 +133,10 @@
}
if (!backing_->image_id) {
- // If GpuMemoryBuffer allocation failed (https://crbug.com/554541), then
- // we don't have anything to give to the display compositor, but also no
- // way to report an error, so we just make a texture but don't bind
- // anything to it. Many blink layout tests on macOS fail to have no
- // |gpu_memory_buffer_| here, so any error reporting will spam console
- // logs (https://crbug.com/871031).
- if (gpu_memory_buffer_) {
- backing_->image_id = gl->CreateImageCHROMIUM(
- gpu_memory_buffer_->AsClientBuffer(), resource_size_.width(),
- resource_size_.height(), viz::GLInternalFormat(resource_format_));
- gl->BindTexImage2DCHROMIUM(backing_->texture_target,
- backing_->image_id);
- }
+ backing_->image_id = gl->CreateImageCHROMIUM(
+ gpu_memory_buffer_->AsClientBuffer(), resource_size_.width(),
+ resource_size_.height(), viz::GLInternalFormat(resource_format_));
+ gl->BindTexImage2DCHROMIUM(backing_->texture_target, backing_->image_id);
} else {
gl->ReleaseTexImage2DCHROMIUM(backing_->texture_target,
backing_->image_id);