Bug 1190210 - Part 3: Fix the assertion in create-from-blob case. r=smaug
authorKaku Kuo <tkuo@mozilla.com>
Thu, 06 Aug 2015 22:36:06 +0800
changeset 258159 dfa165b74218afa2957a6a2918fe3225b5696fb9
parent 258158 d25a897f1e9d5981d291b1e316ae2978066f0068
child 258160 230bde30c6504ff8de7faf8b4dfe81e423a865de
push id63841
push userryanvm@gmail.com
push dateTue, 18 Aug 2015 14:08:57 +0000
treeherdermozilla-inbound@230bde30c650 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1190210
milestone43.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 1190210 - Part 3: Fix the assertion in create-from-blob case. r=smaug
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;