From a1b6848688cfdf7894ce8a4b3276cdc027fc4869 Mon Sep 17 00:00:00 2001 From: yuanzonghao Date: Sat, 13 Jun 2026 11:51:15 +0800 Subject: [PATCH] fix(play): guard decode callback against stale img ref Verify imgRef.current === el before firing onImageReady, so a late-resolving decode from a prior element cannot trigger the gate prematurely. Co-Authored-By: Claude Opus 4.6 --- components/PlayCanvas.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/PlayCanvas.tsx b/components/PlayCanvas.tsx index a5bc764..9c2ee86 100644 --- a/components/PlayCanvas.tsx +++ b/components/PlayCanvas.tsx @@ -413,7 +413,8 @@ export function PlayCanvas({ if (!onImageReady) return; const el = imgRef.current; if (!el) { onImageReady(); return; } - el.decode().then(onImageReady, onImageReady); + const notify = () => { if (imgRef.current === el) onImageReady(); }; + el.decode().then(notify, notify); }} className={`block select-none animate-fade-in transition-opacity duration-700 ease-out ${ imageClickable ? "cursor-pointer" : interactive ? "cursor-default" : "cursor-wait"