-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Prevent Adding View-Backed Nodes to Layer-Backed Hierarchies #3062
Conversation
|
||
for (ASDisplayNode *n in @[parent, a, b, c]) { | ||
for (ASDisplayNode *n in @[parent, a, b, c, d]) { |
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.
These tests forgot to set layerBacked
on the new subnode d
so they failed our new assertion. The method name is also super confusing so I updated 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.
Awesome find!
@@ -2551,6 +2551,11 @@ - (void)_insertSubnode:(ASDisplayNode *)subnode atSubnodeIndex:(NSInteger)subnod | |||
return; | |||
} | |||
|
|||
if (self.layerBacked && !subnode.layerBacked) { | |||
ASDisplayNodeFailAssert(@"Cannot add a view-backed node as a subnode of a layer-backed node. Supernode: %@, subnode: %@", self, subnode); |
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 swear this type of check existed before?
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 think so too, but the test that failed post-change is super old so maybe not… ¯_(ツ)_/¯
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.
yeah, this is really weird. The check did exist before, but I'm not sure how long ago. We should be pretty worried it vanished lol.
* Prevent adding view-backed nodes to layer-backed nodes * Do that in a different diff * Fix the message * Update tests * Fix the fix
Resolves #3038
Doing this will prevent required callbacks like
didMoveToWindow
from getting sent to our view.