Replies: 1 comment
-
reserved for screenshots |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I ll try to do my best to explain the scope of this change it requires having an understanding of how caching work, so please have a read here first:
http://fabricjs.com/fabric-object-caching (of course the interesting part is broken )
Today the cache makes a copy of the object as an image in a temporary canvas so that a series of complex operations can be simplified as a single drawImage.
This is a very simple and common approach that works very well for dragging one or more objects, or panning the canvas.
Now if you scale an object that will become quickly pixellated, when when you end your scaling transformation fabric will update the cache with a new image that is of the correct amount of pixels.
This is the BASE behaviour.
Now while i think that cache scaling is a perfectly good no brain compromise, some apps developer do not think so.
So we have some code in fabricJS that is detecting a scaling operation and that allow you to disable this behaviour
If you read this code it basically says, update the cache but if 'noScaleCache' is true and we are transforming, do it only if is not a scale transformation.
Now in case you want to disable this behavior you would end up with a scale operation trigger hundreds of cache invalidations and redraws, causing a lot of new canvases created and a lot of memory trashing and GC collecting.
So to avoid that when we create a cache canvas we create it a bit larger ( 10% i think ) so that a single canvas has space for more than a single size and you are trashing canvases only once in a while.
( note adds some perf inspection)
Now looking back this doesn't seem a smart choice anymore.
All those handling of specific cases makes the code harder to read and to understand for little gain.
This proposal is to evaluate the following change:
Beta Was this translation helpful? Give feedback.
All reactions