Open Bug 1884485 Opened 1 year ago Updated 1 year ago

If an image was sync-decoded once, subsequent redecodes might be async and fail to be loaded when expected by websites

Categories

(Core :: Layout: Images, Video, and HTML Frames, defect)

defect

Tracking

()

People

(Reporter: jgilbert, Unassigned, NeedInfo)

References

(Blocks 1 open bug)

Details

Some web content does things we don't want them to do in order to force sync decode of images.
A primary example is a slideshow or flipbook app that does something like:

const ensureReadyToPaint = (() => {
  const C2D = new OffscreenCanvas(1,1).getContext('2d');
  return img => {
    C2D.drawImage(img);
  };
})();

function replace(oldImg, src) {
  const container = img.parentElement;
  const newImg = new HTMLImageElement();
  newImg.src = src;
  ensureReadyToPaint(newImg);
  container.replaceChild(newImg, oldImg);
}

Yes, there are a number of things we would prefer this code to do.
However, code of this nature has shipped in long-tail websites that we want to support.
And this currently works in Firefox!
However, it only works if painting requests the same (or close enough) decoding parameters as drawImage.

We are worried that some of the colorspace work will cause us to want to decode as SRGB for drawImage but DISPLAY for painting, or vice-versa.
This will cause this workaround (that we "want" to keep supporting) to break, causing long-tail content breakage in Firefox.

@tnikkel Does that accurately reflect your concern here WRT sync-decoding and canvas colorspaces?

Flags: needinfo?(tnikkel)
See Also: → 1884486
You need to log in before you can comment on or make changes to this bug.