Fix custom cursor flickering in web builds#103304
Fix custom cursor flickering in web builds#103304Chubercik wants to merge 1 commit intogodotengine:masterfrom
Conversation
|
I tested the issue's project with this PR, and the flickering is gone. Everything else works as expected (changing the cursor upon left click, switching back to the previous one upon release). I'm not 100% sure about the hashing, that is, whether we should worry about potential hash collisions. If anyone more experienced than me would like to weigh in on this, it would be greatly appreciated. |
|
BTW, this fixes the issue at hand (flickering when repeatedly changing the cursor to the same graphic), but I can imagine flickering would still be present if someone wanted to have an animated cursor by cycling through different graphics. Not a roadblock for this PR to be merged, but a more robust solution, if possible, would be nice. |
Implement caching of the custom cursor state in `DisplayServerWeb` to prevent redundant updates to the browser's cursor. This change computes a hash based on the cursor resource, shape, and hotspot, and only updates the browser's cursor when the hash changes. This mitigates the flickering observed in web exports when `set_custom_mouse_cursor()` is called every frame.
a60e7f3 to
df9d47f
Compare
|
Rebased 🔛🔝 |
|
Hey, is there any way to speed up merging of this fix? |
There was a problem hiding this comment.
I don't think it's the way to go. Implementing an hashing function just to cache a value such as setting a custom image for a cursor seems way overkill. And especially since the behavior would differ from every other platform.
(Edit: Implementing an hashing function the way it is currently done. I also thought implementing hashing, but the current API is ambiguous. What happens if we pass the same reference, but the actual data of the reference changed? Does it get cached? Currently, there's no caching on other platforms, and I don't see how we can implement a caching system on just a platform, especially since it there would be no way to bust the cache.)
The fix, IMHO, would be just to not update the cursor each frame. That's a limitation of the platform. See #102403 (comment) for an example of how to do it.
|
Superseded by #107586 (for now). |
Fixes #102403.
Implement caching of the custom cursor state in
DisplayServerWebto prevent redundant updates to the browser's cursor. This change computes a hash based on the cursor resource, shape, and hotspot, and only updates the browser's cursor when the hash changes. This mitigates the flickering observed in web exports whenset_custom_mouse_cursor()is called every frame.