Bug 1190210 - Part 3: Fix the assertion in create-from-blob case. r=smaug, a=sledru
authorKaku Kuo <tkuo@mozilla.com>
Thu, 06 Aug 2015 22:36:06 +0800
changeset 277340 2ba0588344a220b3f4f28583686b29e1c8ce2ca5
parent 277339 9596a39c3e78e3a6e0185df8de285134d7c8a9d7
child 277341 d3402c8dcdd4aa27b8fcbf0c1171ae7dc971e96f
push id8357
push userryanvm@gmail.com
push dateFri, 28 Aug 2015 13:33:35 +0000
treeherdermozilla-aurora@d75ede2c22a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, sledru
bugs1190210
milestone42.0a2
Bug 1190210 - Part 3: Fix the assertion in create-from-blob case. r=smaug, a=sledru
dom/canvas/ImageBitmap.cpp
--- a/dom/canvas/ImageBitmap.cpp
+++ b/dom/canvas/ImageBitmap.cpp
@@ -885,18 +885,25 @@ DecodeAndCropBlob(Blob& aBlob, Maybe<Int
 
   // Crop the source surface if needed.
   RefPtr<SourceSurface> croppedSurface = surface;
 
   if (aCropRect.isSome()) {
     // The blob is just decoded into a RasterImage and not optimized yet, so the
     // _surface_ we get is a DataSourceSurface which wraps the RasterImage's
     // raw buffer.
-    MOZ_ASSERT(surface->GetType() == SurfaceType::DATA,
-          "The SourceSurface from just decoded Blob is not DataSourceSurface.");
+    //
+    // The _surface_ might already be optimized so that its type is not
+    // SurfaceType::DATA. However, we could keep using the generic cropping and
+    // copying since the decoded buffer is only used in this ImageBitmap so we
+    // should crop it to save memory usage.
+    //
+    // TODO: Bug1189632 is going to refactor this create-from-blob part to
+    //       decode the blob off the main thread. Re-check if we should do
+    //       cropping at this moment again there.
     RefPtr<DataSourceSurface> dataSurface = surface->GetDataSurface();
     croppedSurface = CropAndCopyDataSourceSurface(dataSurface, aCropRect.ref());
     aCropRect->MoveTo(0, 0);
   }
 
   if (NS_WARN_IF(!croppedSurface)) {
     aRv.Throw(NS_ERROR_NOT_AVAILABLE);
     return nullptr;