Closed Bug 1921817 Opened 2 years ago Closed 2 years ago

ImageDecoder::decode doesn't throw or return with an ill-formatted jpeg image

Categories

(Core :: Audio/Video: Web Codecs, defect)

defect

Tracking

()

RESOLVED FIXED
133 Branch
Tracking Status
firefox133 --- fixed

People

(Reporter: calixte, Assigned: aosmond)

References

Details

Attachments

(2 files, 1 external file)

Attached image issue10880.jpg —

STR:
Load the image in using an ImageDecoder:

<html>
<body>
    <canvas id="canvas"></canvas>
</body>

<script>
    (async () => {
        const response = await fetch("./issue10880.jpg");
        const decoder = new ImageDecoder({
            data: response.body,
            type: "image/jpeg",
        });

        console.log("Decoding started");

        try {
            const img = await decoder.decode();
            const canvas = document.getElementById("canvas");
            const width = (canvas.width = img.codedWidth);
            const height = (canvas.height = img.codedHeight);
            const ctx = canvas.getContext("2d");
            ctx.drawImage(img, 0, 0, width, height);
        } catch (e) {
            console.error(e);
        } finally {
            console.log("Decoding finished.")
        }
    })();
</script>
</html>

Expected result:
At least, an exception must be thrown, but it'd better to try to workaround the issue.

Actual result:
In Firefox, nothing happens: decode neither throws nor returns.
In Chrome an exception is thrown (EncodingError: Failed to decode frame at index 0).

The image comes from the pdf in https://github.com/mozilla/pdf.js/issues/10880.
The images at page 7 & 8 are correctly decoded with the pdf.js jpeg decoder (and it's displayed correctly in Chrome or Acrobat).

Attached image issue10989.jpg —

Same problem with image issue10989.jpg coming from https://github.com/mozilla/pdf.js/issues/10989.

Andrew, any idea here?

Flags: needinfo?(aosmond)

A bit surprising, it should have the error path hooked up. I'll look this week.

Severity: -- → S3

This patch resolves the case where we expect a certain number of frames
from the decoder, given the frame count decoder results, but in practice
when we actually do the decoding, we don't produce any frames.

Assignee: nobody → aosmond
Status: NEW → ASSIGNED
Flags: needinfo?(aosmond)
Pushed by aosmond@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/eb9086e2b233 Fix truncated images where fewer frames are produced than expected with WebCodecs. r=media-playback-reviewers,padenot
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 133 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: