-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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(): bubble dirty flag to parent #9741
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
Build Stats
|
cffaa02
to
b4e08e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
b4e08e3
to
57871cc
Compare
@@ -454,7 +454,7 @@ export class Group | |||
* @return {Boolean} | |||
*/ | |||
isOnACache(): boolean { | |||
return this.ownCaching || (!!this.group && this.group.isOnACache()); | |||
return this.ownCaching || (!!this.parent && this.parent.isOnACache()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
most of the time parent is unset, this would break the detection of isOnAcache for the objects that are not part of a multi selection.
This maybe should do something like
const container = this.parent || this.group
And then check the isOnACache of container?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parent is ALWAYS set
In fact group should be used ONLY for calcTransformMatrix
and for layout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok because ActiveSelection has its own specific exitGroup.
The division between enterGroup, exitGroup, _enterGroup and _exitGroup are confusing at best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True
(this.constructor as typeof FabricObject).stateProperties.includes( | ||
key | ||
))) && | ||
this.parent._set('dirty', true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here i have the same exact concern, group is our main property, while parent is just an exception sometimes.
So we need to check parent or group, with precedence to parent.
Also i think is ok to skip const groupNeedsUpdate = this.group && this.group.isOnACache();
is a bit of hit and miss. Is true we don't care if the group is not cached to set it as dirty, since is just a boolean, but if the group is cached on a different cache than the object, at that point the invalidation isn't necessary and is a cost. ( reading the code today this check isn't made, but if say we are going always to flag a group as dirty we are cutting that away )
What is the reason behind changing the dirty flag? what brought you to change it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but if the group is cached on a different cache than the object
That is not possible in fabric, that is why there is isOnACache
to begin with, isn't it?
And it doesn't make sense.
If the group is caching then the object is drawn on that cache so that cache is dirty if the object is dirty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you are right the separate cache is going to make the lower cache dirty anyway.
So the issue is just parent vs group
To see that the dirty flag is working as expected with nested selected objects |
Just check it out from the branch and add it to this branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I m ok with this PR as long the test you want to do are done on that template.
57871cc
to
cc00726
Compare
tested |
Description
As part of the group rewrite we exposed a
parent
ref on the object #8951 .As part of the layout manager fixes an invalidation bug surfaced #9651 .
Fabric relays on
Object#_set
to bubble cache invalidation to the parent.I forgot to fix the invalidation logic when I exposed the parent ref so it still invalidated the group ref.
The bug occurs when a nested object is part of an
ActiveSelection
.In that case the group ref is the active selection and the parent ref is the group.
ActiveSelection
does not render anything, therefore it doesn't cache meaning that it is pointless to flag it as dirty as opposed to the parent.This PR will fix the mentioned bug.
I also changed the bubbling logic to always bubble a dirty flag regardless of caching state.
In Action