Commit 057d1bbd authored by ccameron@chromium.org's avatar ccameron@chromium.org

Reduce the scope of CGL current contexts

There are a few crash reports coming in where the destructor
~ScopedCGLSetCurrentContext is being implicated inside
CompositorSwapBuffers. Reduce the scope of the 
ScopedCGLSetCurrentContext in CompositorSwapBuffers.

At a minimum, this will make the crash reports reveal which
place is causing problems. At a maximum, this may fix the
issue (in particular, LayoutLayers may call displayIfNeeded,
which may mess with the current context, potentially causing
crashes, as ScopedCGLSetCurrentContext does not expect
this).

BUG=245900
NOTRY=true

Review URL: https://codereview.chromium.org/216733002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260448 0039d316-1c4b-4281-b951-d872f2087c98
parent 620db8a9
......@@ -1363,13 +1363,15 @@ void RenderWidgetHostViewMac::CompositorSwapBuffers(
// Make the context current and update the IOSurface with the handle
// passed in by the swap command.
gfx::ScopedCGLSetCurrentContext scoped_set_current_context(
compositing_iosurface_context_->cgl_context());
if (!compositing_iosurface_->SetIOSurfaceWithContextCurrent(
compositing_iosurface_context_, surface_handle, size,
surface_scale_factor)) {
LOG(ERROR) << "Failed SetIOSurface on CompositingIOSurfaceMac";
return;
{
gfx::ScopedCGLSetCurrentContext scoped_set_current_context(
compositing_iosurface_context_->cgl_context());
if (!compositing_iosurface_->SetIOSurfaceWithContextCurrent(
compositing_iosurface_context_, surface_handle, size,
surface_scale_factor)) {
LOG(ERROR) << "Failed SetIOSurface on CompositingIOSurfaceMac";
return;
}
}
// Grab video frames now that the IOSurface has been set up. Note that this
......@@ -1384,12 +1386,14 @@ void RenderWidgetHostViewMac::CompositorSwapBuffers(
&frame, &callback)) {
// Flush the context that updated the IOSurface, to ensure that the
// context that does the copy picks up the correct version.
glFlush();
{
gfx::ScopedCGLSetCurrentContext scoped_set_current_context(
compositing_iosurface_context_->cgl_context());
glFlush();
}
compositing_iosurface_->CopyToVideoFrame(
gfx::Rect(size), frame,
base::Bind(callback, present_time));
DCHECK_EQ(CGLGetCurrentContext(),
compositing_iosurface_context_->cgl_context());
frame_was_captured = true;
}
}
......@@ -1447,6 +1451,8 @@ void RenderWidgetHostViewMac::CompositorSwapBuffers(
compositing_iosurface_layer_async_timer_.Reset();
[compositing_iosurface_layer_ gotNewFrame];
} else {
gfx::ScopedCGLSetCurrentContext scoped_set_current_context(
compositing_iosurface_context_->cgl_context());
DrawIOSurfaceWithoutCoreAnimation();
}
......
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