Skip to content

Commit eb8e446

Browse files
vanceingallsclaude
andcommitted
fix(studio): break iframe ref update loop causing flickering
Fixes an infinite update loop between handlePreviewIframeRef and NLELayout's onIframeRef effect — the callback identity change triggered the effect which re-called the callback, creating a render loop visible as "Maximum update depth exceeded" in dev mode and intermittent flickering in production. - Guard setPreviewIframe with identity check (skip if same iframe) - Use ref for onIframeRef in NLELayout effect to avoid re-firing on callback identity change Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2f7fcbf commit eb8e446

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

packages/studio/src/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ export function StudioApp() {
261261
const { syncPreviewTimelineHotkey, syncPreviewHistoryHotkey } = appHotkeys;
262262
const handlePreviewIframeRef = useCallback(
263263
(iframe: HTMLIFrameElement | null) => {
264+
if (previewIframeRef.current === iframe) return;
264265
previewIframeRef.current = iframe;
265266
setPreviewIframe(iframe);
266267
syncPreviewTimelineHotkey(iframe);

packages/studio/src/components/nle/NLELayout.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,11 @@ export const NLELayout = memo(function NLELayout({
234234
const currentLevel = compositionStack[compositionStack.length - 1];
235235
const directUrl = compositionStack.length > 1 ? currentLevel.previewUrl : undefined;
236236

237+
const onIframeRefRef = useRef(onIframeRef);
238+
onIframeRefRef.current = onIframeRef;
237239
useEffect(() => {
238-
onIframeRef?.(iframeRef.current);
239-
}, [compositionStack.length, onIframeRef, refreshKey, iframeRef]);
240+
onIframeRefRef.current?.(iframeRef.current);
241+
}, [compositionStack.length, refreshKey, iframeRef]);
240242

241243
// Save master seek position before drilling down so we can restore it on back-navigation.
242244
// saveSeekPosition() sets pendingSeekRef in useTimelinePlayer which onIframeLoad reads.

0 commit comments

Comments
 (0)