Sub topic 13
Debugging transitions in DevTools
This chapter assumes you have enabled @view-transition on both pages and styled the pseudo-elements, as covered earlier. It uses Chromium DevTools. Other browsers differ in their tooling.
Why transitions are hard to debug
A cross-document transition lasts a few hundred milliseconds, and the old page is gone before you can inspect it. When nothing animates, the browser usually skips the transition without telling you. Debugging means making the transition last longer and finding out which step skipped it.
Slow it down and inspect the pseudo-elements
Open the Animations panel (Command Menu, then "Show Animations"). Set the speed to 10% and click a link. The panel records the transition's animations, and you can pause them. While they are paused, the Elements panel shows a ::view-transition tree under html. It contains one group per name, and each group holds an image pair with old and new snapshots. You can select a pseudo-element, read its computed styles, and edit its CSS live.
If the panel captures nothing, the transition did not start. If the tree has only root, no element has a view-transition-name yet.
You can also slow the transition in CSS. Remove this rule when you finish.
/* Temporary: make every transition animation last 5 seconds. */
::view-transition-group(*),
::view-transition-old(*),
::view-transition-new(*) {
animation-duration: 5s !important;
}Log the lifecycle
The pageswap event fires on the old page and pagereveal fires on the new one. In both, event.viewTransition is null when no transition is happening. The ready promise rejects when the browser skips the transition. Add this script to both pages while you debug:
window.addEventListener('pageswap', (event) => {
console.log('[vt] pageswap', event.viewTransition ? 'transition' : 'none',
event.activation?.entry?.url);
});
window.addEventListener('pagereveal', async (event) => {
if (!event.viewTransition) {
console.log('[vt] pagereveal: no transition');
return;
}
try {
await event.viewTransition.ready;
console.log('[vt] ready, animations running');
} catch (error) {
console.warn('[vt] skipped:', error);
}
});Enable "Preserve log" in the Console, because the old page's messages disappear on navigation.
Common causes
| Symptom | Likely cause | Check |
|---|---|---|
| No transition at all | The at-rule is on only one page | View source of both pages |
| No transition at all | Cross-origin navigation or redirect | Compare origins in the Network panel |
| `ready` rejects | Two elements share a `view-transition-name` | Console warning, then search for the name |
| Shared element does not morph | The name exists on only one page | Elements panel, paused tree |
| Transition appears, but no motion | `prefers-reduced-motion` rule matches | Rendering tab, emulate the preference |
| Animation snaps or flashes | New page rendered late | Test `rel="expect"` render blocking |
Exercise
You click a link and nothing animates. The Console shows "[vt] pagereveal: no transition". Which two checks should you do first?
Show answer
Confirm that both the old and new pages include @view-transition { navigation: auto; }, and confirm the navigation is same-origin with no cross-origin redirect. A missing opt-in on either page, or a cross-origin step, means the browser never creates a transition. The ready promise is not relevant yet, because no transition object exists.
Exercise
The transition starts and ready rejects. The page tags a thumbnail with post-image in pageswap, and the post page already has .post-hero img named post-image. Why does it fail, and where do you look?
Show answer
The names collide only if two elements on the same page carry post-image at capture time. Check that pageswap runs only on the list page and that a previous pagereveal handler cleared the name. Search the paused Elements panel or run document.querySelectorAll('*') and filter by getComputedStyle(el).viewTransitionName to find the duplicates.