Commit 38ec3f40 authored by Patrick To's avatar Patrick To Committed by Commit Bot

Fix crash in GraphicsDelegateWin when the GL context generates an error

GraphicsDelegateWin creates GL resources in PreRender and deletes them
in PostRender. If errors are generated in PreRender, PostRender still
tries to delete them, which fires a DCHECK.

This change returns false from PreRender if there are any errors in
the GL context. In this case, the current overlay pose is ignored in
VRBrowserRendererThreadWin.

Bug: 1090957
Change-Id: I7aa4d3b1b0eb26ad571d9de396f3ef2a569c2382
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2259232
Commit-Queue: Patrick To <patrto@microsoft.com>
Reviewed-by: default avatarAlexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781572}
parent 6cc68f72
......@@ -74,16 +74,16 @@ gfx::Rect GraphicsDelegateWin::GetTextureSize() {
return gfx::Rect(width, height);
}
void GraphicsDelegateWin::PreRender() {
bool GraphicsDelegateWin::PreRender() {
if (!gl_)
return;
return false;
BindContext();
gfx::Rect size = GetTextureSize();
// Create a memory buffer, and an image referencing that memory buffer.
if (!EnsureMemoryBuffer(size.width(), size.height()))
return;
return false;
// Create a texture id, and associate it with our image.
gl_->GenTextures(1, &dest_texture_id_);
......@@ -100,6 +100,15 @@ void GraphicsDelegateWin::PreRender() {
gl_->BindFramebuffer(GL_DRAW_FRAMEBUFFER, draw_frame_buffer_);
gl_->FramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, dest_texture_id_, 0);
if (gl_->GetError() != GL_NO_ERROR) {
// Clear any remaining GL errors.
while (gl_->GetError() != GL_NO_ERROR) {
}
return false;
}
return true;
}
void GraphicsDelegateWin::PostRender() {
......
......@@ -43,7 +43,7 @@ class GraphicsDelegateWin : public GraphicsDelegate {
void InitializeOnGLThread();
void SetVRDisplayInfo(device::mojom::VRDisplayInfoPtr info);
void Cleanup();
void PreRender();
bool PreRender();
void PostRender();
mojo::PlatformHandle GetTexture();
gfx::RectF GetLeft();
......
......@@ -412,6 +412,9 @@ void VRBrowserRendererThreadWin::OnPose(int request_id,
return;
}
if (!graphics_->PreRender())
return;
data = ValidateFrameData(data);
// Deliver pose to input and scheduler.
......@@ -435,7 +438,6 @@ void VRBrowserRendererThreadWin::OnPose(int request_id,
head_from_unoriented_head * unoriented_head_from_world;
input_->OnPose(head_from_world);
graphics_->PreRender();
// base::Unretained is safe because scheduler_ will be destroyed without
// calling the callback if we are destroyed.
......
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