Backed out changeset 68bad2f0b260 for crash test failure on CLOSED TREE. r=me
authorStephen Pohl <spohl.mozilla.bugs@gmail.com>
Wed, 02 Oct 2013 16:13:32 -0400
changeset 163566 b4e25908b7893b111abba1d78f39212ad73ff8b0
parent 163565 6b459defebc1824fadd03c6455be02797bc187d4
child 163567 13c239c8242a8b057ec94c8cb141c85a359f48dc
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
milestone27.0a1
backs out68bad2f0b260e5b7baedbac3a4d625c6d6b0748c
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
Backed out changeset 68bad2f0b260 for crash test failure on CLOSED TREE. r=me
content/canvas/src/ImageEncoder.cpp
--- a/content/canvas/src/ImageEncoder.cpp
+++ b/content/canvas/src/ImageEncoder.cpp
@@ -19,71 +19,55 @@ public:
                         nsIThread* aEncoderThread,
                         FileCallback& aCallback)
     : mImgSize(0)
     , mType()
     , mImgData(nullptr)
     , mScriptContext(aScriptContext)
     , mEncoderThread(aEncoderThread)
     , mCallback(&aCallback)
-    , mFailed(false)
   {}
   virtual ~EncodingCompleteEvent() {}
 
   NS_IMETHOD Run()
   {
     MOZ_ASSERT(NS_IsMainThread());
 
-    mozilla::ErrorResult rv;
-
-    if (!mFailed) {
-      nsRefPtr<nsDOMMemoryFile> blob =
-        new nsDOMMemoryFile(mImgData, mImgSize, mType);
+    nsRefPtr<nsDOMMemoryFile> blob =
+      new nsDOMMemoryFile(mImgData, mImgSize, mType);
 
-      if (mScriptContext) {
-        JSContext* jsContext = mScriptContext->GetNativeContext();
-        if (jsContext) {
-          JS_updateMallocCounter(jsContext, mImgSize);
-        }
+    if (mScriptContext) {
+      JSContext* jsContext = mScriptContext->GetNativeContext();
+      if (jsContext) {
+        JS_updateMallocCounter(jsContext, mImgSize);
       }
-
-      mCallback->Call(blob, rv);
     }
 
-    // These members aren't thread-safe. We're making sure that they're being
-    // released on the main thread here. Otherwise, they could be getting
-    // released by EncodingRunnable's destructor on the encoding thread
-    // (bug 916128).
-    mScriptContext = nullptr;
-    mCallback = nullptr;
+    mozilla::ErrorResult rv;
+    mCallback->Call(blob, rv);
+    NS_ENSURE_SUCCESS(rv.ErrorCode(), rv.ErrorCode());
 
     mEncoderThread->Shutdown();
     return rv.ErrorCode();
   }
 
   void SetMembers(void* aImgData, uint64_t aImgSize, const nsAutoString& aType)
   {
     mImgData = aImgData;
     mImgSize = aImgSize;
     mType = aType;
   }
 
-  void SetFailed()
-  {
-    mFailed = true;
-  }
-
 private:
   uint64_t mImgSize;
   nsAutoString mType;
   void* mImgData;
   nsCOMPtr<nsIScriptContext> mScriptContext;
   nsCOMPtr<nsIThread> mEncoderThread;
   nsRefPtr<FileCallback> mCallback;
-  bool mFailed;
 };
 
 NS_IMPL_ISUPPORTS1(EncodingCompleteEvent, nsIRunnable);
 
 class EncodingRunnable : public nsRunnable
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
@@ -102,17 +86,17 @@ public:
     , mEncoder(aEncoder)
     , mEncodingCompleteEvent(aEncodingCompleteEvent)
     , mFormat(aFormat)
     , mSize(aSize)
     , mUsingCustomOptions(aUsingCustomOptions)
   {}
   virtual ~EncodingRunnable() {}
 
-  nsresult ProcessImageData(uint64_t* aImgSize, void** aImgData)
+  NS_IMETHOD Run()
   {
     nsCOMPtr<nsIInputStream> stream;
     nsresult rv = ImageEncoder::ExtractDataInternal(mType,
                                                     mOptions,
                                                     mImageBuffer,
                                                     mFormat,
                                                     mSize,
                                                     nullptr,
@@ -128,43 +112,28 @@ public:
                                              mFormat,
                                              mSize,
                                              nullptr,
                                              getter_AddRefs(stream),
                                              mEncoder);
     }
     NS_ENSURE_SUCCESS(rv, rv);
 
-    rv = stream->Available(aImgSize);
+    uint64_t imgSize;
+    rv = stream->Available(&imgSize);
     NS_ENSURE_SUCCESS(rv, rv);
-    NS_ENSURE_TRUE(*aImgSize <= UINT32_MAX, NS_ERROR_FILE_TOO_BIG);
+    NS_ENSURE_TRUE(imgSize <= UINT32_MAX, NS_ERROR_FILE_TOO_BIG);
 
-    rv = NS_ReadInputStreamToBuffer(stream, aImgData, *aImgSize);
+    void* imgData = nullptr;
+    rv = NS_ReadInputStreamToBuffer(stream, &imgData, imgSize);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    return rv;
-  }
-
-  NS_IMETHOD Run()
-  {
-    uint64_t imgSize;
-    void* imgData = nullptr;
-
-    nsresult rv = ProcessImageData(&imgSize, &imgData);
-    if (NS_FAILED(rv)) {
-      mEncodingCompleteEvent->SetFailed();
-    } else {
-      mEncodingCompleteEvent->SetMembers(imgData, imgSize, mType);
-    }
+    mEncodingCompleteEvent->SetMembers(imgData, imgSize, mType);
     rv = NS_DispatchToMainThread(mEncodingCompleteEvent, NS_DISPATCH_NORMAL);
-    if (NS_FAILED(rv)) {
-      // Better to leak than to crash.
-      mEncodingCompleteEvent.forget();
-      return rv;
-    }
+    NS_ENSURE_SUCCESS(rv, rv);
 
     return rv;
   }
 
 private:
   nsAutoString mType;
   nsAutoString mOptions;
   nsAutoArrayPtr<uint8_t> mImageBuffer;