fix: conditionally enable video skip on double click#989
Conversation
There was a problem hiding this comment.
Code Review
This pull request modifies the video playback script to conditionally register the double-click skip event handler based on the blockingNextFlag state. The review feedback points out a potential race condition where the event listener could be registered after the video component has already been unmounted, leading to memory leaks or unexpected errors. It is recommended to verify that the video element is still present in the DOM before registering the listener.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if (!blockingNextFlag) { | ||
| WebGAL.events.fullscreenDbClick.on(skipVideo); | ||
| } |
There was a problem hiding this comment.
由于 playVideo 中的初始化逻辑是在 setTimeout(..., 1) 中异步执行的,如果视频在播放开始后的极短时间内(例如 1ms 内)被卸载或跳过,restoreVolumeAndUnmount 会先被调用。此时,setTimeout 回调仍会执行,并注册全局双击事件监听器 WebGAL.events.fullscreenDbClick.on(skipVideo)。这会导致内存泄漏,并且在后续双击时可能会触发已销毁实例的 endPerform,引发非预期错误。
建议在注册事件监听器前,先检查 VocalControl 是否仍存在于 DOM 树中(即未被卸载)。
| if (!blockingNextFlag) { | |
| WebGAL.events.fullscreenDbClick.on(skipVideo); | |
| } | |
| if (!blockingNextFlag && document.contains(VocalControl)) { | |
| WebGAL.events.fullscreenDbClick.on(skipVideo); | |
| } |
|
不过我看之前改脚本这块的逻辑好像大致也是这样的,是改了演出系统的原因才导致失效的吗? |
fixes: #985
双击是通过事件直接调用 skipVideo → endPerform(),绕过了场景控制器的判断,设置
blockingNext无法阻止。