Bug 1145981 - Do not crash when a DIB texture is updated without a compositor. r=jrmuizel, a=sledru
authorNicolas Silva <nsilva@mozilla.com>
Fri, 27 Mar 2015 11:16:27 +0100
changeset 265633 52ac172fbfe1d624589a8ac68c5fbe213ed47d87
parent 265632 16e5a3443ec75d32eb1dc8b5e84464dd9d131149
child 265634 0a70c3b98932e7df0321f080bb68ab06a57b1ee9
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel, sledru
bugs1145981
milestone39.0a2
Bug 1145981 - Do not crash when a DIB texture is updated without a compositor. r=jrmuizel, a=sledru
gfx/layers/TextureDIB.cpp
gfx/layers/composite/TextureHost.cpp
--- a/gfx/layers/TextureDIB.cpp
+++ b/gfx/layers/TextureDIB.cpp
@@ -140,16 +140,22 @@ DIBTextureHost::BindTextureSource(Compos
 
   aTexture = mTextureSource;
   return !!aTexture;
 }
 
 void
 DIBTextureHost::Updated(const nsIntRegion* aRegion)
 {
+  if (!mCompositor) {
+    // This can happen if we send textures to a compositable that isn't yet
+    // attached to a layer.
+    return;
+  }
+
   if (!mTextureSource) {
     mTextureSource = mCompositor->CreateDataTextureSource(mFlags);
   }
 
   nsRefPtr<gfxImageSurface> imgSurf = mSurface->GetAsImageSurface();
 
   RefPtr<DataSourceSurface> surf = Factory::CreateWrappingDataSourceSurface(imgSurf->Data(), imgSurf->Stride(), mSize, mFormat);
 
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -492,20 +492,18 @@ BufferTextureHost::Upload(nsIntRegion *a
 {
   if (!GetBuffer()) {
     // We don't have a buffer; a possible cause is that the IPDL actor
     // is already dead. This inevitably happens as IPDL actors can die
     // at any time, so we want to silently return in this case.
     return false;
   }
   if (!mCompositor) {
-    NS_WARNING("Tried to upload without a compositor. Skipping texture upload...");
-    // If we are in this situation it means we should have called SetCompositor
-    // earlier. It is conceivable that on certain rare conditions with async-video
-    // we may end up here for the first frame, but this should not happen repeatedly.
+    // This can happen if we send textures to a compositable that isn't yet
+    // attached to a layer.
     return false;
   }
   if (mFormat == gfx::SurfaceFormat::UNKNOWN) {
     NS_WARNING("BufferTextureHost: unsupported format!");
     return false;
   } else if (mFormat == gfx::SurfaceFormat::YUV) {
     YCbCrImageDataDeserializer yuvDeserializer(GetBuffer(), GetBufferSize());
     MOZ_ASSERT(yuvDeserializer.IsValid());