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

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: 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // frame to complete. 175 // frame to complete.
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. Note that on some platforms (10.9),
186 while (!previous_frame_fence_->HasCompleted()) { 186 // fences appear to sometimes get lost and will naver pass. Add a 32ms
ccameron 2016/06/13 22:16:14 s/naver/never
ericrk 2016/06/13 22:23:14 Done.
187 // timout to prevent these situations from causing a GPU process hang.
188 int timeout = 32;
ccameron 2016/06/13 22:16:14 s/timeout/timeout_msec
ericrk 2016/06/13 22:23:14 Done.
189 while (!previous_frame_fence_->HasCompleted() && timeout > 0) {
190 --timeout;
187 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1)); 191 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(1));
188 } 192 }
193 if (!previous_frame_fence_->HasCompleted()) {
194 // We timed out waiting for the above fence, just issue a glFinish.
195 glFinish();
196 }
189 } 197 }
190 198
191 // Create a fence for the current frame's work and save the context. 199 // Create a fence for the current frame's work and save the context.
192 previous_frame_fence_.reset(gl::GLFence::Create()); 200 previous_frame_fence_.reset(gl::GLFence::Create());
193 fence_context_obj_.reset(CGLGetCurrentContext(), 201 fence_context_obj_.reset(CGLGetCurrentContext(),
194 base::scoped_policy::RETAIN); 202 base::scoped_policy::RETAIN);
195 203
196 // A glFlush is necessary to ensure correct content appears. 204 // A glFlush is necessary to ensure correct content appears.
197 glFlush(); 205 glFlush();
198 206
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask; 363 gl_renderer_id_ = context_renderer_id & kCGLRendererIDMatchingMask;
356 364
357 // Post a task holding a reference to the new GL context. The reason for 365 // 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 366 // this is to avoid creating-then-destroying the context for every image
359 // transport surface that is observing the GPU switch. 367 // transport surface that is observing the GPU switch.
360 base::MessageLoop::current()->PostTask( 368 base::MessageLoop::current()->PostTask(
361 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu)); 369 FROM_HERE, base::Bind(&IOSurfaceContextNoOp, context_on_new_gpu));
362 } 370 }
363 371
364 } // namespace gpu 372 } // 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