Bug 774388 - Patch 13: Temporarily addref to prevent destruction during handling of sync Stop message, to avoid triggering the 'mismatched CxxStackFrames' assertion of MessageChannel - r=nical
authorBenoit Jacob <bjacob@mozilla.com>
Fri, 04 Jul 2014 14:04:12 -0400
changeset 192528 fdfcb86cc3c897a751c260c2778a65a7fbd1ca9f
parent 192527 a27e869f58447fa5c40bf01b801483ee4855a7fd
child 192529 b6a5d0bea2b0102d4bacc59f9af657830687663d
push id27088
push usercbook@mozilla.com
push dateMon, 07 Jul 2014 12:19:04 +0000
treeherdermozilla-central@699348fd356b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs774388
milestone33.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 774388 - Patch 13: Temporarily addref to prevent destruction during handling of sync Stop message, to avoid triggering the 'mismatched CxxStackFrames' assertion of MessageChannel - r=nical
gfx/layers/ipc/ImageBridgeParent.cpp
--- a/gfx/layers/ipc/ImageBridgeParent.cpp
+++ b/gfx/layers/ipc/ImageBridgeParent.cpp
@@ -167,20 +167,35 @@ bool ImageBridgeParent::RecvWillStop()
   ManagedPTextureParent(textures);
   for (unsigned int i = 0; i < textures.Length(); ++i) {
     RefPtr<TextureHost> tex = TextureHost::AsTextureHost(textures[i]);
     tex->DeallocateDeviceData();
   }
   return true;
 }
 
+static void
+ReleaseImageBridgeParent(ImageBridgeParent* aImageBridgeParent)
+{
+  aImageBridgeParent->Release();
+}
+
 bool ImageBridgeParent::RecvStop()
 {
-  // Nothing to do. This message just serves as synchronization between the
+  // This message just serves as synchronization between the
   // child and parent threads during shutdown.
+
+  // There is one thing that we need to do here: temporarily addref, so that
+  // the handling of this sync message can't race with the destruction of
+  // the ImageBridgeParent, which would trigger the dreaded "mismatched CxxStackFrames"
+  // assertion of MessageChannel.
+  AddRef();
+  MessageLoop::current()->PostTask(
+    FROM_HERE,
+    NewRunnableFunction(&ReleaseImageBridgeParent, this));
   return true;
 }
 
 static  uint64_t GenImageContainerID() {
   static uint64_t sNextImageID = 1;
 
   ++sNextImageID;
   return sNextImageID;