html icon indicating copy to clipboard operation
html copied to clipboard

Update the image data - setting src to the same value logic seems incorrect

Open zcorpan opened this issue 3 years ago • 18 comments

https://html.spec.whatwg.org/multipage/images.html#updating-the-image-data

step 13:

If urlString is the same as the current request's current URL and current request's state is partially available, then abort the image request for the pending request, queue an element task on the DOM manipulation task source given the img element to restart the animation if restart animation is set, and return.

So this only restarts the animation / returns if current request's state is partially available, not if it's completely available. That seems wrong. cc @yoavweiss

I think it should be:

  1. If urlString is the same as the current request's current URL:
    1. If current request's state is partially available, then abort the image request for the pending request.
    2. If restart animation is set, then queue an element task on the DOM manipulation task source given the img element to restart the animation.
    3. Return.

zcorpan avatar Jul 06 '22 09:07 zcorpan

Sounds reasonable to me!

yoavweiss avatar Jul 06 '22 09:07 yoavweiss

I think i am capable of solving this issue, Can you please assign this to me?

Parthmahajan29 avatar Jul 10 '22 14:07 Parthmahajan29

I will just need some of your guidance as it will my first issue.

Parthmahajan29 avatar Jul 10 '22 14:07 Parthmahajan29

@Parthmahajan29 - I believe Simon is OOO for the next month or so. If you're interested in sending a PR for this, I'm happy to help with reviews :)

yoavweiss avatar Jul 11 '22 05:07 yoavweiss

I am able to do the chances asked for, but i unable to find the file where i have to make the chances, can you help me with that

Parthmahajan29 avatar Jul 11 '22 07:07 Parthmahajan29

I just want to know where i have to do the chances?

Parthmahajan29 avatar Jul 11 '22 07:07 Parthmahajan29

https://github.com/whatwg/html-build can be a good place to start. The HTML source is where you want to apply the changes.

yoavweiss avatar Jul 11 '22 08:07 yoavweiss

Also, the WHATWG matrix may be a good place to ask for assistance.

yoavweiss avatar Jul 11 '22 08:07 yoavweiss

Ohk i will try my best for this project

Parthmahajan29 avatar Jul 11 '22 08:07 Parthmahajan29

Ohk Sir now i had solved the issue what should i do now?

Parthmahajan29 avatar Jul 14 '22 18:07 Parthmahajan29

@Parthmahajan29 submit a pull request: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request

zcorpan avatar Aug 08 '22 15:08 zcorpan

Hmmm, actually I think the current spec may be correct.

If the image is completely available, it will be in the "list of available images", and so step 6.3.7.1 restarts the animation. (This step is exercised by https://github.com/web-platform-tests/wpt/pull/35468 )

If the image is still loading, the step here will restart the animation. I'm not sure if browsers start to animate images before they're completely loaded, though. This probably needs some more testing.

zcorpan avatar Aug 15 '22 14:08 zcorpan

Here's a demo (with a local wpt serve running):

data:text/html,<img src=http://web-platform.test:8000/css/CSS2/backgrounds/support/animated.gif?pipe=trickle(1200:d10)%20id=x%3E%3Cbutton%20onclick=%22x.src=x.getAttribute(%27src%27)%22%3Eset%20src%3C/button%3E

In Chrome, it starts playing the animation while the image is still loading. Setting src restarts the animation but doesn't re-fetch.

In Safari, the animation is stuck on the first frame while loading. When setting src, it plays to the second frame and gets stuck there.

In Firefox, it starts playing the animation while the image is still loading. Setting src does not restart the animation (while still loading), and also doesn't re-fetch

In all browsers, after the image is fully loaded, setting src restarts the animation.

I think Chrome's behavior seems best.

zcorpan avatar Sep 05 '22 13:09 zcorpan

Why would you want to restart animation if there isn't a re-fetch? If setting src to src doesn't re-fetch, I wouldn't expect it to do anything else either.

smaug---- avatar Sep 05 '22 15:09 smaug----

It's in the spec because it's something all browsers do.

zcorpan avatar Sep 05 '22 15:09 zcorpan

But you just said it isn't, didn't you :) I mean in the comment above.

smaug---- avatar Sep 05 '22 15:09 smaug----

Ah, yeah, I wasn't talking about the fully loaded and you are.

smaug---- avatar Sep 05 '22 15:09 smaug----

Right, setting src while an animated image is still being loaded is an edge case where browsers disagree.

zcorpan avatar Sep 06 '22 08:09 zcorpan