You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Dev toolbar's audit still freezes lazy-loaded SVG animations in Safari #18700
- P3: minor bugAn edge case that only affects very specific usage (priority)pkg: astroRelated to the core `astro` package (scope)triage: fix verifiedReporter confirmed the triage bot fix works
If this issue only occurs in one browser, which browser is a problem?
Safari
Describe the Bug
Follow-up to #18620: #18621 misses <img loading="lazy">. WebKit reports a decodedBodySize of 0 for it, so the audit fetches the image again and the animation still freezes.
In the repro the eager ring now completes; the lazy one stops partway.
Diagnose the cause: not needed (reproduction was skipped)
Verify the diagnosis: not needed (reproduction was skipped)
Attempt a fix: not needed (reproduction was skipped)
Publish the result: set triage: skipped
Reproduced: Skipped. The bug only happens in Safari/WebKit, and the triage sandbox has no WebKit browser that will run (and its Node.js is older than the version Astro requires)
Exploration: Partial. I read the code but couldn't test it in a browser
Unit Test: No. The behavior depends on how WebKit reports resource timing and handles the animation, so a Node unit test can't show it
Priority:P3: minor bug. It only happens in dev, only with the dev toolbar on, only in Safari, and only with CSS-animated SVGs in a lazy-loaded <img>. Turning off the toolbar or running a production build avoids it.
The code the issue describes is on main. getImageSize() in packages/astro/src/runtime/client/dev-toolbar/apps/audit/rules/perf.ts reads decodedBodySize from the image's Performance resource entry. If that value is 0, or the image is not complete yet, it falls back to fetch()ing the image URL again. The reporter says WebKit reports 0 for loading="lazy" images, and their repro includes a page with no Astro in it (public/fetch.html) showing that fetching the URL of an SVG that's animating freezes the animation. Their description matches the code.
I wasn't able to find a fix, but I identified some areas that may be relevant. The fix would be in getImageSize() and the perf-use-image-component rule in perf.ts. Some options:
When the size can't be read from Performance entries, skip the size check instead of fetching again.
Try encodedBodySize or transferSize before fetching.
Wait for lazy images to finish loading before measuring them.
Full Triage Report
Issue
Title: Dev toolbar's audit still freezes lazy-loaded SVG animations in Safari
Environment (from reporter)
Astro v7.4.10, Node v26.13.0, macOS (arm64), pnpm, static output, no adapter, no integrations
Browser: Safari only (the reporter also reproduced it with Playwright's WebKit). Works in Chromium.
Description
This follows up #18620. #18621 doesn't cover <img loading="lazy">. WebKit reports a decodedBodySize of 0 for these images, so the audit fetches the image again and the animation freezes. In the repro, the eager ring now finishes but the lazy one stops partway.
Expected: the animation completes. Actual: the animated SVG in <img src="/ring.svg?lazy" loading="lazy"> stops partway in Safari under astro dev when the dev toolbar is on.
src/pages/index.astro: two <img> tags showing a CSS-animated ring.svg. One is eager; the other is ?lazy with loading="lazy", so the two are separate requests.
astro.config.mjs: the toolbar can be turned off with ASTRO_DEV_TOOLBAR=off.
public/fetch.html: has no Astro. It fetches /ring.svg 250 ms after load, and the <img> animation freezes in WebKit.
Works with the toolbar off, with build && preview, and in Chromium.
The perf-use-image-component rule (selector img:not([data-image-component])) calls this for every local image that isn't a data URI. If decodedBodySize is 0, or the image hasn't finished loading, it fetches the image again, which freezes the SVG's CSS animation in WebKit.
Reproduction attempts
Cloned the repro and linked astro to /repo/packages/astro. Install succeeded.
pnpm dev --background failed: Node.js v22.23.2 is not supported by Astro! Please upgrade Node.js to a supported version: ">=22.23.4".
agent-browser isn't installed. The Playwright WebKit binary is there but won't start because system libraries are missing (gstreamer, gtk-4, pango, cairo, harfbuzz, …).
Result
Skipped. This depends on Safari/WebKit, which can't run in the sandbox. The report is detailed, matches the current code, and includes a WebKit demo with no Astro in it.
This report was made by an LLM. The analysis may be wrong, and the potential fix might not work, but is intended as a starting point for exploring the issue.
The fix is in getImageSize() in packages/astro/src/runtime/client/dev-toolbar/apps/audit/rules/perf.ts: the audit should never fetch an image the page is displaying. The fetch() fallback left by #18621 is the root cause. Any case that reaches it (a lazy image that isn't loaded yet, or WebKit reporting decodedBodySize as 0) freezes the animation, and for a lazy image it also forces a download the page deliberately put off.
If the image isn't loaded yet (!image.complete), wait for its load event before measuring. Don't fetch it.
Read the size from the image's resource timing entry: try decodedBodySize, then encodedBodySize, then transferSize.
If none of them gives a size, skip the size check for that image (don't report it) rather than fetching.
Remove the fetch() fallback entirely. This applies to both rules that use getImageSize() (perf-use-image-component and perf-use-videos).
You can't run WebKit, but you can still check this in the existing Chromium e2e test (packages/astro/e2e/dev-toolbar-audits.test.ts). Record the network requests and assert that opening the Audit app makes no extra request for an eager image or a loading="lazy" image. Also check that a large image is still reported once it has loaded.
Reproduced: Yes. The lazy ring freezes in WebKit (Playwright) with the toolbar on. The toolbar's audit also fetches a not-yet-loaded lazy image in Chromium.
Unit Test: No. getImageSize() is a private, browser-only helper, so I added an e2e test instead: packages/astro/e2e/dev-toolbar-audits.test.ts ("does not fetch a lazy image to read its size").
Priority:P3: minor bug. It only happens in dev, with the toolbar on, in Safari, with CSS-animated SVGs in lazy <img> tags. Turning off the toolbar or using a production build avoids it.
getImageSize() in packages/astro/src/runtime/client/dev-toolbar/apps/audit/rules/perf.ts falls back to fetch() in two cases. One is when the image's resource timing size is 0: WebKit reports decodedBodySize, encodedBodySize and transferSize all as 0 for a loading="lazy"<img>. The other is when the image isn't complete yet. Fetching the URL of an SVG that's animating freezes the animation in WebKit, and fetching an unloaded lazy image downloads it before the page needs it. The audit runs when the toolbar starts up, so this happens even if the Audit app is never opened.
I found a potential fix for this issue. It needs human review.
The fetch() fallback is removed. The size comes from decodedBodySize || encodedBodySize || transferSize; if there's no size, the size check is skipped and the image isn't reported.
Eager images that are still loading are waited on.
This part differs from @matthewp's suggestion: an unloaded loading="lazy" image is skipped instead of waited on. The audit's lint() awaits each rule's match() one after another. I tried waiting for load, and a lazy image below the fold blocked the whole audit: no highlights appeared until the user scrolled to it.
Try this fix
You can test this fix right now without waiting for a release:
# astro
npm i https://pkg.pr.new/astro@4287faa
If this fixes your issue, please leave a comment letting us know (for example
"confirmed, this fixes it"). A pull request will then be opened to get it merged.
Full Triage Report
Issue
Dev toolbar's audit still freezes lazy-loaded SVG animations in Safari (follow-up to #18620 / #18621)
Environment (reporter): Astro v7.4.10, Node v26.13.0, macOS arm64, pnpm, static output, no adapter or integrations. Safari only.
Expected: the SVG animation in <img src="/ring.svg?lazy" loading="lazy"> finishes under astro dev with the toolbar on.
The sandbox runs Node 22.23.2, but bin/astro.mjs requires 22.23.4 or later. I started the dev server through the programmatic dev() API instead.
I installed Playwright Chromium, Chrome and WebKit, with their system dependencies.
Steps:
Clone the repro and link astro to the workspace build.
Load / in WebKit, record every request for ring.svg and dump each image's resource timing entries.
Screenshot both rings 3 s after load and count the orange pixels (a fully drawn ring is 6631).
Results:
Case
Requests
Lazy ring
WebKit, toolbar on
/ring.svg?lazy requested as image, then again as fetch (the audit)
4345 px (frozen)
WebKit, toolbar off
image requests only
6631 px
In WebKit, the lazy <img> resource entry is {decodedBodySize: 0, encodedBodySize: 0, transferSize: 0}. The eager one is 742/742/1042.
Chromium on /: both images are loaded with real sizes, and nothing is fetched again.
On an added /below-fold page (a lazy image under a 10000px spacer), the image isn't complete. The audit fetches it in both Chromium and WebKit, and that fetch is the only request for it.
Diagnosis (confidence: high)
getImageSize() (perf.ts, lines 6–19) is used by perf-use-image-component (20KB threshold) and perf-use-videos (100KB threshold). Before the fix:
Whenever the size is 0 (WebKit lazy images) or the image isn't complete (unloaded lazy images), this falls back to fetch(). The audit runs during the Audit app's init() (apps/audit/index.ts, await run()), on page load.
Verification
Verdict: bug (confidence: high).#18621 set out to stop fetching displayed images again, but missed lazy images. There's no comment or test showing that case was considered. The maintainer also identified the fetch() fallback as the root cause.
Fix
perf.ts: getImageSize() never fetches.
An eager image that isn't complete is waited on (load or error).
An unloaded loading="lazy" image returns 0.
Otherwise it returns decodedBodySize || encodedBodySize || transferSize || 0 from the latest resource entry.
A result of 0 is below both callers' thresholds, so the image is skipped and the call sites are unchanged.
New fixture e2e/fixtures/dev-toolbar/src/pages/audits-perf-lazy-image.astro: a large raw lazy image above the fold, and one below the fold.
New e2e test: opening the Audit app makes no fetch request for /the-future.jpg*, and exactly one perf-use-image-component highlight appears (for the loaded image above the fold). The existing test "does not fetch a loaded image again to read its size" still covers the eager case: the large image is still reported and not fetched.
Why lazy images aren't waited on: waiting for load on every incomplete image made the new test fail with 0 highlights. lint() awaits rule matches one after another, so a lazy image that never loads blocks every rule after it. The original code also stalled on this page: it fetched the image, matched it, and then createAuditProblem() waited for its load.
Tradeoffs:
An unloaded lazy image isn't size-checked until the audit runs again. It re-runs on DOM mutations, not on image load.
WebKit reports zero sizes for lazy images, so Safari never shows perf-use-image-component for them.
Verification:
WebKit, repro page: no fetches; both rings 6631/6631 px.
/below-fold in Chromium and WebKit: no requests.
dev-toolbar-audits.test.ts: 15/15 pass in Chrome Stable. The new test fails on the original code.
Biome is clean and the build has 0 errors.
This report was made by an LLM. The analysis may be wrong, and the potential fix might not work, but is intended as a starting point for exploring the issue.
- P3: minor bugAn edge case that only affects very specific usage (priority)pkg: astroRelated to the core `astro` package (scope)triage: fix verifiedReporter confirmed the triage bot fix works
Activity
astro-factory commentedon Nov 11, 2026
Triage complete
triage: skipped<img>. Turning off the toolbar or running a production build avoids it.The code the issue describes is on
main.getImageSize()inpackages/astro/src/runtime/client/dev-toolbar/apps/audit/rules/perf.tsreadsdecodedBodySizefrom the image's Performance resource entry. If that value is0, or the image is notcompleteyet, it falls back tofetch()ing the image URL again. The reporter says WebKit reports0forloading="lazy"images, and their repro includes a page with no Astro in it (public/fetch.html) showing that fetching the URL of an SVG that's animating freezes the animation. Their description matches the code.I wasn't able to find a fix, but I identified some areas that may be relevant. The fix would be in
getImageSize()and theperf-use-image-componentrule inperf.ts. Some options:encodedBodySizeortransferSizebefore fetching.Full Triage Report
Issue
Title: Dev toolbar's audit still freezes lazy-loaded SVG animations in Safari
Environment (from reporter)
Description
This follows up #18620. #18621 doesn't cover
<img loading="lazy">. WebKit reports adecodedBodySizeof 0 for these images, so the audit fetches the image again and the animation freezes. In the repro, the eager ring now finishes but the lazy one stops partway.Expected: the animation completes.
Actual: the animated SVG in
<img src="/ring.svg?lazy" loading="lazy">stops partway in Safari underastro devwhen the dev toolbar is on.Repro: https://github.com/marcalexiei/astro-dev-toolbar-svg-animation-repro
Repro project
src/pages/index.astro: two<img>tags showing a CSS-animatedring.svg. One is eager; the other is?lazywithloading="lazy", so the two are separate requests.astro.config.mjs: the toolbar can be turned off withASTRO_DEV_TOOLBAR=off.public/fetch.html: has no Astro. It fetches/ring.svg250 ms after load, and the<img>animation freezes in WebKit.build && preview, and in Chromium.Relevant code
packages/astro/src/runtime/client/dev-toolbar/apps/audit/rules/perf.ts:The
perf-use-image-componentrule (selectorimg:not([data-image-component])) calls this for every local image that isn't a data URI. IfdecodedBodySizeis 0, or the image hasn't finished loading, it fetches the image again, which freezes the SVG's CSS animation in WebKit.Reproduction attempts
astroto/repo/packages/astro. Install succeeded.pnpm dev --backgroundfailed:Node.js v22.23.2 is not supported by Astro! Please upgrade Node.js to a supported version: ">=22.23.4".agent-browserisn't installed. The Playwright WebKit binary is there but won't start because system libraries are missing (gstreamer, gtk-4, pango, cairo, harfbuzz, …).Result
Skipped. This depends on Safari/WebKit, which can't run in the sandbox. The report is detailed, matches the current code, and includes a WebKit demo with no Astro in it.
This report was made by an LLM. The analysis may be wrong, and the potential fix might not work, but is intended as a starting point for exploring the issue.
matthewp commentedon Nov 17, 2026
The fix is in
getImageSize()inpackages/astro/src/runtime/client/dev-toolbar/apps/audit/rules/perf.ts: the audit should never fetch an image the page is displaying. Thefetch()fallback left by #18621 is the root cause. Any case that reaches it (a lazy image that isn't loaded yet, or WebKit reportingdecodedBodySizeas 0) freezes the animation, and for a lazy image it also forces a download the page deliberately put off.!image.complete), wait for itsloadevent before measuring. Don't fetch it.decodedBodySize, thenencodedBodySize, thentransferSize.fetch()fallback entirely. This applies to both rules that usegetImageSize()(perf-use-image-componentandperf-use-videos).You can't run WebKit, but you can still check this in the existing Chromium e2e test (
packages/astro/e2e/dev-toolbar-audits.test.ts). Record the network requests and assert that opening the Audit app makes no extra request for an eager image or aloading="lazy"image. Also check that a large image is still reported once it has loaded.matthewp commentedon Nov 17, 2026
Bot please triage again based on this new information.
astro-factory commentedon Nov 17, 2026
Triage complete
triage: fix pendinggetImageSize()is a private, browser-only helper, so I added an e2e test instead:packages/astro/e2e/dev-toolbar-audits.test.ts("does not fetch a lazy image to read its size").<img>tags. Turning off the toolbar or using a production build avoids it.getImageSize()inpackages/astro/src/runtime/client/dev-toolbar/apps/audit/rules/perf.tsfalls back tofetch()in two cases. One is when the image's resource timing size is 0: WebKit reportsdecodedBodySize,encodedBodySizeandtransferSizeall as 0 for aloading="lazy"<img>. The other is when the image isn'tcompleteyet. Fetching the URL of an SVG that's animating freezes the animation in WebKit, and fetching an unloaded lazy image downloads it before the page needs it. The audit runs when the toolbar starts up, so this happens even if the Audit app is never opened.I found a potential fix for this issue. It needs human review.
fetch()fallback is removed. The size comes fromdecodedBodySize || encodedBodySize || transferSize; if there's no size, the size check is skipped and the image isn't reported.loading="lazy"image is skipped instead of waited on. The audit'slint()awaits each rule'smatch()one after another. I tried waiting forload, and a lazy image below the fold blocked the whole audit: no highlights appeared until the user scrolled to it.Try this fix
You can test this fix right now without waiting for a release:
# astro npm i https://pkg.pr.new/astro@4287faaIf this fixes your issue, please leave a comment letting us know (for example
"confirmed, this fixes it"). A pull request will then be opened to get it merged.
Full Triage Report
Issue
Dev toolbar's audit still freezes lazy-loaded SVG animations in Safari (follow-up to #18620 / #18621)
<img src="/ring.svg?lazy" loading="lazy">finishes underastro devwith the toolbar on.Reproduction
Setup notes:
bin/astro.mjsrequires 22.23.4 or later. I started the dev server through the programmaticdev()API instead.Steps:
astroto the workspace build./in WebKit, record every request forring.svgand dump each image's resource timing entries.Results:
/ring.svg?lazyrequested asimage, then again asfetch(the audit)imagerequests only<img>resource entry is{decodedBodySize: 0, encodedBodySize: 0, transferSize: 0}. The eager one is 742/742/1042./: both images are loaded with real sizes, and nothing is fetched again./below-foldpage (a lazy image under a 10000px spacer), the image isn'tcomplete. The auditfetches it in both Chromium and WebKit, and that fetch is the only request for it.Diagnosis (confidence: high)
getImageSize()(perf.ts, lines 6–19) is used byperf-use-image-component(20KB threshold) andperf-use-videos(100KB threshold). Before the fix:Whenever the size is 0 (WebKit lazy images) or the image isn't
complete(unloaded lazy images), this falls back tofetch(). The audit runs during the Audit app'sinit()(apps/audit/index.ts,await run()), on page load.Verification
Verdict: bug (confidence: high). #18621 set out to stop fetching displayed images again, but missed lazy images. There's no comment or test showing that case was considered. The maintainer also identified the
fetch()fallback as the root cause.Fix
perf.ts:getImageSize()never fetches.completeis waited on (loadorerror).loading="lazy"image returns 0.decodedBodySize || encodedBodySize || transferSize || 0from the latest resource entry.e2e/fixtures/dev-toolbar/src/pages/audits-perf-lazy-image.astro: a large raw lazy image above the fold, and one below the fold.fetchrequest for/the-future.jpg*, and exactly oneperf-use-image-componenthighlight appears (for the loaded image above the fold). The existing test "does not fetch a loaded image again to read its size" still covers the eager case: the large image is still reported and not fetched..changeset/lazy-image-audit-fetch.md(astro: patch).Why lazy images aren't waited on: waiting for
loadon every incomplete image made the new test fail with 0 highlights.lint()awaits rule matches one after another, so a lazy image that never loads blocks every rule after it. The original code also stalled on this page: it fetched the image, matched it, and thencreateAuditProblem()waited for itsload.Tradeoffs:
perf-use-image-componentfor them.Verification:
/below-foldin Chromium and WebKit: no requests.dev-toolbar-audits.test.ts: 15/15 pass in Chrome Stable. The new test fails on the original code.This report was made by an LLM. The analysis may be wrong, and the potential fix might not work, but is intended as a starting point for exploring the issue.
matthewp commentedon Nov 17, 2026
Bot, this fixes it
astro-factory commentedon Nov 17, 2026
The fix has been verified! A pull request has been created: #18771