Bug 1366941 - Checking LayersIPCChannel type when using recycled textureClient; r=nical
☠☠ backed out by f89ae1cf86fb ☠ ☠
authorDaosheng Mu <daoshengmu@gmail.com>
Thu, 01 Jun 2017 13:34:00 +0800
changeset 361943 ca6881983573316f6d20ea12085a81f34b13ed27
parent 361942 12e990a890185866669feb776ea1d46c511f3892
child 361944 adb2b2e7960db3e3343ce38071eec33bcf3a0859
push id31952
push usercbook@mozilla.com
push dateFri, 02 Jun 2017 12:17:25 +0000
treeherdermozilla-central@194c009d6295 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1366941
milestone55.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 1366941 - Checking LayersIPCChannel type when using recycled textureClient; r=nical MozReview-Commit-ID: AJUJIC2tkHC
dom/canvas/WebGLContext.cpp
gfx/gl/SharedSurface.cpp
gfx/gl/SharedSurface.h
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -2347,17 +2347,17 @@ WebGLContext::GetVRFrame()
 
     RefPtr<SharedSurfaceTextureClient> sharedSurface = screen->Front();
     if (!sharedSurface) {
         return nullptr;
     }
 
     if (sharedSurface && sharedSurface->GetAllocator() != vrmc) {
         RefPtr<SharedSurfaceTextureClient> dest =
-        screen->Factory()->NewTexClient(sharedSurface->GetSize());
+        screen->Factory()->NewTexClient(sharedSurface->GetSize(), vrmc);
         if (!dest) {
             return nullptr;
         }
         gl::SharedSurface* destSurf = dest->Surf();
         destSurf->ProducerAcquire();
         SharedSurface::ProdCopy(sharedSurface->Surf(), dest->Surf(),
                                 screen->Factory());
         destSurf->ProducerRelease();
--- a/gfx/gl/SharedSurface.cpp
+++ b/gfx/gl/SharedSurface.cpp
@@ -12,16 +12,17 @@
 #include "GLScreenBuffer.h"
 #include "nsThreadUtils.h"
 #include "ScopedGLHelpers.h"
 #include "SharedSurfaceGL.h"
 #include "mozilla/layers/CompositorTypes.h"
 #include "mozilla/layers/TextureClientSharedSurface.h"
 #include "mozilla/layers/TextureForwarder.h"
 #include "mozilla/Unused.h"
+#include "VRManagerChild.h"
 
 namespace mozilla {
 namespace gl {
 
 /*static*/ void
 SharedSurface::ProdCopy(SharedSurface* src, SharedSurface* dest,
                         SurfaceFactory* factory)
 {
@@ -312,25 +313,32 @@ SurfaceFactory::~SurfaceFactory()
     MOZ_RELEASE_ASSERT(mRecycleTotalPool.empty(),"GFX: Surface recycle pool not empty.");
 
     // If we mRecycleFreePool.clear() before StopRecycling(), we may try to recycle it,
     // fail, call StopRecycling(), then return here and call it again.
     mRecycleFreePool.clear();
 }
 
 already_AddRefed<layers::SharedSurfaceTextureClient>
-SurfaceFactory::NewTexClient(const gfx::IntSize& size)
+SurfaceFactory::NewTexClient(const gfx::IntSize& size, const layers::LayersIPCChannel* aLayersChannel)
 {
     while (!mRecycleFreePool.empty()) {
         RefPtr<layers::SharedSurfaceTextureClient> cur = mRecycleFreePool.front();
         mRecycleFreePool.pop();
 
-        if (cur->Surf()->mSize == size) {
-            cur->Surf()->WaitForBufferOwnership();
-            return cur.forget();
+        if (cur->Surf()->mSize == size){
+            // In the general case, textureClients transit textures through
+            // CompositorForwarder. But, the textureClient created by VRManagerChild
+            // has a different LayerIPCChannel, PVRManager. Therefore, textureClients
+            // need to be separated into different cases.
+            if (aLayersChannel && (aLayersChannel == cur->GetAllocator()) ||
+                cur->GetAllocator() != gfx::VRManagerChild::Get()) {
+                cur->Surf()->WaitForBufferOwnership();
+                return cur.forget();
+            }
         }
 
         StopRecycling(cur);
     }
 
     UniquePtr<SharedSurface> surf = Move(CreateShared(size));
     if (!surf)
         return nullptr;
--- a/gfx/gl/SharedSurface.h
+++ b/gfx/gl/SharedSurface.h
@@ -301,17 +301,18 @@ protected:
 
     void StartRecycling(layers::SharedSurfaceTextureClient* tc);
     void SetRecycleCallback(layers::SharedSurfaceTextureClient* tc);
     void StopRecycling(layers::SharedSurfaceTextureClient* tc);
 
 public:
     UniquePtr<SharedSurface> NewSharedSurface(const gfx::IntSize& size);
     //already_AddRefed<ShSurfHandle> NewShSurfHandle(const gfx::IntSize& size);
-    already_AddRefed<layers::SharedSurfaceTextureClient> NewTexClient(const gfx::IntSize& size);
+    already_AddRefed<layers::SharedSurfaceTextureClient> NewTexClient(const gfx::IntSize& size,
+                                                                      const layers::LayersIPCChannel* aLayersChannel = nullptr);
 
     static void RecycleCallback(layers::TextureClient* tc, void* /*closure*/);
 
     // Auto-deletes surfs of the wrong type.
     bool Recycle(layers::SharedSurfaceTextureClient* texClient);
 };
 
 class ScopedReadbackFB