Bug 1145015 - Part 1: Remove IsValidKey() check in MagicGrallocBufferHandle serializer. r=sotaro, r=nical
authorJerryShih <hshih@mozilla.com>
Tue, 24 Mar 2015 03:19:00 -0400
changeset 266295 6c08aa7c7142a7f3643aa77c962ed4c6e464dbc0
parent 266294 7e3c6bc1ade6b23a5f48e23ea196a9a1383f55ef
child 266296 03f1dc776f271455b4b9cf2fdd54f4038bd9cac3
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssotaro, nical
bugs1145015
milestone39.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 1145015 - Part 1: Remove IsValidKey() check in MagicGrallocBufferHandle serializer. r=sotaro, r=nical There is a data racing problem in IsValidKey() and we don't need to check the index in serializer. The index is always invalid when we alloc new buffer.
gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp
gfx/layers/ipc/SharedBufferManagerChild.cpp
gfx/layers/ipc/SharedBufferManagerChild.h
--- a/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp
+++ b/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp
@@ -142,21 +142,16 @@ ParamTraits<MagicGrallocBufferHandle>::R
     fds[n] = fd.fd;
   }
 
   aResult->mRef.mOwner = owner;
   aResult->mRef.mKey = index;
   if (sameProcess) {
     aResult->mGraphicBuffer = SharedBufferManagerParent::GetGraphicBuffer(aResult->mRef);
   } else {
-    if (SharedBufferManagerChild::GetSingleton()->IsValidKey(index)) {
-      aResult->mGraphicBuffer = SharedBufferManagerChild::GetSingleton()->GetGraphicBuffer(index);
-    }
-    MOZ_ASSERT(!aResult->mGraphicBuffer.get());
-
     // Deserialize GraphicBuffer
 #if ANDROID_VERSION >= 19
     sp<GraphicBuffer> buffer(new GraphicBuffer());
     const void* datap = (const void*)data;
     const int* fdsp = &fds[0];
     if (NO_ERROR != buffer->unflatten(datap, nbytes, fdsp, nfds)) {
       buffer = nullptr;
     }
--- a/gfx/layers/ipc/SharedBufferManagerChild.cpp
+++ b/gfx/layers/ipc/SharedBufferManagerChild.cpp
@@ -360,21 +360,10 @@ SharedBufferManagerChild::GetGraphicBuff
   if (mBuffers.count(key) == 0) {
     printf_stderr("SharedBufferManagerChild::GetGraphicBuffer -- invalid key");
     return nullptr;
   }
   return mBuffers[key];
 }
 #endif
 
-bool
-SharedBufferManagerChild::IsValidKey(int64_t key)
-{
-#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-  if (mBuffers.count(key) != 1) {
-    return false;
-  }
-#endif
-  return true;
-}
-
 } /* namespace layers */
 } /* namespace mozilla */
--- a/gfx/layers/ipc/SharedBufferManagerChild.h
+++ b/gfx/layers/ipc/SharedBufferManagerChild.h
@@ -108,18 +108,16 @@ public:
   DropGrallocBuffer(const mozilla::layers::MaybeMagicGrallocBufferHandle& aHandle);
 
   virtual bool RecvDropGrallocBuffer(const mozilla::layers::MaybeMagicGrallocBufferHandle& aHandle);
 
 #ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
   android::sp<android::GraphicBuffer> GetGraphicBuffer(int64_t key);
 #endif
 
-  bool IsValidKey(int64_t key);
-
   base::Thread* GetThread() const;
 
   MessageLoop* GetMessageLoop() const;
 
   static bool IsCreated();
 
   static base::Thread* sSharedBufferManagerChildThread;
   static SharedBufferManagerChild* sSharedBufferManagerChildSingleton;