Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(): object caching is over-invalidating the cache #10294

Merged
merged 4 commits into from
Nov 26, 2024

Conversation

asturur
Copy link
Member

@asturur asturur commented Nov 24, 2024

Description

Working on the demos on the website i noticed the demo with the rotating tigers is extremely choppy.
I debugged and the cache was always being invalidated.

The culprit was this line here:
https://github.com/fabricjs/fabric.js/pull/10294/files#diff-4be7e8bea1e16b55606e7a9b175fc2a6e2e6290a82f3aec65b39425510ca73a6L488

The cache canvas is always an integer, but the cache width/height could be any number.
On top of that our scaling cache optimization was adding extra pixel to the canvas making the size of the needed canvas always different from the actual size we were assigning to it, this was happening for every object that doesn't have an integer size or for an integer sized object that was scaled.

Unless i m seeing something wrong, cache has been broken for very long time.

In Action

Copy link

codesandbox bot commented Nov 24, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link
Contributor

Build Stats

file / KB (diff) bundled minified
fabric 923.861 (-1.072) 306.700 (-0.273)

@asturur
Copy link
Member Author

asturur commented Nov 26, 2024

I checked this code at the best of my abilities, i m a bit confused how caching can be broken 3+ years and we didn't notice that was over drawing all the time. Hopefully i didn't break anything but i can't find anything broken.
now if you scale an object it will invalidate the cache, not in step of 10% but all the time, the other rules to invalidate cache still apply.

@asturur asturur merged commit 880c321 into master Nov 26, 2024
19 of 20 checks passed
@asturur asturur deleted the cache-invalidation-issue branch November 26, 2024 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant