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 258504 16d7e20d9565
parent 258503 348cc6be3ba0
child 258505 ccb54262291d
push id4682
push userryanvm@gmail.com
push date2015-04-16 18:48 +0000
treeherdermozilla-beta@45a5eaa7813b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel, sledru
bugs1145981
milestone38.0
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
@@ -139,16 +139,22 @@ DIBTextureHost::GetTextureSources()
   }
 
   return mTextureSource;
 }
 
 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
@@ -496,20 +496,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());