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

[css-images] Disabling image animation #1615

Open
simonlindholm opened this Issue Jul 18, 2017 · 14 comments

Comments

Projects
None yet
10 participants
@simonlindholm
Copy link

simonlindholm commented Jul 18, 2017

It would be nice to have a CSS property for disabling image animation. Use cases include:

  • thumbnails
  • Twitter-like "only animate images in focus"
  • not wanting to animate user-uploaded content
  • user stylesheets/extensions

I'm imagining something like image-animation: auto | none, where none would disable image animation on elements and background-images.

Semantics are slightly subtle to define, because HTML defines image animations as keyed by URL, instead of per element. I can think of two options:

  • Paused images show the first frame (like how canvas's drawImage behaves)
  • Images that are ever shown as paused are animated individually

where the second seems tricker to implement (e.g., might include cloning SVG documents?) but also more useful than the first.

@Crissov

This comment has been minimized.

Copy link
Contributor

Crissov commented Jul 19, 2017

Perhaps add once or <integer> for repetitions; maybe <time> as well. Some users might want to force continuous loops even if the animation resource specifies a limited number of iterations, so loop or continuous makes sense as well.

Some animation formats distinguish a still poster frame from the first frame. You would probably have to specify which would be used when.

@simonlindholm

This comment has been minimized.

Copy link
Author

simonlindholm commented Jul 24, 2017

Perhaps add once or <integer> for repetitions; maybe <time> as well. Some users might want to force continuous loops even if the animation resource specifies a limited number of iterations, so loop or continuous makes sense as well.

Yep, that definitely fits. The use-cases for it seem weaker, though, and with that level of control you might want a <video> element anyway, so probably worth punting on for a first iteration at least.

Some animation formats distinguish a still poster frame from the first frame. You would probably have to specify which would be used when.

Do you know which ones? (I imagine the answer would be the same as for canvas's drawImage, whatever that does.)

@Crissov

This comment has been minimized.

Copy link
Contributor

Crissov commented Jul 24, 2017

APNG, for instance, can include PNG’s standard IDAT chunk data as the first frame or treat it as a fallback still image.

@DanHarkless

This comment has been minimized.

Copy link

DanHarkless commented Oct 7, 2017

Simon, thank you very much for opening this issue. I think it's much more than a "nice to have", though. The Web Content Accessibility Guidelines require that users be given the ability to pause, stop, or hide any animation that starts automatically and lasts more than 5 seconds (e.g. looping animated GIFs and PNGs). This is as it should be, since, for example, users with hypervigilance (little to no ability to employ selective attention) are unable to "just ignore" or "tune out" distracting extraneous animations in the field of view.

Firefox (and previously Netscape), for example, originally had the ability to stop animated images by pressing the Stop button or hitting the Esc key. Then this ability was eliminated as a side effect of fixing an XMLHttpRequest bug, and now browser add-ons must be installed in order to restore it. Unfortunately these add-ons utilize browser hooks that will no longer be available when Firefox support for add-ons other than WebExtensions is eliminated in November 2017.

Currently, WebExtensions and user stylesheet overrides have no ability to stop image animations, so it seems that a new CSS property is required to allow browsers like Firefox to meet this aspect of the W3C accessibility guidelines (and thus handle the myriad of sites whose webmasters do not implement the WCAGs).

@tabatkins

This comment has been minimized.

Copy link
Member

tabatkins commented Oct 7, 2017

Firefox (or any browser) doesn't need a CSS property in order to control GIF/APNG playback. The current play position isn't even exposed to the web, except indirectly via what frames would get painted to a canvas at a given point in time. It's perfectly acceptable for a browser to give this sort of control natively, either thru a user setting or thru direct manipulation (stop/start gifs on click automatically).

The only reason to add a CSS property is if we think that page authors need this control, and such control is common enough that things like <gif-player> aren't sufficient.

@ssokolow

This comment has been minimized.

Copy link

ssokolow commented Oct 7, 2017

The only reason to add a CSS property is if we think that page authors need this control, and such control is common enough that things like aren't sufficient.

Correct me if I'm wrong, but doesn't the same-origin poiicy render <gif-player> inapplicable for disabling animation on externally-hosted images from domains that don't set an appropriate CORS policy?

Also, the argument for using components like <gif-player> gives me serious concerns for user uploads, since it would basically require replacing every <img> tag with custom in-JavaScript infrastructure to retrieve the image, identify whether it's in a format the browser's native support might animate, and then feed it to a JavaScript-based AniGIF/APNG/etc. renderer if necessary.

Not only does that seem far too convoluted for something which is effectively a "troll security" measure to protect against users trying to disrupt other users' browsing experience (much like how one should use CSS to prevent user-submitted long strings of characters from causing changes to the layout beyond the scope of their post), it also seems like a potential performance issue and a decision which would disincentivize doing the right thing.

(And it would also be a solution ill-suited to "simple, static, meant-for-reading" pages (forums, wikis, etc.) where every other bit of mitigation for user-submitted content shenanigans (CSS, <bdi>, etc.) can be implemented readily without resorting to client-side JavaScript.)

In that latter case, it encourages people like me to take the risk of feeding all user-provided image content through server-side reprocessing to strip extra frames. (At the risk of exposing a vulnerability in the underlying image library which might be leveraged into an exploit across all browsers which visit the site.)

@tabatkins

This comment has been minimized.

Copy link
Member

tabatkins commented Oct 7, 2017

Not only does that seem far too convoluted for something which is effectively a "troll security" measure to protect against users trying to disrupt other users' browsing experience

This suggests that you think site authors are going to be the ones using this property. I don't see why they would, tho. Gifs are generally just fine to upload alongside any other images.

The need to stop/start a gif is either a per-user thing which should apply to all sites (and thus should be a browser setting), or should just generally be a functionality applied to all gifs for all users. I'm not seeing the use-case for an individual site author to need to turn on this functionality.

@ssokolow

This comment has been minimized.

Copy link

ssokolow commented Oct 7, 2017

This suggests that you think site authors are going to be the ones using this property. I don't see why they would, tho. Gifs are generally just fine to upload alongside any other images.

Because I'm both someone with hypervigilance issues and a designer/developer with a strong desire to control when and where animated elements are allowed within the sites I produce. (If a muted <video> wouldn't be allowed, then I probably won't allow an animated <img> either.)

Hence my comment about using image-processing libraries server-side. (To limit the risk, I've taken to using a simple a pre-check stage which detects APNG and animated GIFs using only very limited, defensively-coded inspection routines before I feed only the animated stuff to the full parser.)

On my hobby sites, a lack of this has actually been one of the factors delaying a move away from full pre-moderation to a more wiki-like experience.

@AmeliaBR

This comment has been minimized.

Copy link

AmeliaBR commented Oct 9, 2017

This functionality seems to me as a natural extension of the Media Fragments URI spec, assuming browsers ever get on board with fully implementing that spec. Then you could use something like:

<img src="user-upload.svg#play-state=paused"/>

background-image: icon.gif#t=2s&play-state=paused;

Using a URI hash to set the pause might help avoid the issue with HTML expecting all images with the same URL to animate in sync.

The downside, of course, is that you'd need to modify every URL, and therefore use JS to re-enable animations on content images.

Of course, it would also very much like a user-controlled browser feature to disable auto-playing GIFs, etc. But I do see a benefit to a website designer in being able to use these image formats but also being able to start and stop them.

@MarjaE2

This comment has been minimized.

Copy link

MarjaE2 commented Nov 11, 2017

I don't know much about programming, but I get nasty migraines and other symptoms from flashing, zooming, and some other animation. Some people get seizures. So it can be important for users to be able to disable animation [including transform and transition and so on], easily, and before we get hit by the animation.

@SebastianZ

This comment has been minimized.

Copy link
Contributor

SebastianZ commented Nov 13, 2017

I get nasty migraines and other symptoms from flashing, zooming, and some other animation. Some people get seizures. So it can be important for users to be able to disable animation [including transform and transition and so on], easily, and before we get hit by the animation.

That's a very good point. I would say, this is something the user should be in control of, not the website author. I.e. disabling all animations should rather be an option in the user agent than a CSS feature.

Simon's use case is to allow to disable only image animations, and that selectively per image.

Sebastian

@ssokolow

This comment has been minimized.

Copy link

ssokolow commented Nov 13, 2017

I think it makes more sense for it to be a matter of precedence. The user can overrule the website and the website can overrule the resource.

(ie. I can disable all animation on a site, but even if I don't, the website should have the ability to disable animation on external or user-uploaded resources without having to incorporate potentially insecure libraries for reading and writing the formats in question in order to strip extra frames as is currently necessary.)

@Malvoz

This comment has been minimized.

Copy link

Malvoz commented Apr 17, 2018

Personally I don't know if this is needed, but to add a use-case, see @media (prefers-reduced-motion).

@tabatkins

This comment has been minimized.

Copy link
Member

tabatkins commented Apr 17, 2018

At that level, it's something the UA should be applying, not something the page author is in charge of. That MQ is for alerting the author about things like animations and such, which are in their control and can't be automatically suppressed (since styling sometimes depends on them; just ignoring the animation can leave the element in an unusable default state).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.