Bug 734681 - Make UNTIL_SIZE decodes shutdown the decoder if decoding is already finished. r=joe. This should fix the intermittent reftest failures introduced by Bug 715308.

--HG--
extra : rebase_source : 9661582cc39e18d6ac1c36085c1fa8ee8d0eaffb
This commit is contained in:
Robert Lickenbrock 2012-03-26 09:05:13 -07:00
parent d33003e285
commit 7746162a82

View File

@ -3001,9 +3001,6 @@ RasterImage::DecodeWorker::DecodeSomeOfImage(
NS_ABORT_IF_FALSE(aImg->mInitialized,
"Worker active for uninitialized container!");
if (aDecodeType == DECODE_TYPE_UNTIL_SIZE && aImg->mHasSize)
return NS_OK;
// If an error is flagged, it probably happened while we were waiting
// in the event queue.
if (aImg->mError)
@ -3032,8 +3029,14 @@ RasterImage::DecodeWorker::DecodeSomeOfImage(
TimeStamp start = TimeStamp::Now();
TimeStamp deadline = start + TimeDuration::FromMilliseconds(gMaxMSBeforeYield);
// Decode some chunks of data.
do {
// We keep decoding chunks until:
// * we don't have any data left to decode,
// * the decode completes,
// * we're an UNTIL_SIZE decode and we get the size, or
// * we run out of time.
while (aImg->mSourceData.Length() > aImg->mBytesDecoded &&
!aImg->IsDecodeFinished() &&
!(aDecodeType == DECODE_TYPE_UNTIL_SIZE && aImg->mHasSize)) {
chunkCount++;
nsresult rv = aImg->DecodeSomeData(maxBytes);
if (NS_FAILED(rv)) {
@ -3041,18 +3044,11 @@ RasterImage::DecodeWorker::DecodeSomeOfImage(
return rv;
}
// We keep decoding chunks until either:
// * we're an UNTIL_SIZE decode and we get the size,
// * we don't have any data left to decode,
// * the decode completes, or
// * we run out of time.
if (aDecodeType == DECODE_TYPE_UNTIL_SIZE && aImg->mHasSize)
// Yield if we've been decoding for too long. We check this _after_ decoding
// a chunk to ensure that we don't yield without doing any decoding.
if (TimeStamp::Now() >= deadline)
break;
} while (aImg->mSourceData.Length() > aImg->mBytesDecoded &&
!aImg->IsDecodeFinished() &&
TimeStamp::Now() < deadline);
}
aImg->mDecodeRequest.mDecodeTime += (TimeStamp::Now() - start);