Bug 949347 - Temporary strong reference to the actor in case mActor might be nulled concurrently - r=nical
authorBenoit Jacob <bjacob@mozilla.com>
Thu, 02 Jan 2014 17:54:13 -0500
changeset 162008 a06e9d86b6694ce9b547352ec033e9a305fe08d8
parent 162007 bd83f33608176a117cf87410bb655b1d47a5fc31
child 162009 707c397f00692955d6d78542274356765d4404d0
child 162018 faa8ab5bb9bad72d947f70db68f993229ece1b4a
push id38056
push userbjacob@mozilla.com
push dateThu, 02 Jan 2014 22:54:27 +0000
treeherdermozilla-inbound@a06e9d86b669 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs949347
milestone29.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 949347 - Temporary strong reference to the actor in case mActor might be nulled concurrently - r=nical
gfx/layers/client/TextureClient.cpp
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -284,22 +284,26 @@ void TextureClient::ForceRemove()
     }
   }
   MarkInvalid();
 }
 
 void
 TextureClient::Finalize()
 {
-  if (mActor) {
+  // Always make a temporary strong reference to the actor before we use it,
+  // in case TextureChild::ActorDestroy might null mActor concurrently.
+  RefPtr<TextureChild> actor = mActor;
+
+  if (actor) {
     // this will call ForceRemove in the right thread, using a sync proxy if needed
-    mActor->GetForwarder()->RemoveTexture(this);
+    actor->GetForwarder()->RemoveTexture(this);
 
-    // mActor has a raw pointer to us, mActor->mTextureClient. Null it before we die.
-    mActor->mTextureClient = nullptr;
+    // The actor has a raw pointer to us, actor->mTextureClient. Null it before we die.
+    actor->mTextureClient = nullptr;
   }
 }
 
 bool
 TextureClient::ShouldDeallocateInDestructor() const
 {
   if (!IsAllocated()) {
     return false;