fix: guard fluid mousemove while canvas is hidden (wallpaper mode) - #5
Open
Cyber-Yu-Git wants to merge 1 commit into
Open
fix: guard fluid mousemove while canvas is hidden (wallpaper mode)#5Cyber-Yu-Git wants to merge 1 commit into
Cyber-Yu-Git wants to merge 1 commit into
Conversation
When background is wallpaper, aqua.module.css hides the fluid canvas with display:none. The window-level mousemove listener kept dividing by the canvas rect (0x0) and fed NaN/Infinity pointer coordinates into the flow shader. NaN never decays in the ping-pong flow texture, permanently poisoning the simulation: after switching back to fluid the water no longer flows or follows the pointer. - skip pointer updates while the canvas rect is empty - skip the GL frame entirely while the canvas has zero size
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题 / Bug
背景切到「壁纸」之后,
aqua.module.css用display: none隐藏流体画布,但fluid-shader.ts里挂在window上的mousemove监听仍在运行:NaN 进入 flow shader 的 ping-pong 纹理后永不衰减(
NaN × decay = NaN),整个流体模拟被永久污染。切回「流体」之后水不再流动、也不再跟随鼠标,只能刷新页面(重新挂载)恢复。复现 / Repro
修复 / Fix
onMouseMove在画布 rect 为 0 时跳过指针更新,NaN 不再进入模拟改动两处:
src/client/fluid-shader.ts(源码)与lib/client.js(已发布 bundle,与 src 改动逐行一致;本环境没有 tsdown 构建链,可直接用 src diff 重建 bundle)。验证 / Verification
无头 Chromium 完整复现「隐藏画布 → 移动鼠标 → 恢复画布」流程,修复后流体正常渲染、持续动画,控制台无报错。