ImageDecoder::decode doesn't throw or return with an ill-formatted jpeg image
Categories
(Core :: Audio/Video: Web Codecs, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox133 | --- | fixed |
People
(Reporter: calixte, Assigned: aosmond)
References
Details
Attachments
(2 files, 1 external file)
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).
| Reporter | ||
Comment 1•2 years ago
|
||
Same problem with image issue10989.jpg coming from https://github.com/mozilla/pdf.js/issues/10989.
| Assignee | ||
Comment 3•2 years ago
|
||
A bit surprising, it should have the error path hooked up. I'll look this week.
Updated•2 years ago
|
| Assignee | ||
Comment 4•2 years ago
|
||
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.
Updated•2 years ago
|
| Assignee | ||
Updated•2 years ago
|
Comment 6•2 years ago
|
||
| bugherder | ||
Description
•