mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-14 10:20:11 +00:00
[ASDisplayNode] Don't force a layout pass on a visible node that enters preload state (#751)
- After #706, a layout pass is forced on an ASM-enabled node that enters preload state to make sure that its subnodes can start preloading as well. However, when the node is visible, a (coalesced, thus more efficient) layout pass will be triggered by CA soon anyways, so rely on it instead.
This commit is contained in:
parent
4776cb3dcd
commit
2e98588372
@ -10,7 +10,7 @@
|
|||||||
- [ASScrollNode] Ensure the node respects the given size range while calculating its layout. [#637](https://github.com/TextureGroup/Texture/pull/637) [Huy Nguyen](https://github.com/nguyenhuy)
|
- [ASScrollNode] Ensure the node respects the given size range while calculating its layout. [#637](https://github.com/TextureGroup/Texture/pull/637) [Huy Nguyen](https://github.com/nguyenhuy)
|
||||||
- [ASScrollNode] Invalidate the node's calculated layout if its scrollable directions changed. Also add unit tests for the class. [#637](https://github.com/TextureGroup/Texture/pull/637) [Huy Nguyen](https://github.com/nguyenhuy)
|
- [ASScrollNode] Invalidate the node's calculated layout if its scrollable directions changed. Also add unit tests for the class. [#637](https://github.com/TextureGroup/Texture/pull/637) [Huy Nguyen](https://github.com/nguyenhuy)
|
||||||
- Add new unit testing to the layout engine. [Adlai Holler](https://github.com/Adlai-Holler) [#424](https://github.com/TextureGroup/Texture/pull/424)
|
- Add new unit testing to the layout engine. [Adlai Holler](https://github.com/Adlai-Holler) [#424](https://github.com/TextureGroup/Texture/pull/424)
|
||||||
- [Automatic Subnode Management] Nodes with ASM enabled now insert/delete their subnodes as soon as they enter preload state, so the subnodes can preload too. [Huy Nguyen](https://github.com/nguyenhuy) [#706](https://github.com/TextureGroup/Texture/pull/706)
|
- [Automatic Subnode Management] Nodes with ASM enabled now insert/delete their subnodes as soon as they enter preload state, so subnodes can start preloading right away. [Huy Nguyen](https://github.com/nguyenhuy) [#706](https://github.com/TextureGroup/Texture/pull/706) [#751](https://github.com/TextureGroup/Texture/pull/751)
|
||||||
- [ASCollectionNode] Added support for interactive item movement. [Adlai Holler](https://github.com/Adlai-Holler)
|
- [ASCollectionNode] Added support for interactive item movement. [Adlai Holler](https://github.com/Adlai-Holler)
|
||||||
- Added an experimental "no-copy" rendering API. See ASGraphicsContext.h for info. [Adlai Holler](https://github.com/Adlai-Holler)
|
- Added an experimental "no-copy" rendering API. See ASGraphicsContext.h for info. [Adlai Holler](https://github.com/Adlai-Holler)
|
||||||
- Dropped support for iOS 8. [Adlai Holler](https://github.com/Adlai-Holler)
|
- Dropped support for iOS 8. [Adlai Holler](https://github.com/Adlai-Holler)
|
||||||
|
|||||||
@ -3079,16 +3079,23 @@ ASDISPLAYNODE_INLINE BOOL subtreeIsRasterized(ASDisplayNode *node) {
|
|||||||
ASDisplayNodeAssertMainThread();
|
ASDisplayNodeAssertMainThread();
|
||||||
ASDisplayNodeAssertLockUnownedByCurrentThread(__instanceLock__);
|
ASDisplayNodeAssertLockUnownedByCurrentThread(__instanceLock__);
|
||||||
|
|
||||||
if (self.automaticallyManagesSubnodes) {
|
// If this node has ASM enabled and is not yet visible, force a layout pass to apply its applicable pending layout, if any,
|
||||||
// Tell the node to apply its applicable pending layout, if any, so that its subnodes are inserted/deleted
|
// so that its subnodes are inserted/deleted and start preloading right away.
|
||||||
// and start preloading right away.
|
//
|
||||||
//
|
// - If it has an up-to-date layout (and subnodes), calling -layoutIfNeeded will be fast.
|
||||||
// If this node has an up-to-date layout (and subnodes), calling layoutIfNeeded will be fast.
|
//
|
||||||
//
|
// - If it doesn't have a calculated or pending layout that fits its current bounds, a measurement pass will occur
|
||||||
// If this node doesn't have a calculated or pending layout that fits its current bounds, a measurement pass will occur
|
// (see -__layout and -_u_measureNodeWithBoundsIfNecessary:). This scenario is uncommon,
|
||||||
// (see __layout and _u_measureNodeWithBoundsIfNecessary:).
|
// and running a measurement pass here is a fine trade-off because preloading any time after this point would be late.
|
||||||
// This scenario should be uncommon, and running a measurement pass here is a fine trade-off because preloading
|
//
|
||||||
// any time after this point would be late.
|
// Don't force a layout pass if the node is already visible. Soon CoreAnimation will trigger
|
||||||
|
// a (coalesced, thus more efficient) pass on the backing store. Rely on it instead.
|
||||||
|
BOOL shouldForceLayoutPass = NO;
|
||||||
|
{
|
||||||
|
ASDN::MutexLocker l(__instanceLock__);
|
||||||
|
shouldForceLayoutPass = _automaticallyManagesSubnodes && !ASInterfaceStateIncludesVisible(_interfaceState);
|
||||||
|
}
|
||||||
|
if (shouldForceLayoutPass) {
|
||||||
[self layoutIfNeeded];
|
[self layoutIfNeeded];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user