Repository navigation
perf(web): scope detail-page render cost during viewport changes - #812
Conversation
Browser UI that animates the content viewport — Brave's hover sidebar is the reproducible case — made detail pages drop frames while Home stayed smooth. The cost was concentrated in three places, all of which stay scoped to detail pages rather than changing shared primitives. Containment. The hero is one layout/paint boundary, so resizing it cannot invalidate every rail below it, and its artwork sits behind `contain: strict` on the browser's cheap image path. Five full-hero gradient elements — a tint, two side fades, two bottom fades and a vignette — were each independently invalidated per frame; they collapse into two contained scrim surfaces around the ambient glow, preserving the original layer order exactly. The hero backdrop's `brightness()`/`saturate()` filter is replaced by a flat background wash. A filter on a full-hero element re-rasterizes on every frame of a resize; a flat tint composites. The wash is exposed as `--hero-backdrop-scrim` so themes keep the knob that `--hero-backdrop-brightness` gave them, including the light theme's brighter, more desaturated treatment. Deferral. Detail pages stack several image-heavy rails below the fold, so supporting sections get the same `content-visibility` treatment the home carousels already use, and each clipped Embla viewport is isolated so one rail cannot invalidate its neighbours. MangaContent is deliberately excluded: its only child is a single <ul> holding every chapter, and a 24rem intrinsic placeholder would collapse the whole list and make "Jump to chapter" scroll to an offset that is stale the moment the subtree lays out. Coalescing. Embla rebuilt its measurements on every frame of an animated resize; container resizes now settle into one reInit while a standalone slide resize keeps Embla's immediate path. The virtualized grid measures on the leading edge of a resize and reconciles once at the end, so row geometry never lags the reflowed grid. Ambient colour cleanup is deferred by a microtask so an outgoing detail surface cannot clear the property before the incoming one publishes, which was repainting the full-page gradient between routes. Interaction. Hover prefetch waits for a dwell, so a pointer sweeping a rail no longer starts cache work for every card it crosses; keyboard focus and touch intent still fire immediately. The card hover dim fades a fixed overlay instead of repainting a full-card background colour. Ports the detail-page performance work from #805 by @blurbery, rebuilt against main and re-scoped: the app-wide backdrop-filter removal and card hover changes from that branch are deliberately not included. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Warning Review limit reachedNext included review available in 44 minutes. View limit detailsLimit details: You’ve used the included review currently available. Your 100 included PR review attempts over the past 7 days set your current allowance at 1 review per hour. Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (20)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3d12537fc5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (resizeTimerRef.current === null) measure(); | ||
| else window.clearTimeout(resizeTimerRef.current); |
There was a problem hiding this comment.
Re-measure when the grid crosses a responsive breakpoint
During a continuous resize that crosses a grid breakpoint after the first notification, this branch suppresses every subsequent measurement until 120 ms after resizing stops. CSS immediately changes the number of columns, but ItemGrid continues using the stale columnCount to calculate row count, visible ranges, and item indices, so cards can be omitted, duplicated, or laid out beyond the virtualizer's reserved height for the duration of a browser-sidebar animation or window drag. Preserve coalescing for ordinary width changes, but measure when the computed column count changes.
Useful? React with 👍 / 👎.
…der-cost # Conflicts: # web/src/pages/ItemDetail/components/SeasonEpisodeGrid.tsx
Addresses Codex review feedback on #812. Coalescing every notification after the first was wrong for one case. CSS changes the column count the instant a drag crosses a breakpoint, but `columnCount` also slices the item list — `ItemGrid` derives `rowCount`, `startIndex` and `cellCount` from it — so holding the stale value until the resize settled omitted or duplicated cards for the rest of the gesture. Reading the column count is a style read; the React render is what the coalescing exists to protect. So the observer now reads the count on every notification and measures when it changed, while ordinary width changes within a breakpoint still collapse into one trailing reconcile. The regression test fails against the previous behaviour: it starts a drag, reflows the track to three columns mid-gesture, and asserts the layout follows on that notification rather than 120ms after the drag stops. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Problem
Related issue: N/A — extracted from #805, which has the original profiling.
Browser UI that animates the content viewport — Brave's hover sidebar is the
reproducible case — made detail pages drop frames during resize, scroll and pointer
movement, while Home stayed smooth. @blurbery profiled this with Chrome DevTools
traces on a signed-in deployment; the numbers in #805 show paint down 16.6% and the
max graphics-pipeline slice down 75.1% on the original branch.
Approach
The cost was concentrated in three places. Everything here stays scoped to detail
pages rather than changing shared primitives — that scoping is the main difference
from #805, which applied several of these fixes app-wide.
Containment. The hero becomes one layout/paint boundary, so resizing it cannot
invalidate every rail below it, and its artwork sits behind
contain: stricton thebrowser's cheap image path. Five full-hero gradient elements — a tint, two side fades,
two bottom fades and a vignette — were each independently invalidated per frame; they
collapse into two contained scrim surfaces around the ambient glow, preserving the
original layer order exactly.
The hero backdrop's
brightness()/saturate()filter is replaced by a flatbackground wash: a filter on a full-hero element re-rasterizes on every frame of a
resize, a flat tint composites. The wash is exposed as
--hero-backdrop-scrimsothemes keep the knob
--hero-backdrop-brightnessgave them — including the lighttheme, which sets a heavier wash to match its brighter, more desaturated treatment.
Deferral. Detail pages stack several image-heavy rails below the fold, so
supporting sections get the same
content-visibilitytreatment the home carouselsalready use, and each clipped Embla viewport is isolated so one rail cannot invalidate
its neighbours.
MangaContentis deliberately excluded. Its only child is a single<ul>holdingevery chapter, so a 24rem intrinsic placeholder would collapse the whole list and make
"Jump to chapter" smooth-scroll to an offset that is stale the moment the subtree lays
out. #805 applied it there.
Coalescing. Embla rebuilt its measurements on every frame of an animated resize;
container resizes now settle into one
reInitwhile a standalone slide resize keepsEmbla's immediate path. The virtualized grid measures on the leading edge of a resize
and reconciles once at the end, so row geometry never lags the reflowed grid — a
trailing-only debounce left virtual rows overlapping the already-reflowed grid for the
whole settle window. Ambient colour cleanup is deferred by a microtask so an outgoing
detail surface cannot clear the property before the incoming one publishes, which was
repainting the full-page gradient between routes.
Interaction. Hover prefetch waits for a dwell, so a pointer sweeping a rail no
longer starts cache work for every card it crosses; keyboard focus and touch intent
still fire immediately. The card hover dim fades a fixed overlay instead of repainting
a full-card background colour.
Validation
Confirmed the containment and deferral actually apply in a live signed-in session
rather than only in the stylesheet:
.item-detail-herocomputescontain: content,.hero-backdrop-artworkcomputescontain: strictwithfilter: none, the herorenders two scrim layers around a contained ambient glow,
--hero-backdrop-scrimresolves to
25%, and supporting-section children computecontent-visibility: auto.pnpm run build— passedpnpm exec vitest run— 2619 passedpnpm run lint— 0 errors (165 pre-existing warnings, unchanged baseline)pnpm run format:check— passedRisks
content-visibility: autois the sharp edge here: it makes off-screen contentnon-laid-out, which breaks anything that measures or scrolls into that subtree. The
MangaContent exclusion above is one instance found by inspection, and it is worth
checking whether any other detail section measures its own children.
The hero treatment is a visual change, not just a perf one — the scrim reproduces the
old gradient stack, but the artwork tint moves from a filter to a background wash.
Worth eyeballing in both light and dark themes; the light-theme scrim value is my
estimate of the equivalent of
brightness(1.15) saturate(0.6), not a measurement.Provenance
Ports the detail-page performance work from #805 by @blurbery, rebuilt against current
mainand re-scoped. The app-widebackdrop-filterremoval and the shared card hoverchanges from that branch are deliberately not included; the navigation rewrite is
still open (see #805).
Not ported: the
SeasonCarouseldwell-prefetch conversion, which needs a componentextraction for a row that typically holds under ten seasons.
AI Disclosure
decided which of the original branch's changes were in scope, and reviewed the
result against a live deployment. The underlying profiling and the original fixes
are @blurbery's.
from that branch were deliberately dropped here after review found they were
app-wide fixes for a detail-page problem, and the MangaContent exclusion is a
content-visibilitydefect found by that review rather than by the profiler.Checklist
🤖 Generated with Claude Code