Bug 1036561 - Reduce log spam from SharedBufferManagerChild. r=nical, a=bajaj
authorSotaro Ikeda <sikeda@mozilla.com>
Thu, 10 Jul 2014 07:24:07 -0700
changeset 208982 0e6ed467cb4dc988288e1b39bc7b4a866e004214
parent 208981 f4397dde382d6035cf0113e7ae55518de9008bd5
child 208983 0061c1fe7e28f94a15dc9373dd2914ddc8db5b1a
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical, bajaj
bugs1036561
milestone32.0a2
Bug 1036561 - Reduce log spam from SharedBufferManagerChild. r=nical, a=bajaj
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
@@ -144,17 +144,19 @@ ParamTraits<MagicGrallocBufferHandle>::R
     fds[n] = fd.fd;
   }
 
   aResult->mRef.mOwner = owner;
   aResult->mRef.mKey = index;
   if (sameProcess)
     aResult->mGraphicBuffer = SharedBufferManagerParent::GetGraphicBuffer(aResult->mRef);
   else {
-    aResult->mGraphicBuffer = SharedBufferManagerChild::GetSingleton()->GetGraphicBuffer(index);
+    if (SharedBufferManagerChild::GetSingleton()->IsValidKey(index)) {
+      aResult->mGraphicBuffer = SharedBufferManagerChild::GetSingleton()->GetGraphicBuffer(index);
+    }
     if (index >= 0 && aResult->mGraphicBuffer == nullptr) {
       //Only newly created GraphicBuffer should deserialize
 #if ANDROID_VERSION >= 19
       sp<GraphicBuffer> flattenable(new GraphicBuffer());
       const void* datap = (const void*)data;
       const int* fdsp = &fds[0];
       if (NO_ERROR == flattenable->unflatten(datap, nbytes, fdsp, nfds)) {
         aResult->mGraphicBuffer = flattenable;
--- a/gfx/layers/ipc/SharedBufferManagerChild.cpp
+++ b/gfx/layers/ipc/SharedBufferManagerChild.cpp
@@ -340,10 +340,21 @@ 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
@@ -102,19 +102,21 @@ public:
    * and decrease the reference count on both side.
    */
   void
   DeallocGrallocBuffer(const mozilla::layers::MaybeMagicGrallocBufferHandle& aBuffer);
 
   virtual bool RecvDropGrallocBuffer(const mozilla::layers::MaybeMagicGrallocBufferHandle& handle);
 
 #ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
-  android::sp<android::GraphicBuffer> GetGraphicBuffer(int64_t index);
+  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;