Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(889)

Side by Side Diff: gpu/ipc/service/image_transport_surface_overlay_mac.mm

Issue 2064853002: Add timeout to swap fence (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: feedback Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/ipc/service/image_transport_surface_overlay_mac.h" 5 #include "gpu/ipc/service/image_transport_surface_overlay_mac.h"
6 6
7 #include <CoreGraphics/CoreGraphics.h> 7 #include <CoreGraphics/CoreGraphics.h>
8 #include <IOSurface/IOSurface.h> 8 #include <IOSurface/IOSurface.h>
9 #include <OpenGL/CGLRenderers.h> 9 #include <OpenGL/CGLRenderers.h>
10 #include <OpenGL/CGLTypes.h> 10 #include <OpenGL/CGLTypes.h>
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 if (previous_frame_fence_) { 176 if (previous_frame_fence_) {
177 TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::ClientWait"); 177 TRACE_EVENT0("gpu", "ImageTransportSurfaceOverlayMac::ClientWait");
178 178
179 // Ensure we are using the context with which the fence was created. 179 // Ensure we are using the context with which the fence was created.
180 gl::ScopedCGLSetCurrentContext scoped_set_current(fence_context_obj_); 180 gl::ScopedCGLSetCurrentContext scoped_set_current(fence_context_obj_);
181 181
182 // While we could call GLFence::ClientWait, this performs a busy wait on 182 // While we could call GLFence::ClientWait, this performs a busy wait on
183 // Mac, leading to high CPU usage. Instead we poll with a 1ms delay. This 183 // Mac, leading to high CPU usage. Instead we poll with a 1ms delay. This
184 // should have minimal impact, as we will only hit this path when we are 184 // should have minimal impact, as we will only hit this path when we are
185 // more than one frame (16ms) behind. 185 // more than one frame (16ms) behind.
186 while (!previous_frame_fence_->HasCompleted()) { 186 //
187 // Note that on some platforms (10.9), fences appear to sometimes get
188 // lost and will never pass. Add a 32ms timout to prevent these
189 // situations from causing a GPU process hang. crbug.com/618075
190 int timeout_msec = 32;
191 while (!previous_frame_fence_->HasCompleted() && timeout_msec > 0) {
192 --timeout_msec;
187 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); 193 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1));
188 } 194 }
195 if (!previous_frame_fence_->HasCompleted()) {
196 // We timed out waiting for the above fence, just issue a glFinish.
197 glFinish();
198 }
189 } 199 }
190 200
191 // Create a fence for the current frame's work and save the context. 201 // Create a fence for the current frame's work and save the context.
192 previous_frame_fence_.reset(gl::GLFence::Create()); 202 previous_frame_fence_.reset(gl::GLFence::Create());
193 fence_context_obj_.reset(CGLGetCurrentContext(), 203 fence_context_obj_.reset(CGLGetCurrentContext(),
194 base::scoped_policy::RETAIN); 204 base::scoped_policy::RETAIN);
195 205
196 // A glFlush is necessary to ensure correct content appears. 206 // A glFlush is necessary to ensure correct content appears.
197 glFlush(); 207 glFlush();
198 208
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask; 365 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask;
356 366
357 // Post a task holding a reference to the new GL context. The reason for 367 // Post a task holding a reference to the new GL context. The reason for
358 // this is to avoid creating-then-destroying the context for every image 368 // this is to avoid creating-then-destroying the context for every image
359 // transport surface that is observing the GPU switch. 369 // transport surface that is observing the GPU switch.
360 base::MessageLoop::current()->PostTask( 370 base::MessageLoop::current()->PostTask(
361 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu)); 371 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu));
362 } 372 }
363 373
364 } // namespace gpu 374 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698