Animated AVIF in Safari iOS Responsive HTML Tags

Safari on iOS handles animated AVIF sequences inside responsive HTML elements—such as <picture> and <img> using srcset—by evaluating MIME types and responsive criteria before decoding the file through Apple's native media framework. While modern iOS releases generally support the AVIF container, animated AVIF implementations can encounter specific decoding constraints, memory limits, and performance safeguards that impact playback compared to traditional video or animated formats.

Format Negotiation in Responsive Tags

When serving animated AVIF using the HTML <picture> element, Safari evaluates child <source> tags sequentially:

<picture>
  <source type="image/avif" srcset="animation-large.avif 1200w, animation-small.avif 600w" sizes="(max-width: 768px) 100vw, 50vw">
  <source type="image/webp" srcset="animation-large.webp 1200w, animation-small.webp 600w" sizes="(max-width: 768px) 100vw, 50vw">
  <img src="fallback.gif" alt="Animated sequence" loading="lazy">
</picture>

Starting with iOS 16, Safari reports support for the image/avif MIME type. Because responsive image syntax does not provide a distinct MIME type for animated AVIF versus static AVIF, Safari accepts the type="image/avif" declaration unconditionally. It selects the candidate based on the current viewport, device-pixel ratio (DPR), and the sizes attribute, then initiates the download.

Playback and Rendering Mechanics

Once downloaded, Safari hands the animated AVIF to WebKit's image decoder:

Memory Constraints and Viewport Throttling

Safari on iOS imposes aggressive per-tab memory limits. High-resolution animated AVIF files with dozens or hundreds of frames are decoded into uncompressed raster bitmaps in memory. If an animated AVIF requires more memory than WebKit allocates to the image cache, the browser will drop playback frames, refuse to animate, or occasionally crash the web process (triggering a page reload).

Furthermore, off-screen animated AVIF elements embedded via responsive tags are typically paused until they enter the visual viewport. Safari resumes playback when the element scrolls into view, but rapid scrolling can introduce perceptible latency as the decoder initializes the sequence.

Implementation Considerations