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

Unified Diff: content/browser/aura/gpu_process_transport_factory.cc

Issue 23055007: aura: Fix raciness in context loss and recreation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/layers/texture_layer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/aura/gpu_process_transport_factory.cc
diff --git a/content/browser/aura/gpu_process_transport_factory.cc b/content/browser/aura/gpu_process_transport_factory.cc
index 06057138de699d92d887327d23330346e59fec6a..b740c5c5cea85c4f43fd9f08675fd94eb673d686 100644
--- a/content/browser/aura/gpu_process_transport_factory.cc
+++ b/content/browser/aura/gpu_process_transport_factory.cc
@@ -74,6 +74,7 @@ class OwnedTexture : public ui::Texture, ImageTransportFactoryObserver {
// ImageTransportFactory overrides:
virtual void OnLostResources() OVERRIDE {
DeleteTexture();
+ host_context_ = NULL;
}
protected:
@@ -90,9 +91,8 @@ class OwnedTexture : public ui::Texture, ImageTransportFactoryObserver {
}
}
- // A raw pointer. This |ImageTransportClientTexture| will be destroyed
- // before the |host_context_| via
- // |ImageTransportFactoryObserver::OnLostContext()| handlers.
+ // The OnLostResources() callback will happen before this context
+ // pointer is destroyed.
WebKit::WebGraphicsContext3D* host_context_;
unsigned texture_id_;
@@ -387,8 +387,11 @@ void GpuProcessTransportFactory::RemoveObserver(
scoped_refptr<cc::ContextProvider>
GpuProcessTransportFactory::OffscreenContextProviderForMainThread() {
- if (!shared_contexts_main_thread_.get() ||
- shared_contexts_main_thread_->DestroyedOnMainThread()) {
+ // Don't check for DestroyedOnMainThread() here. We hear about context
+ // loss for this context through the lost context callback. If the context
+ // is lost, we want to leave this ContextProvider available until the lost
+ // context notification is sent to the ImageTransportFactoryObserver clients.
+ if (!shared_contexts_main_thread_.get()) {
shared_contexts_main_thread_ = ContextProviderCommandBuffer::Create(
GpuProcessTransportFactory::CreateOffscreenCommandBufferContext());
if (shared_contexts_main_thread_) {
@@ -406,8 +409,10 @@ GpuProcessTransportFactory::OffscreenContextProviderForMainThread() {
scoped_refptr<cc::ContextProvider>
GpuProcessTransportFactory::OffscreenContextProviderForCompositorThread() {
- if (!shared_contexts_compositor_thread_.get() ||
- shared_contexts_compositor_thread_->DestroyedOnMainThread()) {
+ // The lifetime of this context is tied to the main thread context so that
+ // they are always in the same share group. So do not check for
+ // DestroyedOnMainThread().
+ if (!shared_contexts_compositor_thread_.get()) {
shared_contexts_compositor_thread_ = ContextProviderCommandBuffer::Create(
GpuProcessTransportFactory::CreateOffscreenCommandBufferContext());
}
@@ -493,18 +498,29 @@ void GpuProcessTransportFactory::OnLostMainThreadSharedContextInsideCallback() {
void GpuProcessTransportFactory::OnLostMainThreadSharedContext() {
LOG(ERROR) << "Lost UI shared context.";
+
// Keep old resources around while we call the observers, but ensure that
// new resources are created if needed.
+ // Kill shared contexts for both threads in tandom so they are always in
piman 2013/08/22 01:14:48 nit: s/tandom/tandem/
danakj 2013/08/22 01:18:04 Done.
+ // the same share group.
- scoped_refptr<ContextProviderCommandBuffer> old_contexts_main_thread =
+ scoped_refptr<cc::ContextProvider> lost_shared_contexts_main_thread =
shared_contexts_main_thread_;
+ scoped_refptr<cc::ContextProvider> lost_shared_contexts_compositor_thread =
+ shared_contexts_compositor_thread_;
shared_contexts_main_thread_ = NULL;
+ shared_contexts_compositor_thread_ = NULL;
- scoped_ptr<GLHelper> old_helper(gl_helper_.release());
+ scoped_ptr<GLHelper> lost_gl_helper = gl_helper_.Pass();
FOR_EACH_OBSERVER(ImageTransportFactoryObserver,
observer_list_,
OnLostResources());
+
+ // Kill things that use the shared context before killing the shared context.
+ lost_gl_helper.reset();
+ lost_shared_contexts_main_thread = NULL;
+ lost_shared_contexts_compositor_thread = NULL;
}
} // namespace content
« no previous file with comments | « cc/layers/texture_layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698