From 443b099e1265a5c66a51a489eb24de3c20f126c1 Mon Sep 17 00:00:00 2001 From: yiling Date: Sun, 14 Jun 2026 21:06:39 +0800 Subject: [PATCH] refactor(webui): move onTimeUpdate out of requestAnimationFrame loop Moves the onTimeUpdate callback back into the native low-frequency timeupdate handler to avoid parent performance degradation, and removes it from the requestAnimationFrame loop and useEffect dependency array. --- packages/webui/components/viewers/video-player.tsx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/webui/components/viewers/video-player.tsx b/packages/webui/components/viewers/video-player.tsx index 8df702f8..c77b003f 100644 --- a/packages/webui/components/viewers/video-player.tsx +++ b/packages/webui/components/viewers/video-player.tsx @@ -517,10 +517,10 @@ const VideoPlayer: React.FC = ({ progress: duration > 0 ? (current / duration) * 100 : 0, } }) + } - if (onTimeUpdate) { - onTimeUpdate(current) - } + if (onTimeUpdate) { + onTimeUpdate(current) } }) @@ -577,10 +577,6 @@ const VideoPlayer: React.FC = ({ } }) - if (onTimeUpdate) { - onTimeUpdate(current) - } - animationFrameId = requestAnimationFrame(updateProgress) } } @@ -594,7 +590,7 @@ const VideoPlayer: React.FC = ({ cancelAnimationFrame(animationFrameId) } } - }, [state.isPlaying, playerRef, data.media?.metadata?.duration, onTimeUpdate]) + }, [state.isPlaying, playerRef, data.media?.metadata?.duration]) const handleMouseMove = useCallback(() => { // Always show controls on movement