Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

perf(timeline): ne plus re-rendre la timeline à chaque événement souris pendant un scrub

Etienne Lescotf40238538ebe
diff --git a/src/components/ai-edition/v4/V4Timeline.tsx b/src/components/ai-edition/v4/V4Timeline.tsx
index 8e53bf75f..de387bac6 100644
--- a/src/components/ai-edition/v4/V4Timeline.tsx
+++ b/src/components/ai-edition/v4/V4Timeline.tsx
@@ -402,8 +402,6 @@ export function V4Timeline({
playheadElRef.current.style.left = `${pct * 100}%`;
}
- // Optimistic local UI state update
- setScrubbingTimeSec(targetTime);
pendingSeekTimeRef.current = targetTime;
if (isImmediate) {
@@ -411,16 +409,28 @@ export function V4Timeline({
cancelAnimationFrame(rafSeekRef.current);
rafSeekRef.current = 0;
}
+ setScrubbingTimeSec(targetTime);
setCurrentTime(targetTime);
return;
}
- // Throttled store update / D3D seek via rAF to avoid IPC flooding
+ // Throttled store update / D3D seek via rAF to avoid IPC flooding.
+ //
+ // `setScrubbingTimeSec` est throttlé ICI AUSSI et n'est plus appelé depuis
+ // `pointermove`. Une souris émet 125 à 1000 événements par seconde ; à chacun,
+ // cet état local re-rendait `V4Timeline` en entier — clips, waveforms, régions —
+ // pour déplacer une tête de lecture que la ligne du dessus vient DÉJÀ d'écrire
+ // directement dans le DOM. Ce rendu React ne sert qu'aux consommateurs de
+ // l'override (timecode, overlay), qui n'ont aucune raison d'être rafraîchis plus
+ // vite qu'une frame. L'écriture DOM, elle, reste à chaque événement : la tête
+ // continue de coller au curseur.
if (rafSeekRef.current === 0) {
rafSeekRef.current = requestAnimationFrame(() => {
rafSeekRef.current = 0;
- if (pendingSeekTimeRef.current !== null) {
- setCurrentTime(pendingSeekTimeRef.current);
+ const pending = pendingSeekTimeRef.current;
+ if (pending !== null) {
+ setScrubbingTimeSec(pending);
+ setCurrentTime(pending);
}
});
}