mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
745ff1086a
Summary: Changelog: [Internal] # Problem Yoga internally uses address of owner to determine whether a node should be cloned or it shouldn't. During layout, it traverses the tree and looks whether current parent is equal to child's owner. If it isn't it means the yoga node is shared between 2+ trees and need to be cloned before mutated. Parent in yoga is stored as reference to the parent. We can run into an issue where yoga node is shared between 2+ trees, but its current parent is equal to child's owner. This is because we reallocate new parent at address where its previous parent lived. This happens over few iterations, the old parent is first deallocated. This is known as ABA problem. # Solution When we are cloning node, we loop over all children to see whether any of the is not using address of new `yogaNode_` as its owner. At this point we know this is accidental and set its owner to `0xBADC0FFEE0DDF00D`. We chose `0xBADC0FFEE0DDF00D` because when someone is debugging this in LLDB and prints this address, it will hint them that it was artificially set and can string search for it in the codebase. Reviewed By: shergin Differential Revision: D21641096 fbshipit-source-id: c8b1b4487ea02b367f5831c1cdac055bce79c856