Bug 1059793 - Mark the compositor's gl context destroyed before the widget is gone. r=jgilbert
authorNicolas Silva <nsilva@mozilla.com>
Tue, 02 Sep 2014 14:05:00 +0200
changeset 202978 c98b1e8ca69a2ced2e5175044b185270882bdeb7
parent 202977 bb6876120191ca14dea7500609d2c1cebddac39c
child 202979 c412208c484102629b65d5ef17b5af77ac124d54
push id48540
push usernsilva@mozilla.com
push dateTue, 02 Sep 2014 12:05:24 +0000
treeherdermozilla-inbound@c98b1e8ca69a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1059793
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1059793 - Mark the compositor's gl context destroyed before the widget is gone. r=jgilbert
gfx/gl/GLContext.h
gfx/layers/opengl/CompositorOGL.cpp
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -2636,16 +2636,19 @@ protected:
                        bool isOffscreen = false);
 
 
 // -----------------------------------------------------------------------------
 // Destructor
 public:
     virtual ~GLContext();
 
+    // Mark this context as destroyed.  This will nullptr out all
+    // the GL function pointers!
+    void MarkDestroyed();
 
 // -----------------------------------------------------------------------------
 // Everything that isn't standard GL APIs
 protected:
     typedef gfx::SurfaceFormat SurfaceFormat;
 
     virtual bool MakeCurrentImpl(bool aForce) = 0;
 
@@ -2678,20 +2681,16 @@ public:
     }
 
     virtual bool Init() = 0;
 
     virtual bool SetupLookupFunction() = 0;
 
     virtual void ReleaseSurface() {}
 
-    // Mark this context as destroyed.  This will nullptr out all
-    // the GL function pointers!
-    void MarkDestroyed();
-
     bool IsDestroyed() {
         // MarkDestroyed will mark all these as null.
         return mSymbols.fUseProgram == nullptr;
     }
 
     GLContext *GetSharedContext() { return mSharedContext; }
 
     /**
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -168,16 +168,23 @@ CompositorOGL::CleanupResources()
 
   ctx->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0);
 
   if (mQuadVBO) {
     ctx->fDeleteBuffers(1, &mQuadVBO);
     mQuadVBO = 0;
   }
 
+  // On the main thread the Widget will be destroyed soon and calling MakeCurrent
+  // after that could cause a crash (at least with GLX, see bug 1059793), unless
+  // context is marked as destroyed.
+  // There may be some textures still alive that will try to call MakeCurrent on
+  // the context so let's make sure it is marked destroyed now.
+  mGLContext->MarkDestroyed();
+
   mGLContext = nullptr;
 }
 
 bool
 CompositorOGL::Initialize()
 {
   bool force = gfxPrefs::LayersAccelerationForceEnabled();