Commit b102e647 authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

[ozone/wayland] Fix NativeGpuMemoryBuffers usage.

After https://crrev.com/c/1570014, Chromium started to
crash immediately because of null accelerated widget provided
to the WaylandBufferManager and hitting data validation
error when --enable-native-gpu-memory-buffer with
the --enable-gpu-rasterization passed.

The problem was that the raster buffer provided can
create a staging buffer for rasterization, which is not
tight to any of the existing widgets. Thus, it seems like
it just passes a null widget [1][2].

But, when the GbmPixmapWayland was created and the dmabuf handle
was passed to the WaylandBufferManager to import a wl_buffer,
it crashed on the data validation, because the widget was null.

Thus, when a null widget is passed, just create a native pixmap
and do not call the WaylandBufferManager with a request to import
a wl_buffer as long as they can also be used as staging buffers
and not meant for attaching to Wayland surfaces.

[1] https://cs.chromium.org/chromium/src/cc/raster/one_copy_raster_buffer_provider.cc?type=cs&g=0&l=296
[2] https://cs.chromium.org/chromium/src/cc/raster/zero_copy_raster_buffer_provider.cc?type=cs&g=0&l=125

Bug: 962466
Change-Id: Ied6fd6d3e29fdd21939c8b159682537f9239ab84
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1609781Reviewed-by: default avatarRobert Kroeger <rjkroege@chromium.org>
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Cr-Commit-Position: refs/heads/master@{#659575}
parent 6fa0695c
......@@ -35,7 +35,7 @@ GbmPixmapWayland::GbmPixmapWayland(WaylandSurfaceFactory* surface_manager,
widget_(widget) {}
GbmPixmapWayland::~GbmPixmapWayland() {
if (gbm_bo_)
if (gbm_bo_ && widget_ != gfx::kNullAcceleratedWidget)
connection_->DestroyZwpLinuxDmabuf(widget_, GetUniqueId());
}
......@@ -80,7 +80,10 @@ bool GbmPixmapWayland::InitializeBuffer(gfx::Size size,
return false;
}
CreateZwpLinuxDmabuf();
// The pixmap can be created as a staging buffer and not be mapped to any of
// the existing widgets.
if (widget_ != gfx::kNullAcceleratedWidget)
CreateZwpLinuxDmabuf();
return true;
}
......
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