-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Conversation
All credit to Said Abou-Hallawa for doing most of the work here in WebKit many years ago.
const image = new Image(); | ||
image.src = "support/image-with-nested-data-url-images.svg?" + Math.random().toString(); | ||
|
||
image.onload = () => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
@annevk not sure, you sure you're just not relying on the inner |
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. |
All credit to Said Abou-Hallawa for doing most of the work here in WebKit many years ago.