Repository navigation
fix(transitions): do not re-create media inside persisted subtrees - #17750
Conversation
reifyMediaElements() (withastro#17603) runs after transition:persist elements from the old document have been moved into the new body, so it also replaced the live <audio>/<video> nodes carried over from the previous page. Those nodes were never parsed by DOMParser and are not inert; re-creating them resets currentTime/paused and drops listeners and framework refs, which breaks persistent players on every navigation. Skip media whose nearest [data-astro-transition-persist] host is one of the persisted elements. Media inside a persist container that appears for the first time on the new page still get reified, so withastro#17601 stays fixed for that case.
🦋 Changeset detectedLatest commit: ac20d07 The changes in this PR will be included in the next version bump. This PR includes changesets to release 422 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Merging this PR will improve performance by 18.09%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | Build: hybrid site (static + server) |
1.6 s | 1.4 s | +18.09% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing dobrodob:fix/persisted-media-reify (ac20d07) with main (d483125)1
Footnotes
Collect the <video>/<audio> nodes of the old body before the swap and skip those in reifyMediaElements(). This is precise by construction: a node that was live and is still in the new body got there through transition:persist — at any nesting depth, including persist containers nested inside a persisted one that have no counterpart on the new page, and the attribute placed on the media element itself. Media parsed from the new document are never in the set and still get reified (withastro#17601 stays fixed).
…gation Two view-transitions e2e tests that fail on main and pass with the fix: an expando set on the persisted <video> before navigation must still be there afterwards — for transition:persist on the media element itself, and for media inside an inner persist container that has no counterpart on the next page (it travels with its matched outer container). The existing '<video> can persist' test only asserts that currentTime grows, which a freshly re-created autoplaying element also satisfies — that is why the regression went unnoticed. Also spells out in swap-functions.ts why the liveMedia snapshot is sufficient.
|
Sorry for the inconvenience caused by the regression, and thanks for providing a fix/test that is much better than what Houston tried ;-) |
|
@codspeedbot fix this regression |
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [astro](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/astro)) | [`7.2.4` → `7.2.6`](https://renovatebot.com/diffs/npm/astro/7.2.4/7.2.6) |  |  | --- >⚠️ **Warning** > > Some dependencies could not be looked up. Check the [Dependency Dashboard](issues/273) for more information. --- ### Release Notes <details> <summary>withastro/astro (astro)</summary> ### [`v7.2.6`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#726) [Compare Source](https://github.com/withastro/astro/compare/[email protected]@7.2.6) ##### Patch Changes - [#​17812](withastro/astro#17812) [`29af6da`](withastro/astro@29af6da) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes a bug where `new FetchState(request)` could fail in development when server dependencies were optimized ### [`v7.2.5`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#725) [Compare Source](https://github.com/withastro/astro/compare/[email protected]@7.2.5) ##### Patch Changes - [#​17758](withastro/astro#17758) [`5f419e2`](withastro/astro@5f419e2) Thanks [@​astro-factory](https://github.com/apps/astro-factory)! - Fixes a bug where `experimental_getFontFileURL()` rejected valid font URLs when using the Cloudflare adapter - [#​17416](withastro/astro#17416) [`493796b`](withastro/astro@493796b) Thanks [@​iseraph-dev](https://github.com/iseraph-dev)! - Skips no-op pathname writes when normalizing SSR request URLs - [#​17712](withastro/astro#17712) [`bd374b7`](withastro/astro@bd374b7) Thanks [@​fkatsuhiro](https://github.com/fkatsuhiro)! - Updates deprecation messages target from Astro 7 to 8 - [#​17719](withastro/astro#17719) [`dac1768`](withastro/astro@dac1768) Thanks [@​astrobot-houston](https://github.com/astrobot-houston)! - Fixes session ID validation to reject non-UUID cookie values before using them as storage keys - [#​17770](withastro/astro#17770) [`84eb7e7`](withastro/astro@84eb7e7) Thanks [@​astro-factory](https://github.com/apps/astro-factory)! - Fixes `--mode`, `--site`, `--base`, `--out-dir`, `--verbose`, `--silent`, and `--open` flags being silently dropped when using `astro dev --background` or `astro preview --background` - [#​17713](withastro/astro#17713) [`d035290`](withastro/astro@d035290) Thanks [@​wakqasahmed](https://github.com/wakqasahmed)! - Fixes `content-modules.mjs` not removing entries for deleted or renamed content files, which could cause Vite to attempt to resolve non-existent modules As part of this fix, `#moduleImports` is now fully rebuilt from `deferredRender` entries before every write, so a module import added only through the public `addModuleImport()` API without a corresponding `deferredRender` entry in the store will no longer be preserved across writes. - [#​17743](withastro/astro#17743) [`adc750f`](withastro/astro@adc750f) Thanks [@​contactjawad](https://github.com/contactjawad)! - Fixes `Astro.preferredLocale` and `Astro.preferredLocaleList` ignoring `Accept-Language` quality values when they are absent or `0`. An entry without an explicit `q=` now correctly counts as quality `1.0` (per RFC 7231) and an entry with `q=0` is treated as not acceptable, so the highest-quality locale is selected regardless of header order. - [#​17757](withastro/astro#17757) [`660991c`](withastro/astro@660991c) Thanks [@​astro-factory](https://github.com/apps/astro-factory)! - Fixes build errors showing wrong file location, missing line:col, and misleading hints when a plugin error (e.g. from MDX) is wrapped by Vite's build error - [#​17783](withastro/astro#17783) [`60b14ff`](withastro/astro@60b14ff) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes a type error when passing an image from a content collection `image()` schema to a component or `<Image />`. The schema returned by `image()` was missing the `apng` format, so it no longer matched the type of an imported image. - [#​17664](withastro/astro#17664) [`d483125`](withastro/astro@d483125) Thanks [@​astrobot-houston](https://github.com/astrobot-houston)! - Fixes an issue where Astro CSP support didn't correctly handle cases `"unsafe-inline"` resource. Now when `"unsafe-inline"`, Astro won't emit hashes for the directive specified. - [#​17810](withastro/astro#17810) [`0fc5f65`](withastro/astro@0fc5f65) Thanks [@​florian-lefebvre](https://github.com/florian-lefebvre)! - Fixes a regression in the content collections that could cause images to not be resolved - [#​17781](withastro/astro#17781) [`aa33b44`](withastro/astro@aa33b44) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes `memoryCache()` storing responses that set cookies through `Astro.cookies` or `Astro.session` - [#​17787](withastro/astro#17787) [`6661fbe`](withastro/astro@6661fbe) Thanks [@​astro-factory](https://github.com/apps/astro-factory)! - Fixes `server:defer` crashing the dev server with "undefined is not a function" when a deferred component imports from `astro:i18n` - [#​17750](withastro/astro#17750) [`dd0e3ac`](withastro/astro@dd0e3ac) Thanks [@​dobrodob](https://github.com/dobrodob)! - Fixes a regression where `transition:persist` stopped working for `<audio>` and `<video>` elements. - [#​17774](withastro/astro#17774) [`fe1d16d`](withastro/astro@fe1d16d) Thanks [@​astro-factory](https://github.com/apps/astro-factory)! - Adds support for importing `.apng` files as image metadata for use with standard `<img>` elements. Astro's image components reject APNG files to avoid removing their animation - [#​17799](withastro/astro#17799) [`8797754`](withastro/astro@8797754) Thanks [@​astro-factory](https://github.com/apps/astro-factory)! - Fixes i18n `fallbackType: "rewrite"` returning 500 instead of 404 when the fallback locale also has no matching static path for a prerendered dynamic route - [#​17741](withastro/astro#17741) [`99d3d3d`](withastro/astro@99d3d3d) Thanks [@​ericswpark](https://github.com/ericswpark)! - Bumps the Astro compiler to the latest version. [Changelog](https://github.com/withastro/compiler-rs/releases/tag/%40astrojs%2Fcompiler-rs%400.4.0). - [#​17782](withastro/astro#17782) [`3578d45`](withastro/astro@3578d45) Thanks [@​Princesseuh](https://github.com/Princesseuh)! - Improves the performance of the Astro CLI in local by enabling Node's module compilation cache. - [#​17705](withastro/astro#17705) [`2043e4f`](withastro/astro@2043e4f) Thanks [@​astrobot-houston](https://github.com/astrobot-houston)! - Fixes incremental builds serving cached HTML that references stale CSS filenames after a stylesheet-only edit - [#​17754](withastro/astro#17754) [`3d50dfd`](withastro/astro@3d50dfd) Thanks [@​astro-factory](https://github.com/apps/astro-factory)! - Fixes the dev server refusing to start in Docker containers after a restart due to PID reuse in the lock file check - [#​17769](withastro/astro#17769) [`bbda94d`](withastro/astro@bbda94d) Thanks [@​astro-factory](https://github.com/apps/astro-factory)! - Fixes a build failure when defining `vite.environments.ssr` in the Astro config. User-provided environment config for `ssr`, `prerender`, or `client` is now properly deep-merged with Astro's internal environment settings instead of silently breaking the server entry naming. - [#​17776](withastro/astro#17776) [`0874da8`](withastro/astro@0874da8) Thanks [@​astro-factory](https://github.com/apps/astro-factory)! - Fixes the `glob()` content loader failing to load files with colons in their names (e.g., `Guide: Architecture.md`) - Updated dependencies \[[`0762a83`](withastro/astro@0762a83), [`0c99615`](withastro/astro@0c99615)]: - [@​astrojs/markdown-satteri](https://github.com/astrojs/markdown-satteri)@​0.3.8 </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC40OC4xIiwidXBkYXRlZEluVmVyIjoiNDQuNDguMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> Co-authored-by: Davide Zarantonello <[email protected]>
Changes
reifyMediaElements()(added in Fix video and audio elements broken after view transition navigation #17603, shipped in 7.2.1) runs after thetransition:persistelements from the old document have been moved into the new body, so it also replaced the live<audio>/<video>nodes carried over from the previous page. Those nodes were never parsed byDOMParserand are not inert; re-creating them resetscurrentTime/pausedand drops listeners and framework refs, which breaks persistent players on every<ClientRouter />navigation.new Set(oldElement.querySelectorAll('video, audio'))) and skip exactly those inreifyMediaElements(). A node that was live and is still in the new body got there throughtransition:persist— at any nesting depth (including a persist container nested inside a persisted one that has no counterpart on the new page) or with the attribute on the media element itself — so the check is precise by construction. Media parsed from the new document are never in the set and still get reified, so View Transitions Break Videos in Chrome #17601 stays fixed for them.Closes #17749
Testing
packages/astro/e2e/view-transitions.test.ts(fixturesnested-persist-one/two.astro): an expando set on the persisted<video>before navigation must still be there afterwards — (1)transition:persiston the media element itself (existingvideo-one/twofixture), (2) media inside an inner persist container that has no counterpart on the next page and travels with its matched outer container. Run locally in Chrome Stable: both fail onmain(2 failed) and pass with this branch (2 passed). The existing<video> can persisttest only asserts thatcurrentTimegrows, which a freshly re-created autoplaying element also satisfies — that is why the regression was not caught.<audio>loses its identity after a link navigation; with this change applied todist/transitions/swap-functions.jsand the app rebuilt, the app's e2e passes. Details: https://github.com/discours/publy/pull/1410#issuecomment-5344739532Docs
transition:persistalways had before 7.2.1.