mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 1709406 - Propagate errors from ImageDecoderSupport. r=aklotz
This change makes it so we always resolve the GeckoResult when we encounter an error. The stacktrace in the bug points to the SendBitmap() call, which I don't really understand how it's possible. Maybe some inlining is causing the stacktrace to misreport the line? This patch adds some extra null checks in case that's the issue. Differential Revision: https://phabricator.services.mozilla.com/D115082
This commit is contained in:
parent
1c9fdbfa5c
commit
668fb2856c
@ -30,9 +30,10 @@ class ImageCallbackHelper : public imgIContainerCallback,
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
void CompleteExceptionally(const char* aMessage) {
|
||||
void CompleteExceptionally(nsresult aRv) {
|
||||
nsPrintfCString error("Could not process image: 0x%08X", aRv);
|
||||
mResult->CompleteExceptionally(
|
||||
java::Image::ImageProcessingException::New(aMessage)
|
||||
java::Image::ImageProcessingException::New(error.get())
|
||||
.Cast<jni::Throwable>());
|
||||
gDecodeRequests.remove(this);
|
||||
}
|
||||
@ -60,8 +61,7 @@ class ImageCallbackHelper : public imgIContainerCallback,
|
||||
MOZ_ALWAYS_TRUE(gDecodeRequests.putNew(this));
|
||||
|
||||
if (NS_FAILED(aStatus)) {
|
||||
nsPrintfCString error("Could not process image: %d", aStatus);
|
||||
CompleteExceptionally(error.get());
|
||||
CompleteExceptionally(aStatus);
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
@ -75,6 +75,7 @@ class ImageCallbackHelper : public imgIContainerCallback,
|
||||
nsresult SendBitmap() {
|
||||
RefPtr<gfx::SourceSurface> surface;
|
||||
|
||||
NS_ENSURE_TRUE(mImage, NS_ERROR_FAILURE);
|
||||
if (mDesiredLength > 0) {
|
||||
surface = mImage->GetFrameAtSize(
|
||||
gfx::IntSize(mDesiredLength, mDesiredLength),
|
||||
@ -86,10 +87,10 @@ class ImageCallbackHelper : public imgIContainerCallback,
|
||||
imgIContainer::FLAG_SYNC_DECODE | imgIContainer::FLAG_ASYNC_NOTIFY);
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE);
|
||||
RefPtr<DataSourceSurface> dataSurface = surface->GetDataSurface();
|
||||
|
||||
NS_ENSURE_TRUE(dataSurface, NS_ERROR_FAILURE);
|
||||
|
||||
int32_t width = dataSurface->GetSize().width;
|
||||
int32_t height = dataSurface->GetSize().height;
|
||||
|
||||
@ -119,7 +120,11 @@ class ImageCallbackHelper : public imgIContainerCallback,
|
||||
void Notify(imgIRequest* aRequest, int32_t aType,
|
||||
const nsIntRect* aData) override {
|
||||
if (aType == imgINotificationObserver::DECODE_COMPLETE) {
|
||||
SendBitmap();
|
||||
nsresult status = SendBitmap();
|
||||
if (NS_FAILED(status)) {
|
||||
CompleteExceptionally(status);
|
||||
}
|
||||
|
||||
// Breack the cyclic reference between `ImageDecoderListener` (which is a
|
||||
// `imgIContainer`) and `ImageCallbackHelper`.
|
||||
mImage = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user