You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue: For any node, there is only one instance variable for pending layout (and when set, its constrained size is used for any new layout that is starting). This variable is thread safe, but it doesn't make sense for multiple threads to be using it at the same time.
Example diagram below. The main thread would be better off using size0, the last committed layout, than size1, which may be set in the middle of an unfinished layout pass.
This is important because the flexbox layout calculation (e.g. ASStackLayoutSpec always generates multiple pending layouts, and capturing one of these intermediate size constraints on another thread might produce incorrect results.
Proposed Solution:ASLayoutElementContext already exists per thread. Move pending layout (which contains the last constrained size) to this ASLayoutElementContext and delete the node's pending layout instance variable. Because there is only one ASLayoutElementContext per thread, a map from node to pending layout will be needed so that the pending layout for each node being used on that thread is stored / can be referenced.
Looks like ASLayoutElementContext is a struct and not an object. :(
hannahmbanana
changed the title
[ASLayoutContext] Pending Layout should be in thread local storage
[ASLayoutElementContext] Pending Layout should be in thread local storage
Jun 6, 2017
…rage.
Preliminary stab at issue TextureGroup#329. It builds, but -[ASAbsoluteLayoutSpecSnapshotTests testChildrenMeasuredWithAutoMaxSize]` test case fails.
Issue: For any node, there is only one instance variable for pending layout (and when set, its constrained size is used for any new layout that is starting). This variable is thread safe, but it doesn't make sense for multiple threads to be using it at the same time.
Example diagram below. The main thread would be better off using
size0
, the last committed layout, thansize1
, which may be set in the middle of an unfinished layout pass.This is important because the flexbox layout calculation (e.g.
ASStackLayoutSpec
always generates multiple pending layouts, and capturing one of these intermediate size constraints on another thread might produce incorrect results.Proposed Solution:
ASLayoutElementContext
already exists per thread. Move pending layout (which contains the last constrained size) to thisASLayoutElementContext
and delete the node's pending layout instance variable. Because there is only oneASLayoutElementContext
per thread, a map from node to pending layout will be needed so that the pending layout for each node being used on that thread is stored / can be referenced.Ideas per discussion between @nguyenhuy @Adlai-Holler @appleguy.
The text was updated successfully, but these errors were encountered: