[Perf] Focus guides: every pointer move re-renders the scene and re-serializes, re-parses and rewrites the guide layer
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 22/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- d3, react, typescript
- Ambito
- data-visualization
Direzione di ricerca
Start with the repro in packages/charts-core/test-repro/03b-crosshair-spring.test.ts and the focus path in focus-guide.ts, focus-layer.ts, motion.ts (applyStateFocus, paintFocus, and the track start around line 3990) and renderer.ts updateFocus. Done when the repro shows the crosshair x1 advancing across frames under data motion, and a repeated identical paintFocus triggers no renderSvg call. Part C (tooltip z-index and label layering) needs layout to verify, so it is not testable in jsdom.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Version: @tanstack/charts 1.1.0 (57774e1).
focusGuideX, focusGuideY and crosshair follow the cursor. With motion() they are repainted on every pointer move, and each repaint costs a whole-scene render (A), a markup round-trip of the guide layer (B) and writes to guide elements that did not change (C). The cost grows with the number of guide nodes, not with what moved. Related but different: #132, #179, #178.
Impact (bklit migration, Chrome, time-x line with two series, 60 synthetic moves 17 ms apart, 8 rounds): main-thread busy time per move was a median 7.07 ms (range 6.70-8.31) with native guides, and 2.1-3.2 ms with the same guide layer drawn by our own sibling element driven from onFocusChange. Line chart hover p95 was about 25-27 ms versus about 17-18 ms for a hand-written SVG equivalent.
A. Every paintFocus re-renders the whole scene
focusGuideXsetsretarget: true(focus-guide.ts:336-338).resolveFocusScenethen returns a new scene object on every call (focus-layer.ts:113-115).applyStateFocusseespresented.scene !== scene(motion.ts:898-903) and runsrenderSvg+animateSvg(motion.ts:918-921), even for an unchanged focus.- Test on main: two repeated identical
paintFocuscalls cause 2renderSvgcalls.
Expected: same resolved focus gives a cheap guide paint, no whole-scene render. Fix: memoize resolveFocusScene per (scene, focus).
B. The guide layer is reparsed from markup on every focus change (from this comment)
paintMotionSvgFocusGuides renders the layer to a string with renderFocusGuideLayer (motion.ts:1209). animateSvgFragment and reconcileChartSvgFragment then parse that string through template.innerHTML (motion.ts:751-753, reconcile.ts:67-68) before diffing. Removing only the pill, or only the crosshair and dots, saved nothing measurable.
Expected: patch guide marks in place, keyed by guide, with no markup round-trip. A per-guide static flag (or skipping guides whose descriptor is unchanged) would let a guide that only moves update its transform alone.
C. Unchanged guide elements are rewritten (from this comment)
On each pointer move the reconciler sets and removes data-ts-motion-role and rewrites transform on guide elements whose target did not change (motion.ts:1164-1212, motion.ts:2247-2285).
Measured on a production build (line chart with markers, about 50 guide nodes): about 1,080 getAttribute calls and 4 set/remove pairs of the attribute per move. With a stylesheet that uses :not([data-ts-motion-role]) (the only mid-tween guard, see #196), style recalc is about 1.9 ms per move. Skipping those writes brings it to about 0.
Expected: skip the attribute and transform writes on guide elements whose target is unchanged.
Crosshair spring restarts every frame during data motion
Moved to #208 (a bug: it contradicts motion.md, and A's memo does not fix it because the scene changes every frame).
Guide labels always paint below the tooltip
Moved to #132, which asks for the same label to get a background box.
Proposed fix
One rule for A-C: the same focus and the same targets is a no-op; otherwise patch the changed guide nodes in place, without re-rendering the scene or the layer markup.
- Lingua principale
- TypeScript
- Stelle
- 870
- Fork
- 57
- Merge medio
- 11h 58m
- PR unite (30g)
- 18
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TanStack/charts
-
[Perf] Canvas layer composition is quadratic: splitRenderLayers re-copies the node array per nodeAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug] Focus guides: `url(#id)` paints ignore `idPrefix`Forse già presa @getdownandcode l’ha presa 37 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
TanStack/charts#211 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Add reverse options to waffleY and waffleXForse già presa @tannerlinsley l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di TanStack/charts
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
fb55/htmlparser2#2579 ·
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue needs-review
Difficoltà 1/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno
-
Add Module DB RulesApertadocumentation public
Difficoltà 1/5 1-3 ore Idoneità per principianti 68/100
midnightntwrk/umbradb#65 ·
I maintainer di solito rispondono entro 2 giorni
-
area/channels kind/bug priority/medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
nanocoai/nanoclaw#4501 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
needs verification
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 13 giorni