Skip to content

More SVG as image with subresources test coverage #51850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 10, 2025
Merged

Conversation

annevk
Copy link
Member

@annevk annevk commented Apr 4, 2025

All credit to Said Abou-Hallawa for doing most of the work here in WebKit many years ago.

All credit to Said Abou-Hallawa for doing most of the work here in WebKit many years ago.
@annevk annevk enabled auto-merge (squash) April 7, 2025 11:32
@annevk
Copy link
Member Author

annevk commented Apr 7, 2025

I think my cache bust identified a legitimate bug in Firefox. @emilio want to take a look? WebKit will be racy here as well, but we'll mark it as flaky until that's fixed.

@jgraham can this still be merged?

const image = new Image();
image.src = "support/image-with-nested-data-url-images.svg?" + Math.random().toString();

image.onload = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, are you sure per spec this works? Shouldn't you image.decode().then(? What guarantees that the inner image:

  • Is decoded sync?
  • Is decoded on time?

Copy link
Member

@shallawa shallawa Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the web developer should not worry about loading or decoding internal images. An image should be looked at as one entity especially if you do not have access to its internal structures (like the image in this test case). So for an image there should have only one loading time and only one decoding time.

For drawing an image into a canvas, I think this should force sync decoding. Unlike HTMLImageElement in the page, the image will be drawn into the canvas only once. If the image is not drawn because it has not been decoded yet, HTMLImageElement in the page will be repainted once it is ready. But canvas can't repaint the image.

So I think image.onload() should be enough to guarantee the image can be drawn to the canvas regardless of whether it contains internal images or not and regardless its decoding attribute is sync or async

@emilio
Copy link
Contributor

emilio commented Apr 7, 2025

@annevk not sure, you sure you're just not relying on the inner <image> decoding sync? But yeah maybe worth aligning in this case and forcing sync decoding on SVG-as-image documents...

@annevk
Copy link
Member Author

annevk commented Apr 7, 2025

Yeah, note that Gecko already seems to have that behavior in most cases. It's just the post load case that's flaky. But overall I think that all images should behave in the same way.

@jgraham jgraham disabled auto-merge April 10, 2025 09:50
@jgraham jgraham merged commit 52e0ae0 into master Apr 10, 2025
17 of 19 checks passed
@jgraham jgraham deleted the annevk/moar-svg-image branch April 10, 2025 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants