Skip to content
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

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

Open
zcorpan opened this issue Jul 6, 2022 · 18 comments · May be fixed by #8182
Open

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

zcorpan opened this issue Jul 6, 2022 · 18 comments · May be fixed by #8182

Comments

@zcorpan
Copy link
Member

zcorpan commented Jul 6, 2022

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.
@yoavweiss
Copy link
Contributor

Sounds reasonable to me!

@zcorpan zcorpan added the good first issue Ideal for someone new to a WHATWG standard or software project label Jul 6, 2022
@Parthmahajan29
Copy link

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

@Parthmahajan29
Copy link

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

@yoavweiss
Copy link
Contributor

@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 :)

@Parthmahajan29
Copy link

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
Copy link

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

@yoavweiss
Copy link
Contributor

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
Copy link
Contributor

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

@Parthmahajan29
Copy link

Ohk i will try my best for this project

@Parthmahajan29
Copy link

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

zcorpan added a commit that referenced this issue Aug 11, 2022
Fix the 'update the image data' algorithm when src is set to the same value.

Fixes #8080.
@zcorpan zcorpan removed the good first issue Ideal for someone new to a WHATWG standard or software project label Aug 11, 2022
@zcorpan zcorpan linked a pull request Aug 11, 2022 that will close this issue
@zcorpan
Copy link
Member Author

zcorpan commented Aug 15, 2022

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 web-platform-tests/wpt#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
Copy link
Member Author

zcorpan commented Sep 5, 2022

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.

@smaug----
Copy link

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.

@zcorpan
Copy link
Member Author

zcorpan commented Sep 5, 2022

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

@smaug----
Copy link

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

@smaug----
Copy link

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

@zcorpan
Copy link
Member Author

zcorpan commented Sep 6, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

4 participants