Skip to content
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

Make ASCollectionElement Public #1303

Merged
merged 2 commits into from
Mar 5, 2019
Merged

Make ASCollectionElement Public #1303

merged 2 commits into from
Mar 5, 2019

Conversation

JonathanDowning
Copy link
Contributor

I'm having a problem with using AsyncDisplayKit with Carthage.

I've previously used Cocoapods with my project, but whilst changing to Carthage, I noticed that ASCollectionElement.h is private.

I presume this is a mistake as ASCollectionElement is referenced in other public headers in this project.

@CLAassistant
Copy link

CLAassistant commented Jan 6, 2019

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@Adlai-Holler Adlai-Holler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! Thanks for fixing!

@Adlai-Holler Adlai-Holler merged commit 6dc0edf into TextureGroup:master Mar 5, 2019
hebertialmeida pushed a commit to hebertialmeida/Texture that referenced this pull request May 10, 2019
* Update AsyncDisplayKit.h

* Update project.pbxproj
@dskuza
Copy link

dskuza commented Dec 27, 2019

I noticed this PR was merged into master, but is still missing from the 2.8.1 release (which is dated post-merge). Is there insight into when this will be available? I'd like to stick to semver rather than "master" in my Cartfile.

bolsinga added a commit that referenced this pull request May 21, 2020
* Extended IGListKit support for node deselect, highlight and unhighlight

* Proposal of renaming willDisplayItemWithNode and didEndDisplayingItemWithNode to be similiar to UICollectionView

* Extended support for IGListDisplayDelegate

* Updated changelog with displaying delegates change

* Removed extra deprecation supression flag

* Reverted ASCollectionNode changes and implemented displaing delegate with indexPathForNode:

* Sending a real UICollectionViewCell to the delegate if not nil

* Added safety check for nil indexPaths

* Discard any CHANGELOG changes for fix Danger error

* Add an experimental flag to use native dispatch_apply (#1345)

* Add an experimental flag to use native dispatch_apply instead of our core count * 2 approach. This has shown performance wins in some profiling.

* Add in other places

* Don't return non-animated GIFs for animation (update to latest PINRemoteImage beta) (#940)

* Don't return non-animated GIFs for animation

* Update to latest PINRemoteImage beta

* Fix typos  (#1348)

* Update containers-overview.md

* Update subclassing.md

* Update node-overview.md

ASImageNode, ASNetworkImageNode and ASMultiplexImageNode are in place of UIImageView, not UIImage.

* Revert "Have node and controller share lock (#1227)" (#1347)

This reverts commit 2baa943.

* Don't compile out ASExperimentalTextNode if ASTextNode is compiled out (#1353)

* Lock up to yogaRoot during layout to avoid deadlocks. (#1356)

* Lock up to yogaRoot during layout to avoid dead lock.

1) lock to root for tree
2) lock self to change parent (& consequently root)
3) Implement ASLocking (tryLock) on ASNodeController
4) add lockPair to try-lock node & controller together
5) lock controllers if they exist in lockToRoot...

Disable some asserts due to lock to root. :(

LL# No commands remaining.

* Add macro so non-Yoga still builds :)

* wut

* Update layout-transition-api.md (#1357)

* Optimize ASTwoDimensionalArrayUtils (#1351)

* Optimize ASTwoDimensionalArrayUtils

These methods are called on the main thread during range controller updates (i.e. every frame) and so they should be as fast as possible.

* Rename

* Use vector instead of stack array to handle really big cases (e.g. photos)

* If we check for batching before content size is available we'll always fetch (#1355)

* Do not lock the nodeController if we are not locking to root. (#1360)

Doing so leaves it locked when we elsewhere explicitly unlock the node to ascend.

* Resolve root constrained size before informing delegate to resolve infinite layout loop. (#1359)

* Add `setNeedsLayout` to yoga tree changes. (#1361)

* Make ASCollectionElement Public (#1303)

* Update AsyncDisplayKit.h

* Update project.pbxproj

* Optimize _assertSubnodeState (#1352)

* Optimize _assertSubnodeState

This method is actually pretty painful in today's world. In one iPad mini trace, the first page of nodes spent 6.6ms in this call, just in time profiler.

* Clean it up, check count

* Check the right value

* _ASCollectionViewCell - The point isn't converted before to send to node, impossible to touch button into the node hierarchy (#1362)

* Revert node call, useless, the node has a ASDisplayView, and this view forward on the node in first.

* Use convertPoint to convert the given point in hittest & pointInside methods.
Keep the standard usage if the node didn't rasterized a view.

* Removed isNodeLoaded, finally it's useless in this case
In these methods, we are on the mainThread, we can create the view if the view is not created.

* Optimize ASCATransactionQueue (#1350)

* Optimize ASCATransactionQueue. This queue is very busy, and it runs on the main thread so it's important for it to be fast.

Avoid waking up the run loop for every single node.
Avoid a ton of NSPointerArray overhead that we don't need.
Avoid retain/release traffic on the singleton by using an inline function. I confirmed that in release mode, the static __strong is correctly inlined and no ARC traffic is incurred.

* Comment

* Unlock right

* Remove magic number

* Cleanup Yoga Categories (#1364)

* Add forwarding of UIAccessibilityAction methods (#1344)

* Add forwarding of UIAccessibilityAction methods

* Use OCMock for testing UIAccessibilityAction method forwarding

* Don't add extraneous truncation token during kCTLineTruncationMiddle. (#1297)

* Don't add extraneous truncation token during kCTLineTruncationMiddle

* Expand these comments a little.

* Update the FAQ to throw less shade. (#1379)

* Update the FAQ to throw less shade.

Both of these technologies have their place, no point in being assholes.

* Update faq.md

* [Updated Snapshots] Don't add extraneous truncation token during kCTLineTruncationMiddle (#1375)

* Don't add extraneous truncation token during kCTLineTruncationMiddle

* Expand these comments a little.

* Update snapshot tests with beautiful correct behavior

* Launches switching ASNetworkImageNode callbacks to global queue. (#1369)

* Launches switching ASNetworkImageNode callbacks to global queue.

* Good catch configuration tests!

* Make ASTextNode2 more forgiving when searching for links (#1374)

* Make ASTextNode2 more forgiving when searching for links by searching a 44x44 square around the touch

* Trailing whitespace

* Safely handle end-of-line

* Experiment with different strategies for image downloader priority (#1349)

Right now when an image node enters preload state, we kick off an image request with the default priority. Then when it enters display state, we change the priority to "imminent" which is mapped to the default priority as well. This means that requests from preload and display nodes have the same priority and are put to the same pool. The right behavior would be that preload requests should have a lower priority from the beginning.

Another problem is that, due to the execution order of -didEnter(Preload|Display|Visible)State calls, a node may kick off a low priority request when it enters preload state even though it knows that it's also visible. By the time -didEnterVisibleState is called, the low priority request may have already been consumed and the download/data task won't pick up the new higher priority, or some work needs to be done to move it to another queue. A better behavior would be to always use the current interface state to determine the priority. This means that visible nodes will kick off high priority requests as soon as -didEnterPreloadState is called.

The last (and smaller) issue is that a node marks its request as preload/low priority as soon as it exits visible state. I'd argue that this is too agressive. It may be reasonble for nodes in the trailing direction. Even so, we already handle this case by (almost always) have smaller trailing buffers. So this diff makes sure that nodes that exited visible state will have imminent/default priority if they remain in the display range.

All of these new behaviors are wrapped in an experiment and will be tested carefully before being rolled out.

* Add imports

* Fix build failure

* Encapsulate common logics into methods

* Address comments

* Whoops, someone forgot an else! (#1385)

Luckily it seems this didn't cause huge memory bloat because there's
a check below that keeps the display flag from being set in low memory
conditions when the node is off the screen.

* Catch invalid sizes during yoga layout (#1376)

* Correct View vs. Layer here (tho it doesn't make any difference) (#1378)

Older FBSnapshot versions, however, don't use VerifyViewOrLayer

* Expose initial constrained size before layout in case anyone is interested later during the layout on the same thread. (#1377)

Optionally, clients are expected to clean it up after usage to avoid accessing outdated data.

* Assert for context creation failure during displayBlock. (#1373)

Nothing good can possibly happen if we continue without one.

* Fix an issue where state change notifications can be sent mulitple times. (#1372)

Before the change: both - (void)setShouldInvertStrongReference:(BOOL)shouldInvertStrongReference and - (void)setNode:(ASDisplayNode *)node will call through [self setupReferencesWithNode:node]; which call the [node addInterfaceStateDelegate:self];

* Add Yoga support to ASButtonNode (#1381)

* Add Yoga support to ASButtonNode

* Drop unowned ASLayoutElementStyle parameter

* Fix access of Yoga properties

* Move ASButtonNode Yoga logic to Category

* Update header

* Fix CTLineRef leaks (#1386)

Found by Clang Static Analyzer:

~/Texture/Source/ASTextNode2.mm:663:39: warning: Potential leak of an object stored into 'truncationTokenLine'
      CTLineRef truncationTokenLine = CTLineCreateWithAttributedString((CFAttributedStringRef)_truncationAttributedText);
                                      ^
~/Texture/Source/ASTextNode2.mm:666:49: warning: Potential leak of an object stored into 'additionalTruncationTokenLine'
      CTLineRef additionalTruncationTokenLine = CTLineCreateWithAttributedString((CFAttributedStringRef)_additionalTruncationMessage);
                                                ^
2 warnings generated.

* Correct attributes lookup for supplementary elements. (#1318)

* Need some more locks for working with calculated yoga layouts (#1388)

* Adds support for using UIGraphicsImageRenderer in ASTextNode. (#1384)

* Adds support for using UIGraphicsImageRenderer in ASTextNode.

In many cases this reduces the backing store of text nodes by 1/2.

* Guard for UIGraphicsRenderer availability.

* Comma

* Add UIDataSourceModelAssociation to ASTableView and ASCollectionView (#1354)

* Add UIDataSourceModelAssociation protocol conformance to ASTableView and ASCollectionView.

* Implementing review feedback from @Adlai-Holler

* Rename ASDN C++ namespace to AS (#1366)

* Rename ASDN C++ namespace to "AS." Referring to the framework as ASDisplayNode is pretty out-dated and verbose. See CoreAnimation which usees CA for their internal namespace.

More using

* More cases

* Clean up a clang analyzer cast error (#1387)

~/Texture/Source/Private/ASMutableElementMap.mm:32:24: warning: Conversion from value of type 'NSMutableArray<NSMutableArray *> *' to incompatible type 'ASMutableCollectionElementTwoDimensionalArray *'
    _sectionsOfItems = (id)ASTwoDimensionalArrayDeepMutableCopy(items);
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

* Update for 9.4.1 CI (#1392)

* Remove experimental features (exp_skip_a11y_wait && exp_new_default_cell_layout_mode) (#1383)

* Remove experimental features

* prevent blocking main thread

* remove small content all together as none is the default

* Update ASExperimentalFeatures.h

* Make experiment checks faster (#1393)

* Make experiment checks use dispatch_once when not debugging, clean up singleton

* One more

* Pull out the variable

* Make shared CA transaction queue variable extern so it's actually shared (#1397)

* Fix header typo (#1402)

* Context is a pretty general name that will cause conflicts with subclasses (#1399)

* Suppress documentation warnings when using external libraries (#1401)

Fixes 1400

* Add layer-action support to nodes (#1396)

* Add layer-action support to nodes, unify hierarchy notifications on it

* Better pending state

* Fix bool

* Skip extra copy

* Never run default actions

* Continue the search

* Avoid an unnecessary lock & unlock pair in ASMainSerialQueue (#1409)

* Add clang-format for a common source code format (#1365)

* Add clang-format

* Update format to be as close as our current style

* Fix GIF Caching (#1405)

* Add support for reverse direction to yoga layouts (#1413)

* Add support for reverse direction to yoga layouts

* #ifdef YOGA yoga-specific additions

* oops

* Only set ASLayoutElementStyle delegate if Yoga is enabled (#1417)

* Fix bug in ASRangeController that causes some cell nodes of a collection view which is about to becomes invisible to load their backing view/layer and render (#1418)

* Fix a bug with Yoga nodes whose position change and don't update. (#1408)

* Follow up on the ASRangeController fix in #1418 (#1419)

The changes in #1418 is a bit too aggressive when it comes to nodes that are in display range. It forces those nodes to not preload.

Also update the changes to avoid diluting the experiment data by triggering too broadly (i.e avoid triggering when the old and new implementations yield the same result leading to no behavior change).

* Dev docs for threading in Texture (#1319)

* Getting started on adding threading by example

* writing writing writing

* more info

* More threading

* More more more

* Threading

* self lock

* Some language fixes

* Update docs/_docs/development/threading.md

Co-Authored-By: mikezucc <mikezuccarino@gmail.com>

* fix image references

* Removed locked jekyll version (#1322)

* showcase.md updated (#1421)

* Experiment with disabling ASViewController background dealloc (#1420)

* [Experiment] Dont forget about these collection view background deallocs (#1424)

* Dont forget about these collection view background deallocs

* Also Table view for completeness

* Fix retain cycle with transaction operations (#1429)

Add unit tests that help find cycles. `-testWeakWithSingleOperation` fails without the code fix applied.

* Replace +load initializers with __attribute__((constructor)) functions (#1425)

* Replace +load initializers with __attribute__((constructor)) functions

* Updating the documentation for textureDidInitialize, per @nguyenhuy

* Fix dealloc on bg (#1410)

* fix SIMULATE_WEB_RESPONSE not imported #449

* Fix to make rangeMode update in right time

* remove uncessary assert

* Fix collection cell editing bug for iOS 9 & 10

* Revert "Fix collection cell editing bug for iOS 9 & 10"

This reverts commit 06e18a1.

* Fix dealloc long gesture in background

* Add support for clipping only specific corners, add unit tests (#1415)

* Add support for clipping only specific corners, add unit tests

* Remove some cleanup to make the diff smaller

* Fix

* [ASImageNode]fix incorrect backing size calculation (#1189)

* fix backing size for image node which content mode is scaleAspectFit

* chore: update comments and naming

* add change log

* Update CHANGELOG.md

* Update CHANGELOG.md

Co-Authored-By: junjielu <348649634@qq.com>

* add unit test for backing size calculation

* correct license

* Have image nodes draw into opaque contexts automatically if possible (#1432)

* Have image nodes draw into opaque contexts if the image is opaque and it fills the context

* Call backingSize once

* Fix typo in batch-fetching-api.md (#1437)

* [ASDisplayNode] Stop infinite layout in _u_measureNodeWithBoundsIfNecessary (#1434)

We came across an infinite layout loop in `_u_measureNodeWithBoundsIfNecessary`. After requesting a layout from above, the sizes between pending and caluclated layout still do not match. We continue to prefer to use the pending layout and ask for another layout loop from above. We can’t seem to break out of this loop. The solution (thanks to Huy for the guidance) was to nil out the pending layout we get from requesting the layout from above.

I was only able to reproduce this when working with a node in a `UINavigationBarItem’s` `titleView`. I think that UIKit must be doing something sneaky with setting the frame on the view. While I was not able to create a unit test to catch this issue (I tried for a long time, and can post what I’ve come up with to see if anyone has any suggestions), I was able to create a pretty simple example project that shows the behavior:
https://github.com/rcancro/TextureLayoutLoopExample

* Add a verbose log for locking operations. Has no effect in production (#1436)

* Add a verbose log for locking operations. Has no effect in production

* Need check

* Wrap transaction operation retain cycle fix in an experiment (#1438)

* Wrap transaction operation retain cycle fix in an experiment

This is a follow on to #1429.

* fix typo in experiment name. fix copyright in tests file.

* Fix scroll node in yoga (#1435)

* fix SIMULATE_WEB_RESPONSE not imported #449

* Fix to make rangeMode update in right time

* remove uncessary assert

* Fix collection cell editing bug for iOS 9 & 10

* Revert "Fix collection cell editing bug for iOS 9 & 10"

This reverts commit 06e18a1.

* Fix child not fit to full scroll node's bounds when flex_grow = 1.0 is used on child

* Fix the stub for layerActionForKey: to let CA continue the search (#1441)

* Fix the stub for layerActionForKey: to let CA continue the search

* Kick CI

* Revert "Have image nodes draw into opaque contexts automatically if possible (#1432)" (#1443)

This reverts commit 28522ce.

* Use instance lock for ASPrimitiveTraitCollection (#1442)

* Use instance lock for ASPrimitiveTraitCollection

* Remove the atomic

* Simplify ASTraitCollection propagation in ASViewController (#1447)

* Use AS::Mutex in ASCollectionElement (#1445)

* [ASTextNode] Maintain isAccessibilityElement setting on text nodes when updating text (#1326)

* Add didEnterHierarchy/didExitHierarchy to ASNodeController. (#1444)

* Fix wrongly formatted RELEASE link (#1453)

* Only create activities during debug (#1456)

* [#1451] Add support for UIAccessibilityCustomAction (#1452)

This PR adds support for UIAccessibilityCustomAction propagation through ASPendingState so that it can be picked up by VoiceOver.

* Shut down graphics contexts experiment (#1458)

* Shut down graphics contexts experiment

* Remove dead import

* Remove gone class

* Remove lock of ASTextNodeRendererKey (#1454)

* Remove lock of ASTextNodeRendererKey

* Remove class check for isEqual

* Add const specifier to function parameter

* Fixes typo

* Fixes typo

* Disable ASAssertLocked and ASAssertUnlocked (#1412)

* Try to remove global lock when initialising TextKit components (#1455)

* Try to remove global lock when initialising TextKit components

* Adding experiment flag to dis/enable lock of textkit component

* Adding tests

* code clean

fix typo

Make remove lock optional

Keep locks

code clean

* Make ASCollectionNode's pan gesture customizable (#1457)

* changes done

* complete set of uigesturedeleagte methods

* Remove iOS 8 support from logging code. (#1462)

* Drop support for Xcode 8 and fix some compiler warnings (#1463)

* Remove ASEventLog (#1460)

* Remove ASEventLog. We'll focus on ASLog for the future, possibly making it triggerable on a per-node basis

* See ya!

* Hello semicolon

* Remove refs to gone tree methods

* Fix

* Remove irrelevant change, kick CI

* Clean up

* Cover the other background dealloc surfaces (#1464)

* Passthrough pagingEnabled for ASCollectionNode / ASTableNode (#1466)

* Passthrough pagingEnabled for ASCollectionNode and ASTableNode

* Add tvOS handling

* Fix open context bug introduced in #1458 (#1468)

* Make sure all ASDisplayNode properties have backing ivars for consistency. (#1475)

* Make sure all ASDisplayNodes have backing ivars for consistency.

Found this by enabling #pragma clang diagnostic error "-Wobjc-missing-property-synthesis" for ASDisplayNode. One property is unused, saving 8 bytes of heap space per instance on 64-bit builds. Implement setter/getters for these properties, and add appropriate locking. add the warning as error to the build for this file.

* Ensure ASControlMode properties lock before accessing their ivars (#1476)

Enable `#pragma clang diagnostic error "-Wobjc-missing-property-synthesis"` for this file.

* Add a new "global drawing" experiment to use UIGraphicsRenderer (#1469)

* Add a new "global drawing" experiment to use UIGraphicsRenderer everywhere, when available

* Fix logic

* Use preferredFormat

* Cut version 2.8.1 (#1491)

* Clean up documentation issues around periods (#1490)

There were so unnecessary `'` around periods for some reason. Just deleting those because they are distracting.

* Minor update in change log #changelog (#1492)

* Ship ASExperimentalFixRangeController (#1486)

* Shrink _ASCollectionPendingState from 144 to 128 bytes, a 12.5% reduction (#1485)

* Shrink _ASCollectionPendingState from 144 to 128 bytes, a 12.5% reduction

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* address review comments. move enums out. add comment. rename struct to _flags

* fix a missing rename

* Shrink _ASPendingState from 824 to 808 bytes, reduction of ~2% (#1483)

* Shrink _ASPendingState from 824 to 808 bytes, reduction of ~2%

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Shrink ASPendingState BOOLs. Use unsigned int for these bitfields for clarity. Separate from `_flags` as that struct is compared to `0` for testing. The `_boolFlags` struct is just storing other `BOOL`s.

* rename struct fields as suggested in garret's review.

* Shrink ASDisplayNode from 1072 to 968 bytes, reduction of 10.74% (#1484)

* Shrink ASDisplayNode from 1088 to 976 bytes, reduction of 11.48%

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* Forgot to bit-field-ify placeholderEnable; new small size is 968, old size is 1072 (measured consistentlyl on iPhoneSE simulator). 10.74% reduction.

* Shrink Button Node (#1494)

Button: 1312 to 1288 bytes, running on iPhone SE simulator. 1.9% reduction.

Shrink the enums it stores, and place them next to each other (along with a BOOL) to reduce instance size.

* Shrink TextNode(2) (#1495)

Running in iPhone SE Simulator:
- ASTextNode: 1360 to 1352 bytes .6% reduction
- ASTextNode2: 1360 to 1304 bytes 4.3% redction

Shrink stored enum sizes. Group BOOLs near these smaller enums. Override -usingExperiment to return constant instead of never set, but allocated ivar.

* Shrink Pager and Scroll Node (#1496)

Running on iPhone SE Simulator:
ASPagerNode 1240 to 1232 bytes .7% reduction
ASScrollNode 1104 to 1096 bytes .7% reduction

- make ASScrollNode smaller by shrinking ASScrollDirection, which requires a change to ASRangeController
- shrink ASPagerNode by declaring the BOOL next to the struct

* Shrink ASImageNode by .6% and ASNetworkImageNode by 2.2% (#1487)

* Shrink ASImageNode by .6% and ASNetworkImageNode by 2.2%

ASImageNode goes from 1384 to 1376. ASNetworkImageNode goes from 1496 to 1464.

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* add comments as requested in garrett's review.

* access ivar directly since already locked as suggested in review.

* Remove unused declaration, missed in #1460 (#1497)

* Keep the atomics - does not affect memory work (#1498)

Revert "Ensure ASControlMode properties lock before accessing their ivars (#1476)"
This reverts commit ce1e195.

Revert "Make sure all ASDisplayNode properties have backing ivars for consistency. (#1475)"
This reverts commit d6061f4.
- Except the unused property `interfaceStateSuspended` is still removed (this is a memory saver).

* Shrink ASCellNode by 8 bytes (#1499)

Group the BOOLs together, since there are only 4 (and there are no other auto-generated ivars that are < 64 bits) this is sufficient and keeps the properties `atomic`.

* Shrink ASEditableTextNode by 16 bytes (#1500)

Just shuffle some BOOLs around and explicitly declare an ivar so it is grouped with the others.

* ASSignpost: Add support for the os_signpost API, fixes (#1501)

* ASSignpost: Add support for the os_signpost API

- Removes support for colored intervals. These weren't really useful and they aren't part of the signpost api.
- Fixes an issue with range controller interval logging.
- Adds an interval for interface orientation changes.

* Rename

* Support Xcode 9

* Commentary

* Shrink ASLayout (#1503)

- Shrink the enum. Save 8 bytes. There are 1000s of these in the heap after running Pinterest for 10 minutes.

* Cleanup whitespace #trivial (#1507)

(It's easier to deal with these as silly oneoffs IMO than to
have them conflated with real work)

* Shrink LayoutSpec classes (#1502)

- Resize enums to make `ASStackLayoutSpec` 40 bytes smaller. This applies to the subclasses too.

Co-authored-by: Adlai Holler <adlai@icloud.com>
Co-authored-by: Garrett Moon <garrett@pinterest.com>
Co-authored-by: dirtmelon <272485887@qq.com>
Co-authored-by: Michael Schneider <maicki@users.noreply.github.com>
Co-authored-by: Kevin <kevin@wode.com>
Co-authored-by: dirtmelon <0xffdirtmelon@gmail.com>
Co-authored-by: Jonathan Downing <jd@jonathandowning.uk>
Co-authored-by: Xavier Deloge <Idefix60@users.noreply.github.com>
Co-authored-by: Eric Scheers <smeis@users.noreply.github.com>
Co-authored-by: Huy Nguyen <allforone1511@gmail.com>
Co-authored-by: Greg Bolsinga <bolsinga@mac.com>
Co-authored-by: Jacob Farkas <farktronix@users.noreply.github.com>
Co-authored-by: ernestmama <43187788+ernestmama@users.noreply.github.com>
Co-authored-by: Andrew Yates <contact@andydev.co.uk>
Co-authored-by: Tim Norman <tim@normsoft.com>
Co-authored-by: Michael Zuccarino <mikezuccarino@gmail.com>
Co-authored-by: Dmitry Gridnev <dmitr.gridnev@gmail.com>
Co-authored-by: Max Wang <max.wang.cs@gmail.com>
Co-authored-by: Ballad <348649634@qq.com>
Co-authored-by: ricky <rickycancro@gmail.com>
Co-authored-by: Patrick Balestra <me@patrickbalestra.com>
Co-authored-by: Harry Shamansky <harry.shamansky@gmail.com>
Co-authored-by: Wu Zhong <zhongwuzw@qq.com>
Co-authored-by: Oskar Zhang <i@oskarzhang.me>
Co-authored-by: Adlai Holler <adlai@google.com>
Co-authored-by: Greg Bolsinga <gbolsinga@pinterest.com>
Co-authored-by: Huy Nguyen <huy@pinterest.com>
Co-authored-by: Andrew Monshizadeh <amonshiz+github@gmail.com>
rcancro added a commit to rcancro/Texture that referenced this pull request May 21, 2020
…ureGroup#1011)

* Extended IGListKit support for node deselect, highlight and unhighlight

* Proposal of renaming willDisplayItemWithNode and didEndDisplayingItemWithNode to be similiar to UICollectionView

* Extended support for IGListDisplayDelegate

* Updated changelog with displaying delegates change

* Removed extra deprecation supression flag

* Reverted ASCollectionNode changes and implemented displaing delegate with indexPathForNode:

* Sending a real UICollectionViewCell to the delegate if not nil

* Added safety check for nil indexPaths

* Discard any CHANGELOG changes for fix Danger error

* Add an experimental flag to use native dispatch_apply (TextureGroup#1345)

* Add an experimental flag to use native dispatch_apply instead of our core count * 2 approach. This has shown performance wins in some profiling.

* Add in other places

* Don't return non-animated GIFs for animation (update to latest PINRemoteImage beta) (TextureGroup#940)

* Don't return non-animated GIFs for animation

* Update to latest PINRemoteImage beta

* Fix typos  (TextureGroup#1348)

* Update containers-overview.md

* Update subclassing.md

* Update node-overview.md

ASImageNode, ASNetworkImageNode and ASMultiplexImageNode are in place of UIImageView, not UIImage.

* Revert "Have node and controller share lock (TextureGroup#1227)" (TextureGroup#1347)

This reverts commit 2baa943.

* Don't compile out ASExperimentalTextNode if ASTextNode is compiled out (TextureGroup#1353)

* Lock up to yogaRoot during layout to avoid deadlocks. (TextureGroup#1356)

* Lock up to yogaRoot during layout to avoid dead lock.

1) lock to root for tree
2) lock self to change parent (& consequently root)
3) Implement ASLocking (tryLock) on ASNodeController
4) add lockPair to try-lock node & controller together
5) lock controllers if they exist in lockToRoot...

Disable some asserts due to lock to root. :(

LL# No commands remaining.

* Add macro so non-Yoga still builds :)

* wut

* Update layout-transition-api.md (TextureGroup#1357)

* Optimize ASTwoDimensionalArrayUtils (TextureGroup#1351)

* Optimize ASTwoDimensionalArrayUtils

These methods are called on the main thread during range controller updates (i.e. every frame) and so they should be as fast as possible.

* Rename

* Use vector instead of stack array to handle really big cases (e.g. photos)

* If we check for batching before content size is available we'll always fetch (TextureGroup#1355)

* Do not lock the nodeController if we are not locking to root. (TextureGroup#1360)

Doing so leaves it locked when we elsewhere explicitly unlock the node to ascend.

* Resolve root constrained size before informing delegate to resolve infinite layout loop. (TextureGroup#1359)

* Add `setNeedsLayout` to yoga tree changes. (TextureGroup#1361)

* Make ASCollectionElement Public (TextureGroup#1303)

* Update AsyncDisplayKit.h

* Update project.pbxproj

* Optimize _assertSubnodeState (TextureGroup#1352)

* Optimize _assertSubnodeState

This method is actually pretty painful in today's world. In one iPad mini trace, the first page of nodes spent 6.6ms in this call, just in time profiler.

* Clean it up, check count

* Check the right value

* _ASCollectionViewCell - The point isn't converted before to send to node, impossible to touch button into the node hierarchy (TextureGroup#1362)

* Revert node call, useless, the node has a ASDisplayView, and this view forward on the node in first.

* Use convertPoint to convert the given point in hittest & pointInside methods.
Keep the standard usage if the node didn't rasterized a view.

* Removed isNodeLoaded, finally it's useless in this case
In these methods, we are on the mainThread, we can create the view if the view is not created.

* Optimize ASCATransactionQueue (TextureGroup#1350)

* Optimize ASCATransactionQueue. This queue is very busy, and it runs on the main thread so it's important for it to be fast.

Avoid waking up the run loop for every single node.
Avoid a ton of NSPointerArray overhead that we don't need.
Avoid retain/release traffic on the singleton by using an inline function. I confirmed that in release mode, the static __strong is correctly inlined and no ARC traffic is incurred.

* Comment

* Unlock right

* Remove magic number

* Cleanup Yoga Categories (TextureGroup#1364)

* Add forwarding of UIAccessibilityAction methods (TextureGroup#1344)

* Add forwarding of UIAccessibilityAction methods

* Use OCMock for testing UIAccessibilityAction method forwarding

* Don't add extraneous truncation token during kCTLineTruncationMiddle. (TextureGroup#1297)

* Don't add extraneous truncation token during kCTLineTruncationMiddle

* Expand these comments a little.

* Update the FAQ to throw less shade. (TextureGroup#1379)

* Update the FAQ to throw less shade.

Both of these technologies have their place, no point in being assholes.

* Update faq.md

* [Updated Snapshots] Don't add extraneous truncation token during kCTLineTruncationMiddle (TextureGroup#1375)

* Don't add extraneous truncation token during kCTLineTruncationMiddle

* Expand these comments a little.

* Update snapshot tests with beautiful correct behavior

* Launches switching ASNetworkImageNode callbacks to global queue. (TextureGroup#1369)

* Launches switching ASNetworkImageNode callbacks to global queue.

* Good catch configuration tests!

* Make ASTextNode2 more forgiving when searching for links (TextureGroup#1374)

* Make ASTextNode2 more forgiving when searching for links by searching a 44x44 square around the touch

* Trailing whitespace

* Safely handle end-of-line

* Experiment with different strategies for image downloader priority (TextureGroup#1349)

Right now when an image node enters preload state, we kick off an image request with the default priority. Then when it enters display state, we change the priority to "imminent" which is mapped to the default priority as well. This means that requests from preload and display nodes have the same priority and are put to the same pool. The right behavior would be that preload requests should have a lower priority from the beginning.

Another problem is that, due to the execution order of -didEnter(Preload|Display|Visible)State calls, a node may kick off a low priority request when it enters preload state even though it knows that it's also visible. By the time -didEnterVisibleState is called, the low priority request may have already been consumed and the download/data task won't pick up the new higher priority, or some work needs to be done to move it to another queue. A better behavior would be to always use the current interface state to determine the priority. This means that visible nodes will kick off high priority requests as soon as -didEnterPreloadState is called.

The last (and smaller) issue is that a node marks its request as preload/low priority as soon as it exits visible state. I'd argue that this is too agressive. It may be reasonble for nodes in the trailing direction. Even so, we already handle this case by (almost always) have smaller trailing buffers. So this diff makes sure that nodes that exited visible state will have imminent/default priority if they remain in the display range.

All of these new behaviors are wrapped in an experiment and will be tested carefully before being rolled out.

* Add imports

* Fix build failure

* Encapsulate common logics into methods

* Address comments

* Whoops, someone forgot an else! (TextureGroup#1385)

Luckily it seems this didn't cause huge memory bloat because there's
a check below that keeps the display flag from being set in low memory
conditions when the node is off the screen.

* Catch invalid sizes during yoga layout (TextureGroup#1376)

* Correct View vs. Layer here (tho it doesn't make any difference) (TextureGroup#1378)

Older FBSnapshot versions, however, don't use VerifyViewOrLayer

* Expose initial constrained size before layout in case anyone is interested later during the layout on the same thread. (TextureGroup#1377)

Optionally, clients are expected to clean it up after usage to avoid accessing outdated data.

* Assert for context creation failure during displayBlock. (TextureGroup#1373)

Nothing good can possibly happen if we continue without one.

* Fix an issue where state change notifications can be sent mulitple times. (TextureGroup#1372)

Before the change: both - (void)setShouldInvertStrongReference:(BOOL)shouldInvertStrongReference and - (void)setNode:(ASDisplayNode *)node will call through [self setupReferencesWithNode:node]; which call the [node addInterfaceStateDelegate:self];

* Add Yoga support to ASButtonNode (TextureGroup#1381)

* Add Yoga support to ASButtonNode

* Drop unowned ASLayoutElementStyle parameter

* Fix access of Yoga properties

* Move ASButtonNode Yoga logic to Category

* Update header

* Fix CTLineRef leaks (TextureGroup#1386)

Found by Clang Static Analyzer:

~/Texture/Source/ASTextNode2.mm:663:39: warning: Potential leak of an object stored into 'truncationTokenLine'
      CTLineRef truncationTokenLine = CTLineCreateWithAttributedString((CFAttributedStringRef)_truncationAttributedText);
                                      ^
~/Texture/Source/ASTextNode2.mm:666:49: warning: Potential leak of an object stored into 'additionalTruncationTokenLine'
      CTLineRef additionalTruncationTokenLine = CTLineCreateWithAttributedString((CFAttributedStringRef)_additionalTruncationMessage);
                                                ^
2 warnings generated.

* Correct attributes lookup for supplementary elements. (TextureGroup#1318)

* Need some more locks for working with calculated yoga layouts (TextureGroup#1388)

* Adds support for using UIGraphicsImageRenderer in ASTextNode. (TextureGroup#1384)

* Adds support for using UIGraphicsImageRenderer in ASTextNode.

In many cases this reduces the backing store of text nodes by 1/2.

* Guard for UIGraphicsRenderer availability.

* Comma

* Add UIDataSourceModelAssociation to ASTableView and ASCollectionView (TextureGroup#1354)

* Add UIDataSourceModelAssociation protocol conformance to ASTableView and ASCollectionView.

* Implementing review feedback from @Adlai-Holler

* Rename ASDN C++ namespace to AS (TextureGroup#1366)

* Rename ASDN C++ namespace to "AS." Referring to the framework as ASDisplayNode is pretty out-dated and verbose. See CoreAnimation which usees CA for their internal namespace.

More using

* More cases

* Clean up a clang analyzer cast error (TextureGroup#1387)

~/Texture/Source/Private/ASMutableElementMap.mm:32:24: warning: Conversion from value of type 'NSMutableArray<NSMutableArray *> *' to incompatible type 'ASMutableCollectionElementTwoDimensionalArray *'
    _sectionsOfItems = (id)ASTwoDimensionalArrayDeepMutableCopy(items);
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

* Update for 9.4.1 CI (TextureGroup#1392)

* Remove experimental features (exp_skip_a11y_wait && exp_new_default_cell_layout_mode) (TextureGroup#1383)

* Remove experimental features

* prevent blocking main thread

* remove small content all together as none is the default

* Update ASExperimentalFeatures.h

* Make experiment checks faster (TextureGroup#1393)

* Make experiment checks use dispatch_once when not debugging, clean up singleton

* One more

* Pull out the variable

* Make shared CA transaction queue variable extern so it's actually shared (TextureGroup#1397)

* Fix header typo (TextureGroup#1402)

* Context is a pretty general name that will cause conflicts with subclasses (TextureGroup#1399)

* Suppress documentation warnings when using external libraries (TextureGroup#1401)

Fixes 1400

* Add layer-action support to nodes (TextureGroup#1396)

* Add layer-action support to nodes, unify hierarchy notifications on it

* Better pending state

* Fix bool

* Skip extra copy

* Never run default actions

* Continue the search

* Avoid an unnecessary lock & unlock pair in ASMainSerialQueue (TextureGroup#1409)

* Add clang-format for a common source code format (TextureGroup#1365)

* Add clang-format

* Update format to be as close as our current style

* Fix GIF Caching (TextureGroup#1405)

* Add support for reverse direction to yoga layouts (TextureGroup#1413)

* Add support for reverse direction to yoga layouts

* #ifdef YOGA yoga-specific additions

* oops

* Only set ASLayoutElementStyle delegate if Yoga is enabled (TextureGroup#1417)

* Fix bug in ASRangeController that causes some cell nodes of a collection view which is about to becomes invisible to load their backing view/layer and render (TextureGroup#1418)

* Fix a bug with Yoga nodes whose position change and don't update. (TextureGroup#1408)

* Follow up on the ASRangeController fix in TextureGroup#1418 (TextureGroup#1419)

The changes in TextureGroup#1418 is a bit too aggressive when it comes to nodes that are in display range. It forces those nodes to not preload.

Also update the changes to avoid diluting the experiment data by triggering too broadly (i.e avoid triggering when the old and new implementations yield the same result leading to no behavior change).

* Dev docs for threading in Texture (TextureGroup#1319)

* Getting started on adding threading by example

* writing writing writing

* more info

* More threading

* More more more

* Threading

* self lock

* Some language fixes

* Update docs/_docs/development/threading.md

Co-Authored-By: mikezucc <mikezuccarino@gmail.com>

* fix image references

* Removed locked jekyll version (TextureGroup#1322)

* showcase.md updated (TextureGroup#1421)

* Experiment with disabling ASViewController background dealloc (TextureGroup#1420)

* [Experiment] Dont forget about these collection view background deallocs (TextureGroup#1424)

* Dont forget about these collection view background deallocs

* Also Table view for completeness

* Fix retain cycle with transaction operations (TextureGroup#1429)

Add unit tests that help find cycles. `-testWeakWithSingleOperation` fails without the code fix applied.

* Replace +load initializers with __attribute__((constructor)) functions (TextureGroup#1425)

* Replace +load initializers with __attribute__((constructor)) functions

* Updating the documentation for textureDidInitialize, per @nguyenhuy

* Fix dealloc on bg (TextureGroup#1410)

* fix SIMULATE_WEB_RESPONSE not imported TextureGroup#449

* Fix to make rangeMode update in right time

* remove uncessary assert

* Fix collection cell editing bug for iOS 9 & 10

* Revert "Fix collection cell editing bug for iOS 9 & 10"

This reverts commit 06e18a1.

* Fix dealloc long gesture in background

* Add support for clipping only specific corners, add unit tests (TextureGroup#1415)

* Add support for clipping only specific corners, add unit tests

* Remove some cleanup to make the diff smaller

* Fix

* [ASImageNode]fix incorrect backing size calculation (TextureGroup#1189)

* fix backing size for image node which content mode is scaleAspectFit

* chore: update comments and naming

* add change log

* Update CHANGELOG.md

* Update CHANGELOG.md

Co-Authored-By: junjielu <348649634@qq.com>

* add unit test for backing size calculation

* correct license

* Have image nodes draw into opaque contexts automatically if possible (TextureGroup#1432)

* Have image nodes draw into opaque contexts if the image is opaque and it fills the context

* Call backingSize once

* Fix typo in batch-fetching-api.md (TextureGroup#1437)

* [ASDisplayNode] Stop infinite layout in _u_measureNodeWithBoundsIfNecessary (TextureGroup#1434)

We came across an infinite layout loop in `_u_measureNodeWithBoundsIfNecessary`. After requesting a layout from above, the sizes between pending and caluclated layout still do not match. We continue to prefer to use the pending layout and ask for another layout loop from above. We can’t seem to break out of this loop. The solution (thanks to Huy for the guidance) was to nil out the pending layout we get from requesting the layout from above.

I was only able to reproduce this when working with a node in a `UINavigationBarItem’s` `titleView`. I think that UIKit must be doing something sneaky with setting the frame on the view. While I was not able to create a unit test to catch this issue (I tried for a long time, and can post what I’ve come up with to see if anyone has any suggestions), I was able to create a pretty simple example project that shows the behavior:
https://github.com/rcancro/TextureLayoutLoopExample

* Add a verbose log for locking operations. Has no effect in production (TextureGroup#1436)

* Add a verbose log for locking operations. Has no effect in production

* Need check

* Wrap transaction operation retain cycle fix in an experiment (TextureGroup#1438)

* Wrap transaction operation retain cycle fix in an experiment

This is a follow on to TextureGroup#1429.

* fix typo in experiment name. fix copyright in tests file.

* Fix scroll node in yoga (TextureGroup#1435)

* fix SIMULATE_WEB_RESPONSE not imported TextureGroup#449

* Fix to make rangeMode update in right time

* remove uncessary assert

* Fix collection cell editing bug for iOS 9 & 10

* Revert "Fix collection cell editing bug for iOS 9 & 10"

This reverts commit 06e18a1.

* Fix child not fit to full scroll node's bounds when flex_grow = 1.0 is used on child

* Fix the stub for layerActionForKey: to let CA continue the search (TextureGroup#1441)

* Fix the stub for layerActionForKey: to let CA continue the search

* Kick CI

* Revert "Have image nodes draw into opaque contexts automatically if possible (TextureGroup#1432)" (TextureGroup#1443)

This reverts commit 28522ce.

* Use instance lock for ASPrimitiveTraitCollection (TextureGroup#1442)

* Use instance lock for ASPrimitiveTraitCollection

* Remove the atomic

* Simplify ASTraitCollection propagation in ASViewController (TextureGroup#1447)

* Use AS::Mutex in ASCollectionElement (TextureGroup#1445)

* [ASTextNode] Maintain isAccessibilityElement setting on text nodes when updating text (TextureGroup#1326)

* Add didEnterHierarchy/didExitHierarchy to ASNodeController. (TextureGroup#1444)

* Fix wrongly formatted RELEASE link (TextureGroup#1453)

* Only create activities during debug (TextureGroup#1456)

* [TextureGroup#1451] Add support for UIAccessibilityCustomAction (TextureGroup#1452)

This PR adds support for UIAccessibilityCustomAction propagation through ASPendingState so that it can be picked up by VoiceOver.

* Shut down graphics contexts experiment (TextureGroup#1458)

* Shut down graphics contexts experiment

* Remove dead import

* Remove gone class

* Remove lock of ASTextNodeRendererKey (TextureGroup#1454)

* Remove lock of ASTextNodeRendererKey

* Remove class check for isEqual

* Add const specifier to function parameter

* Fixes typo

* Fixes typo

* Disable ASAssertLocked and ASAssertUnlocked (TextureGroup#1412)

* Try to remove global lock when initialising TextKit components (TextureGroup#1455)

* Try to remove global lock when initialising TextKit components

* Adding experiment flag to dis/enable lock of textkit component

* Adding tests

* code clean

fix typo

Make remove lock optional

Keep locks

code clean

* Make ASCollectionNode's pan gesture customizable (TextureGroup#1457)

* changes done

* complete set of uigesturedeleagte methods

* Remove iOS 8 support from logging code. (TextureGroup#1462)

* Drop support for Xcode 8 and fix some compiler warnings (TextureGroup#1463)

* Remove ASEventLog (TextureGroup#1460)

* Remove ASEventLog. We'll focus on ASLog for the future, possibly making it triggerable on a per-node basis

* See ya!

* Hello semicolon

* Remove refs to gone tree methods

* Fix

* Remove irrelevant change, kick CI

* Clean up

* Cover the other background dealloc surfaces (TextureGroup#1464)

* Passthrough pagingEnabled for ASCollectionNode / ASTableNode (TextureGroup#1466)

* Passthrough pagingEnabled for ASCollectionNode and ASTableNode

* Add tvOS handling

* Fix open context bug introduced in TextureGroup#1458 (TextureGroup#1468)

* Make sure all ASDisplayNode properties have backing ivars for consistency. (TextureGroup#1475)

* Make sure all ASDisplayNodes have backing ivars for consistency.

Found this by enabling #pragma clang diagnostic error "-Wobjc-missing-property-synthesis" for ASDisplayNode. One property is unused, saving 8 bytes of heap space per instance on 64-bit builds. Implement setter/getters for these properties, and add appropriate locking. add the warning as error to the build for this file.

* Ensure ASControlMode properties lock before accessing their ivars (TextureGroup#1476)

Enable `#pragma clang diagnostic error "-Wobjc-missing-property-synthesis"` for this file.

* Add a new "global drawing" experiment to use UIGraphicsRenderer (TextureGroup#1469)

* Add a new "global drawing" experiment to use UIGraphicsRenderer everywhere, when available

* Fix logic

* Use preferredFormat

* Cut version 2.8.1 (TextureGroup#1491)

* Clean up documentation issues around periods (TextureGroup#1490)

There were so unnecessary `'` around periods for some reason. Just deleting those because they are distracting.

* Minor update in change log #changelog (TextureGroup#1492)

* Ship ASExperimentalFixRangeController (TextureGroup#1486)

* Shrink _ASCollectionPendingState from 144 to 128 bytes, a 12.5% reduction (TextureGroup#1485)

* Shrink _ASCollectionPendingState from 144 to 128 bytes, a 12.5% reduction

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* address review comments. move enums out. add comment. rename struct to _flags

* fix a missing rename

* Shrink _ASPendingState from 824 to 808 bytes, reduction of ~2% (TextureGroup#1483)

* Shrink _ASPendingState from 824 to 808 bytes, reduction of ~2%

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Shrink ASPendingState BOOLs. Use unsigned int for these bitfields for clarity. Separate from `_flags` as that struct is compared to `0` for testing. The `_boolFlags` struct is just storing other `BOOL`s.

* rename struct fields as suggested in garret's review.

* Shrink ASDisplayNode from 1072 to 968 bytes, reduction of 10.74% (TextureGroup#1484)

* Shrink ASDisplayNode from 1088 to 976 bytes, reduction of 11.48%

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* Forgot to bit-field-ify placeholderEnable; new small size is 968, old size is 1072 (measured consistentlyl on iPhoneSE simulator). 10.74% reduction.

* Shrink Button Node (TextureGroup#1494)

Button: 1312 to 1288 bytes, running on iPhone SE simulator. 1.9% reduction.

Shrink the enums it stores, and place them next to each other (along with a BOOL) to reduce instance size.

* Shrink TextNode(2) (TextureGroup#1495)

Running in iPhone SE Simulator:
- ASTextNode: 1360 to 1352 bytes .6% reduction
- ASTextNode2: 1360 to 1304 bytes 4.3% redction

Shrink stored enum sizes. Group BOOLs near these smaller enums. Override -usingExperiment to return constant instead of never set, but allocated ivar.

* Shrink Pager and Scroll Node (TextureGroup#1496)

Running on iPhone SE Simulator:
ASPagerNode 1240 to 1232 bytes .7% reduction
ASScrollNode 1104 to 1096 bytes .7% reduction

- make ASScrollNode smaller by shrinking ASScrollDirection, which requires a change to ASRangeController
- shrink ASPagerNode by declaring the BOOL next to the struct

* Shrink ASImageNode by .6% and ASNetworkImageNode by 2.2% (TextureGroup#1487)

* Shrink ASImageNode by .6% and ASNetworkImageNode by 2.2%

ASImageNode goes from 1384 to 1376. ASNetworkImageNode goes from 1496 to 1464.

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* add comments as requested in garrett's review.

* access ivar directly since already locked as suggested in review.

* Remove unused declaration, missed in TextureGroup#1460 (TextureGroup#1497)

* Keep the atomics - does not affect memory work (TextureGroup#1498)

Revert "Ensure ASControlMode properties lock before accessing their ivars (TextureGroup#1476)"
This reverts commit ce1e195.

Revert "Make sure all ASDisplayNode properties have backing ivars for consistency. (TextureGroup#1475)"
This reverts commit d6061f4.
- Except the unused property `interfaceStateSuspended` is still removed (this is a memory saver).

* Shrink ASCellNode by 8 bytes (TextureGroup#1499)

Group the BOOLs together, since there are only 4 (and there are no other auto-generated ivars that are < 64 bits) this is sufficient and keeps the properties `atomic`.

* Shrink ASEditableTextNode by 16 bytes (TextureGroup#1500)

Just shuffle some BOOLs around and explicitly declare an ivar so it is grouped with the others.

* ASSignpost: Add support for the os_signpost API, fixes (TextureGroup#1501)

* ASSignpost: Add support for the os_signpost API

- Removes support for colored intervals. These weren't really useful and they aren't part of the signpost api.
- Fixes an issue with range controller interval logging.
- Adds an interval for interface orientation changes.

* Rename

* Support Xcode 9

* Commentary

* Shrink ASLayout (TextureGroup#1503)

- Shrink the enum. Save 8 bytes. There are 1000s of these in the heap after running Pinterest for 10 minutes.

* Cleanup whitespace #trivial (TextureGroup#1507)

(It's easier to deal with these as silly oneoffs IMO than to
have them conflated with real work)

* Shrink LayoutSpec classes (TextureGroup#1502)

- Resize enums to make `ASStackLayoutSpec` 40 bytes smaller. This applies to the subclasses too.

Co-authored-by: Adlai Holler <adlai@icloud.com>
Co-authored-by: Garrett Moon <garrett@pinterest.com>
Co-authored-by: dirtmelon <272485887@qq.com>
Co-authored-by: Michael Schneider <maicki@users.noreply.github.com>
Co-authored-by: Kevin <kevin@wode.com>
Co-authored-by: dirtmelon <0xffdirtmelon@gmail.com>
Co-authored-by: Jonathan Downing <jd@jonathandowning.uk>
Co-authored-by: Xavier Deloge <Idefix60@users.noreply.github.com>
Co-authored-by: Eric Scheers <smeis@users.noreply.github.com>
Co-authored-by: Huy Nguyen <allforone1511@gmail.com>
Co-authored-by: Greg Bolsinga <bolsinga@mac.com>
Co-authored-by: Jacob Farkas <farktronix@users.noreply.github.com>
Co-authored-by: ernestmama <43187788+ernestmama@users.noreply.github.com>
Co-authored-by: Andrew Yates <contact@andydev.co.uk>
Co-authored-by: Tim Norman <tim@normsoft.com>
Co-authored-by: Michael Zuccarino <mikezuccarino@gmail.com>
Co-authored-by: Dmitry Gridnev <dmitr.gridnev@gmail.com>
Co-authored-by: Max Wang <max.wang.cs@gmail.com>
Co-authored-by: Ballad <348649634@qq.com>
Co-authored-by: ricky <rickycancro@gmail.com>
Co-authored-by: Patrick Balestra <me@patrickbalestra.com>
Co-authored-by: Harry Shamansky <harry.shamansky@gmail.com>
Co-authored-by: Wu Zhong <zhongwuzw@qq.com>
Co-authored-by: Oskar Zhang <i@oskarzhang.me>
Co-authored-by: Adlai Holler <adlai@google.com>
Co-authored-by: Greg Bolsinga <gbolsinga@pinterest.com>
Co-authored-by: Huy Nguyen <huy@pinterest.com>
Co-authored-by: Andrew Monshizadeh <amonshiz+github@gmail.com>
rcancro added a commit to rcancro/Texture that referenced this pull request May 21, 2020
…ureGroup#1011)

* Extended IGListKit support for node deselect, highlight and unhighlight

* Proposal of renaming willDisplayItemWithNode and didEndDisplayingItemWithNode to be similiar to UICollectionView

* Extended support for IGListDisplayDelegate

* Updated changelog with displaying delegates change

* Removed extra deprecation supression flag

* Reverted ASCollectionNode changes and implemented displaing delegate with indexPathForNode:

* Sending a real UICollectionViewCell to the delegate if not nil

* Added safety check for nil indexPaths

* Discard any CHANGELOG changes for fix Danger error

* Add an experimental flag to use native dispatch_apply (TextureGroup#1345)

* Add an experimental flag to use native dispatch_apply instead of our core count * 2 approach. This has shown performance wins in some profiling.

* Add in other places

* Don't return non-animated GIFs for animation (update to latest PINRemoteImage beta) (TextureGroup#940)

* Don't return non-animated GIFs for animation

* Update to latest PINRemoteImage beta

* Fix typos  (TextureGroup#1348)

* Update containers-overview.md

* Update subclassing.md

* Update node-overview.md

ASImageNode, ASNetworkImageNode and ASMultiplexImageNode are in place of UIImageView, not UIImage.

* Revert "Have node and controller share lock (TextureGroup#1227)" (TextureGroup#1347)

This reverts commit 2baa943.

* Don't compile out ASExperimentalTextNode if ASTextNode is compiled out (TextureGroup#1353)

* Lock up to yogaRoot during layout to avoid deadlocks. (TextureGroup#1356)

* Lock up to yogaRoot during layout to avoid dead lock.

1) lock to root for tree
2) lock self to change parent (& consequently root)
3) Implement ASLocking (tryLock) on ASNodeController
4) add lockPair to try-lock node & controller together
5) lock controllers if they exist in lockToRoot...

Disable some asserts due to lock to root. :(

LL# No commands remaining.

* Add macro so non-Yoga still builds :)

* wut

* Update layout-transition-api.md (TextureGroup#1357)

* Optimize ASTwoDimensionalArrayUtils (TextureGroup#1351)

* Optimize ASTwoDimensionalArrayUtils

These methods are called on the main thread during range controller updates (i.e. every frame) and so they should be as fast as possible.

* Rename

* Use vector instead of stack array to handle really big cases (e.g. photos)

* If we check for batching before content size is available we'll always fetch (TextureGroup#1355)

* Do not lock the nodeController if we are not locking to root. (TextureGroup#1360)

Doing so leaves it locked when we elsewhere explicitly unlock the node to ascend.

* Resolve root constrained size before informing delegate to resolve infinite layout loop. (TextureGroup#1359)

* Add `setNeedsLayout` to yoga tree changes. (TextureGroup#1361)

* Make ASCollectionElement Public (TextureGroup#1303)

* Update AsyncDisplayKit.h

* Update project.pbxproj

* Optimize _assertSubnodeState (TextureGroup#1352)

* Optimize _assertSubnodeState

This method is actually pretty painful in today's world. In one iPad mini trace, the first page of nodes spent 6.6ms in this call, just in time profiler.

* Clean it up, check count

* Check the right value

* _ASCollectionViewCell - The point isn't converted before to send to node, impossible to touch button into the node hierarchy (TextureGroup#1362)

* Revert node call, useless, the node has a ASDisplayView, and this view forward on the node in first.

* Use convertPoint to convert the given point in hittest & pointInside methods.
Keep the standard usage if the node didn't rasterized a view.

* Removed isNodeLoaded, finally it's useless in this case
In these methods, we are on the mainThread, we can create the view if the view is not created.

* Optimize ASCATransactionQueue (TextureGroup#1350)

* Optimize ASCATransactionQueue. This queue is very busy, and it runs on the main thread so it's important for it to be fast.

Avoid waking up the run loop for every single node.
Avoid a ton of NSPointerArray overhead that we don't need.
Avoid retain/release traffic on the singleton by using an inline function. I confirmed that in release mode, the static __strong is correctly inlined and no ARC traffic is incurred.

* Comment

* Unlock right

* Remove magic number

* Cleanup Yoga Categories (TextureGroup#1364)

* Add forwarding of UIAccessibilityAction methods (TextureGroup#1344)

* Add forwarding of UIAccessibilityAction methods

* Use OCMock for testing UIAccessibilityAction method forwarding

* Don't add extraneous truncation token during kCTLineTruncationMiddle. (TextureGroup#1297)

* Don't add extraneous truncation token during kCTLineTruncationMiddle

* Expand these comments a little.

* Update the FAQ to throw less shade. (TextureGroup#1379)

* Update the FAQ to throw less shade.

Both of these technologies have their place, no point in being assholes.

* Update faq.md

* [Updated Snapshots] Don't add extraneous truncation token during kCTLineTruncationMiddle (TextureGroup#1375)

* Don't add extraneous truncation token during kCTLineTruncationMiddle

* Expand these comments a little.

* Update snapshot tests with beautiful correct behavior

* Launches switching ASNetworkImageNode callbacks to global queue. (TextureGroup#1369)

* Launches switching ASNetworkImageNode callbacks to global queue.

* Good catch configuration tests!

* Make ASTextNode2 more forgiving when searching for links (TextureGroup#1374)

* Make ASTextNode2 more forgiving when searching for links by searching a 44x44 square around the touch

* Trailing whitespace

* Safely handle end-of-line

* Experiment with different strategies for image downloader priority (TextureGroup#1349)

Right now when an image node enters preload state, we kick off an image request with the default priority. Then when it enters display state, we change the priority to "imminent" which is mapped to the default priority as well. This means that requests from preload and display nodes have the same priority and are put to the same pool. The right behavior would be that preload requests should have a lower priority from the beginning.

Another problem is that, due to the execution order of -didEnter(Preload|Display|Visible)State calls, a node may kick off a low priority request when it enters preload state even though it knows that it's also visible. By the time -didEnterVisibleState is called, the low priority request may have already been consumed and the download/data task won't pick up the new higher priority, or some work needs to be done to move it to another queue. A better behavior would be to always use the current interface state to determine the priority. This means that visible nodes will kick off high priority requests as soon as -didEnterPreloadState is called.

The last (and smaller) issue is that a node marks its request as preload/low priority as soon as it exits visible state. I'd argue that this is too agressive. It may be reasonble for nodes in the trailing direction. Even so, we already handle this case by (almost always) have smaller trailing buffers. So this diff makes sure that nodes that exited visible state will have imminent/default priority if they remain in the display range.

All of these new behaviors are wrapped in an experiment and will be tested carefully before being rolled out.

* Add imports

* Fix build failure

* Encapsulate common logics into methods

* Address comments

* Whoops, someone forgot an else! (TextureGroup#1385)

Luckily it seems this didn't cause huge memory bloat because there's
a check below that keeps the display flag from being set in low memory
conditions when the node is off the screen.

* Catch invalid sizes during yoga layout (TextureGroup#1376)

* Correct View vs. Layer here (tho it doesn't make any difference) (TextureGroup#1378)

Older FBSnapshot versions, however, don't use VerifyViewOrLayer

* Expose initial constrained size before layout in case anyone is interested later during the layout on the same thread. (TextureGroup#1377)

Optionally, clients are expected to clean it up after usage to avoid accessing outdated data.

* Assert for context creation failure during displayBlock. (TextureGroup#1373)

Nothing good can possibly happen if we continue without one.

* Fix an issue where state change notifications can be sent mulitple times. (TextureGroup#1372)

Before the change: both - (void)setShouldInvertStrongReference:(BOOL)shouldInvertStrongReference and - (void)setNode:(ASDisplayNode *)node will call through [self setupReferencesWithNode:node]; which call the [node addInterfaceStateDelegate:self];

* Add Yoga support to ASButtonNode (TextureGroup#1381)

* Add Yoga support to ASButtonNode

* Drop unowned ASLayoutElementStyle parameter

* Fix access of Yoga properties

* Move ASButtonNode Yoga logic to Category

* Update header

* Fix CTLineRef leaks (TextureGroup#1386)

Found by Clang Static Analyzer:

~/Texture/Source/ASTextNode2.mm:663:39: warning: Potential leak of an object stored into 'truncationTokenLine'
      CTLineRef truncationTokenLine = CTLineCreateWithAttributedString((CFAttributedStringRef)_truncationAttributedText);
                                      ^
~/Texture/Source/ASTextNode2.mm:666:49: warning: Potential leak of an object stored into 'additionalTruncationTokenLine'
      CTLineRef additionalTruncationTokenLine = CTLineCreateWithAttributedString((CFAttributedStringRef)_additionalTruncationMessage);
                                                ^
2 warnings generated.

* Correct attributes lookup for supplementary elements. (TextureGroup#1318)

* Need some more locks for working with calculated yoga layouts (TextureGroup#1388)

* Adds support for using UIGraphicsImageRenderer in ASTextNode. (TextureGroup#1384)

* Adds support for using UIGraphicsImageRenderer in ASTextNode.

In many cases this reduces the backing store of text nodes by 1/2.

* Guard for UIGraphicsRenderer availability.

* Comma

* Add UIDataSourceModelAssociation to ASTableView and ASCollectionView (TextureGroup#1354)

* Add UIDataSourceModelAssociation protocol conformance to ASTableView and ASCollectionView.

* Implementing review feedback from @Adlai-Holler

* Rename ASDN C++ namespace to AS (TextureGroup#1366)

* Rename ASDN C++ namespace to "AS." Referring to the framework as ASDisplayNode is pretty out-dated and verbose. See CoreAnimation which usees CA for their internal namespace.

More using

* More cases

* Clean up a clang analyzer cast error (TextureGroup#1387)

~/Texture/Source/Private/ASMutableElementMap.mm:32:24: warning: Conversion from value of type 'NSMutableArray<NSMutableArray *> *' to incompatible type 'ASMutableCollectionElementTwoDimensionalArray *'
    _sectionsOfItems = (id)ASTwoDimensionalArrayDeepMutableCopy(items);
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

* Update for 9.4.1 CI (TextureGroup#1392)

* Remove experimental features (exp_skip_a11y_wait && exp_new_default_cell_layout_mode) (TextureGroup#1383)

* Remove experimental features

* prevent blocking main thread

* remove small content all together as none is the default

* Update ASExperimentalFeatures.h

* Make experiment checks faster (TextureGroup#1393)

* Make experiment checks use dispatch_once when not debugging, clean up singleton

* One more

* Pull out the variable

* Make shared CA transaction queue variable extern so it's actually shared (TextureGroup#1397)

* Fix header typo (TextureGroup#1402)

* Context is a pretty general name that will cause conflicts with subclasses (TextureGroup#1399)

* Suppress documentation warnings when using external libraries (TextureGroup#1401)

Fixes 1400

* Add layer-action support to nodes (TextureGroup#1396)

* Add layer-action support to nodes, unify hierarchy notifications on it

* Better pending state

* Fix bool

* Skip extra copy

* Never run default actions

* Continue the search

* Avoid an unnecessary lock & unlock pair in ASMainSerialQueue (TextureGroup#1409)

* Add clang-format for a common source code format (TextureGroup#1365)

* Add clang-format

* Update format to be as close as our current style

* Fix GIF Caching (TextureGroup#1405)

* Add support for reverse direction to yoga layouts (TextureGroup#1413)

* Add support for reverse direction to yoga layouts

* #ifdef YOGA yoga-specific additions

* oops

* Only set ASLayoutElementStyle delegate if Yoga is enabled (TextureGroup#1417)

* Fix bug in ASRangeController that causes some cell nodes of a collection view which is about to becomes invisible to load their backing view/layer and render (TextureGroup#1418)

* Fix a bug with Yoga nodes whose position change and don't update. (TextureGroup#1408)

* Follow up on the ASRangeController fix in TextureGroup#1418 (TextureGroup#1419)

The changes in TextureGroup#1418 is a bit too aggressive when it comes to nodes that are in display range. It forces those nodes to not preload.

Also update the changes to avoid diluting the experiment data by triggering too broadly (i.e avoid triggering when the old and new implementations yield the same result leading to no behavior change).

* Dev docs for threading in Texture (TextureGroup#1319)

* Getting started on adding threading by example

* writing writing writing

* more info

* More threading

* More more more

* Threading

* self lock

* Some language fixes

* Update docs/_docs/development/threading.md

Co-Authored-By: mikezucc <mikezuccarino@gmail.com>

* fix image references

* Removed locked jekyll version (TextureGroup#1322)

* showcase.md updated (TextureGroup#1421)

* Experiment with disabling ASViewController background dealloc (TextureGroup#1420)

* [Experiment] Dont forget about these collection view background deallocs (TextureGroup#1424)

* Dont forget about these collection view background deallocs

* Also Table view for completeness

* Fix retain cycle with transaction operations (TextureGroup#1429)

Add unit tests that help find cycles. `-testWeakWithSingleOperation` fails without the code fix applied.

* Replace +load initializers with __attribute__((constructor)) functions (TextureGroup#1425)

* Replace +load initializers with __attribute__((constructor)) functions

* Updating the documentation for textureDidInitialize, per @nguyenhuy

* Fix dealloc on bg (TextureGroup#1410)

* fix SIMULATE_WEB_RESPONSE not imported TextureGroup#449

* Fix to make rangeMode update in right time

* remove uncessary assert

* Fix collection cell editing bug for iOS 9 & 10

* Revert "Fix collection cell editing bug for iOS 9 & 10"

This reverts commit 06e18a1.

* Fix dealloc long gesture in background

* Add support for clipping only specific corners, add unit tests (TextureGroup#1415)

* Add support for clipping only specific corners, add unit tests

* Remove some cleanup to make the diff smaller

* Fix

* [ASImageNode]fix incorrect backing size calculation (TextureGroup#1189)

* fix backing size for image node which content mode is scaleAspectFit

* chore: update comments and naming

* add change log

* Update CHANGELOG.md

* Update CHANGELOG.md

Co-Authored-By: junjielu <348649634@qq.com>

* add unit test for backing size calculation

* correct license

* Have image nodes draw into opaque contexts automatically if possible (TextureGroup#1432)

* Have image nodes draw into opaque contexts if the image is opaque and it fills the context

* Call backingSize once

* Fix typo in batch-fetching-api.md (TextureGroup#1437)

* [ASDisplayNode] Stop infinite layout in _u_measureNodeWithBoundsIfNecessary (TextureGroup#1434)

We came across an infinite layout loop in `_u_measureNodeWithBoundsIfNecessary`. After requesting a layout from above, the sizes between pending and caluclated layout still do not match. We continue to prefer to use the pending layout and ask for another layout loop from above. We can’t seem to break out of this loop. The solution (thanks to Huy for the guidance) was to nil out the pending layout we get from requesting the layout from above.

I was only able to reproduce this when working with a node in a `UINavigationBarItem’s` `titleView`. I think that UIKit must be doing something sneaky with setting the frame on the view. While I was not able to create a unit test to catch this issue (I tried for a long time, and can post what I’ve come up with to see if anyone has any suggestions), I was able to create a pretty simple example project that shows the behavior:
https://github.com/rcancro/TextureLayoutLoopExample

* Add a verbose log for locking operations. Has no effect in production (TextureGroup#1436)

* Add a verbose log for locking operations. Has no effect in production

* Need check

* Wrap transaction operation retain cycle fix in an experiment (TextureGroup#1438)

* Wrap transaction operation retain cycle fix in an experiment

This is a follow on to TextureGroup#1429.

* fix typo in experiment name. fix copyright in tests file.

* Fix scroll node in yoga (TextureGroup#1435)

* fix SIMULATE_WEB_RESPONSE not imported TextureGroup#449

* Fix to make rangeMode update in right time

* remove uncessary assert

* Fix collection cell editing bug for iOS 9 & 10

* Revert "Fix collection cell editing bug for iOS 9 & 10"

This reverts commit 06e18a1.

* Fix child not fit to full scroll node's bounds when flex_grow = 1.0 is used on child

* Fix the stub for layerActionForKey: to let CA continue the search (TextureGroup#1441)

* Fix the stub for layerActionForKey: to let CA continue the search

* Kick CI

* Revert "Have image nodes draw into opaque contexts automatically if possible (TextureGroup#1432)" (TextureGroup#1443)

This reverts commit 28522ce.

* Use instance lock for ASPrimitiveTraitCollection (TextureGroup#1442)

* Use instance lock for ASPrimitiveTraitCollection

* Remove the atomic

* Simplify ASTraitCollection propagation in ASViewController (TextureGroup#1447)

* Use AS::Mutex in ASCollectionElement (TextureGroup#1445)

* [ASTextNode] Maintain isAccessibilityElement setting on text nodes when updating text (TextureGroup#1326)

* Add didEnterHierarchy/didExitHierarchy to ASNodeController. (TextureGroup#1444)

* Fix wrongly formatted RELEASE link (TextureGroup#1453)

* Only create activities during debug (TextureGroup#1456)

* [TextureGroup#1451] Add support for UIAccessibilityCustomAction (TextureGroup#1452)

This PR adds support for UIAccessibilityCustomAction propagation through ASPendingState so that it can be picked up by VoiceOver.

* Shut down graphics contexts experiment (TextureGroup#1458)

* Shut down graphics contexts experiment

* Remove dead import

* Remove gone class

* Remove lock of ASTextNodeRendererKey (TextureGroup#1454)

* Remove lock of ASTextNodeRendererKey

* Remove class check for isEqual

* Add const specifier to function parameter

* Fixes typo

* Fixes typo

* Disable ASAssertLocked and ASAssertUnlocked (TextureGroup#1412)

* Try to remove global lock when initialising TextKit components (TextureGroup#1455)

* Try to remove global lock when initialising TextKit components

* Adding experiment flag to dis/enable lock of textkit component

* Adding tests

* code clean

fix typo

Make remove lock optional

Keep locks

code clean

* Make ASCollectionNode's pan gesture customizable (TextureGroup#1457)

* changes done

* complete set of uigesturedeleagte methods

* Remove iOS 8 support from logging code. (TextureGroup#1462)

* Drop support for Xcode 8 and fix some compiler warnings (TextureGroup#1463)

* Remove ASEventLog (TextureGroup#1460)

* Remove ASEventLog. We'll focus on ASLog for the future, possibly making it triggerable on a per-node basis

* See ya!

* Hello semicolon

* Remove refs to gone tree methods

* Fix

* Remove irrelevant change, kick CI

* Clean up

* Cover the other background dealloc surfaces (TextureGroup#1464)

* Passthrough pagingEnabled for ASCollectionNode / ASTableNode (TextureGroup#1466)

* Passthrough pagingEnabled for ASCollectionNode and ASTableNode

* Add tvOS handling

* Fix open context bug introduced in TextureGroup#1458 (TextureGroup#1468)

* Make sure all ASDisplayNode properties have backing ivars for consistency. (TextureGroup#1475)

* Make sure all ASDisplayNodes have backing ivars for consistency.

Found this by enabling #pragma clang diagnostic error "-Wobjc-missing-property-synthesis" for ASDisplayNode. One property is unused, saving 8 bytes of heap space per instance on 64-bit builds. Implement setter/getters for these properties, and add appropriate locking. add the warning as error to the build for this file.

* Ensure ASControlMode properties lock before accessing their ivars (TextureGroup#1476)

Enable `#pragma clang diagnostic error "-Wobjc-missing-property-synthesis"` for this file.

* Add a new "global drawing" experiment to use UIGraphicsRenderer (TextureGroup#1469)

* Add a new "global drawing" experiment to use UIGraphicsRenderer everywhere, when available

* Fix logic

* Use preferredFormat

* Cut version 2.8.1 (TextureGroup#1491)

* Clean up documentation issues around periods (TextureGroup#1490)

There were so unnecessary `'` around periods for some reason. Just deleting those because they are distracting.

* Minor update in change log #changelog (TextureGroup#1492)

* Ship ASExperimentalFixRangeController (TextureGroup#1486)

* Shrink _ASCollectionPendingState from 144 to 128 bytes, a 12.5% reduction (TextureGroup#1485)

* Shrink _ASCollectionPendingState from 144 to 128 bytes, a 12.5% reduction

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* address review comments. move enums out. add comment. rename struct to _flags

* fix a missing rename

* Shrink _ASPendingState from 824 to 808 bytes, reduction of ~2% (TextureGroup#1483)

* Shrink _ASPendingState from 824 to 808 bytes, reduction of ~2%

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Shrink ASPendingState BOOLs. Use unsigned int for these bitfields for clarity. Separate from `_flags` as that struct is compared to `0` for testing. The `_boolFlags` struct is just storing other `BOOL`s.

* rename struct fields as suggested in garret's review.

* Shrink ASDisplayNode from 1072 to 968 bytes, reduction of 10.74% (TextureGroup#1484)

* Shrink ASDisplayNode from 1088 to 976 bytes, reduction of 11.48%

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* Forgot to bit-field-ify placeholderEnable; new small size is 968, old size is 1072 (measured consistentlyl on iPhoneSE simulator). 10.74% reduction.

* Shrink Button Node (TextureGroup#1494)

Button: 1312 to 1288 bytes, running on iPhone SE simulator. 1.9% reduction.

Shrink the enums it stores, and place them next to each other (along with a BOOL) to reduce instance size.

* Shrink TextNode(2) (TextureGroup#1495)

Running in iPhone SE Simulator:
- ASTextNode: 1360 to 1352 bytes .6% reduction
- ASTextNode2: 1360 to 1304 bytes 4.3% redction

Shrink stored enum sizes. Group BOOLs near these smaller enums. Override -usingExperiment to return constant instead of never set, but allocated ivar.

* Shrink Pager and Scroll Node (TextureGroup#1496)

Running on iPhone SE Simulator:
ASPagerNode 1240 to 1232 bytes .7% reduction
ASScrollNode 1104 to 1096 bytes .7% reduction

- make ASScrollNode smaller by shrinking ASScrollDirection, which requires a change to ASRangeController
- shrink ASPagerNode by declaring the BOOL next to the struct

* Shrink ASImageNode by .6% and ASNetworkImageNode by 2.2% (TextureGroup#1487)

* Shrink ASImageNode by .6% and ASNetworkImageNode by 2.2%

ASImageNode goes from 1384 to 1376. ASNetworkImageNode goes from 1496 to 1464.

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* add comments as requested in garrett's review.

* access ivar directly since already locked as suggested in review.

* Remove unused declaration, missed in TextureGroup#1460 (TextureGroup#1497)

* Keep the atomics - does not affect memory work (TextureGroup#1498)

Revert "Ensure ASControlMode properties lock before accessing their ivars (TextureGroup#1476)"
This reverts commit ce1e195.

Revert "Make sure all ASDisplayNode properties have backing ivars for consistency. (TextureGroup#1475)"
This reverts commit d6061f4.
- Except the unused property `interfaceStateSuspended` is still removed (this is a memory saver).

* Shrink ASCellNode by 8 bytes (TextureGroup#1499)

Group the BOOLs together, since there are only 4 (and there are no other auto-generated ivars that are < 64 bits) this is sufficient and keeps the properties `atomic`.

* Shrink ASEditableTextNode by 16 bytes (TextureGroup#1500)

Just shuffle some BOOLs around and explicitly declare an ivar so it is grouped with the others.

* ASSignpost: Add support for the os_signpost API, fixes (TextureGroup#1501)

* ASSignpost: Add support for the os_signpost API

- Removes support for colored intervals. These weren't really useful and they aren't part of the signpost api.
- Fixes an issue with range controller interval logging.
- Adds an interval for interface orientation changes.

* Rename

* Support Xcode 9

* Commentary

* Shrink ASLayout (TextureGroup#1503)

- Shrink the enum. Save 8 bytes. There are 1000s of these in the heap after running Pinterest for 10 minutes.

* Cleanup whitespace #trivial (TextureGroup#1507)

(It's easier to deal with these as silly oneoffs IMO than to
have them conflated with real work)

* Shrink LayoutSpec classes (TextureGroup#1502)

- Resize enums to make `ASStackLayoutSpec` 40 bytes smaller. This applies to the subclasses too.

Co-authored-by: Adlai Holler <adlai@icloud.com>
Co-authored-by: Garrett Moon <garrett@pinterest.com>
Co-authored-by: dirtmelon <272485887@qq.com>
Co-authored-by: Michael Schneider <maicki@users.noreply.github.com>
Co-authored-by: Kevin <kevin@wode.com>
Co-authored-by: dirtmelon <0xffdirtmelon@gmail.com>
Co-authored-by: Jonathan Downing <jd@jonathandowning.uk>
Co-authored-by: Xavier Deloge <Idefix60@users.noreply.github.com>
Co-authored-by: Eric Scheers <smeis@users.noreply.github.com>
Co-authored-by: Huy Nguyen <allforone1511@gmail.com>
Co-authored-by: Greg Bolsinga <bolsinga@mac.com>
Co-authored-by: Jacob Farkas <farktronix@users.noreply.github.com>
Co-authored-by: ernestmama <43187788+ernestmama@users.noreply.github.com>
Co-authored-by: Andrew Yates <contact@andydev.co.uk>
Co-authored-by: Tim Norman <tim@normsoft.com>
Co-authored-by: Michael Zuccarino <mikezuccarino@gmail.com>
Co-authored-by: Dmitry Gridnev <dmitr.gridnev@gmail.com>
Co-authored-by: Max Wang <max.wang.cs@gmail.com>
Co-authored-by: Ballad <348649634@qq.com>
Co-authored-by: ricky <rickycancro@gmail.com>
Co-authored-by: Patrick Balestra <me@patrickbalestra.com>
Co-authored-by: Harry Shamansky <harry.shamansky@gmail.com>
Co-authored-by: Wu Zhong <zhongwuzw@qq.com>
Co-authored-by: Oskar Zhang <i@oskarzhang.me>
Co-authored-by: Adlai Holler <adlai@google.com>
Co-authored-by: Greg Bolsinga <gbolsinga@pinterest.com>
Co-authored-by: Huy Nguyen <huy@pinterest.com>
Co-authored-by: Andrew Monshizadeh <amonshiz+github@gmail.com>
bolsinga added a commit that referenced this pull request May 22, 2020
…t are subviews of UIScrollView (#1821)

* [Accessibility] Do not exclude elements outside the window’s rect that are subviews of UIScrollView

Previously I put up a diff to exclude accessibility elements that were outside of the current window rect. However, I didn’t take the case of scrollViews (including table and collection views) into consideration. By ignoring cells outside of the window, the scroll view would not advance to additional elements in the scrollView but off screen.

I did some side-by-side testing with UIKit and it appears that no elements are excluded that are in a scroll view, even if the element’s rect is outside of the scroll view’s visible rect. In order to match this behavior, I added a recursive superview check to see if an element that is off screen has a scrollView as a parent. If so, we do not exclude it:

```    if (!CGRectIntersectsRect(view.window.frame, nodeInWindowCoords) && !recusivelyCheckSuperviewsForScrollView(view)) {
        continue;
    }```

* fix some spacings

* force a build

* build bump again

* Removes unnecessary `-tearDown` code. (#1822)

* Update Texture.podspec (#1773)

3.0.0

* support cancelation in ASGraphicsCreateImage (#1814)

* support cancelation in ASGraphicsCreateImage

* updated comment

* [IGListKit] Extended IGListKit support for displaying delegates (#1011)

* Extended IGListKit support for node deselect, highlight and unhighlight

* Proposal of renaming willDisplayItemWithNode and didEndDisplayingItemWithNode to be similiar to UICollectionView

* Extended support for IGListDisplayDelegate

* Updated changelog with displaying delegates change

* Removed extra deprecation supression flag

* Reverted ASCollectionNode changes and implemented displaing delegate with indexPathForNode:

* Sending a real UICollectionViewCell to the delegate if not nil

* Added safety check for nil indexPaths

* Discard any CHANGELOG changes for fix Danger error

* Add an experimental flag to use native dispatch_apply (#1345)

* Add an experimental flag to use native dispatch_apply instead of our core count * 2 approach. This has shown performance wins in some profiling.

* Add in other places

* Don't return non-animated GIFs for animation (update to latest PINRemoteImage beta) (#940)

* Don't return non-animated GIFs for animation

* Update to latest PINRemoteImage beta

* Fix typos  (#1348)

* Update containers-overview.md

* Update subclassing.md

* Update node-overview.md

ASImageNode, ASNetworkImageNode and ASMultiplexImageNode are in place of UIImageView, not UIImage.

* Revert "Have node and controller share lock (#1227)" (#1347)

This reverts commit 2baa943.

* Don't compile out ASExperimentalTextNode if ASTextNode is compiled out (#1353)

* Lock up to yogaRoot during layout to avoid deadlocks. (#1356)

* Lock up to yogaRoot during layout to avoid dead lock.

1) lock to root for tree
2) lock self to change parent (& consequently root)
3) Implement ASLocking (tryLock) on ASNodeController
4) add lockPair to try-lock node & controller together
5) lock controllers if they exist in lockToRoot...

Disable some asserts due to lock to root. :(

LL# No commands remaining.

* Add macro so non-Yoga still builds :)

* wut

* Update layout-transition-api.md (#1357)

* Optimize ASTwoDimensionalArrayUtils (#1351)

* Optimize ASTwoDimensionalArrayUtils

These methods are called on the main thread during range controller updates (i.e. every frame) and so they should be as fast as possible.

* Rename

* Use vector instead of stack array to handle really big cases (e.g. photos)

* If we check for batching before content size is available we'll always fetch (#1355)

* Do not lock the nodeController if we are not locking to root. (#1360)

Doing so leaves it locked when we elsewhere explicitly unlock the node to ascend.

* Resolve root constrained size before informing delegate to resolve infinite layout loop. (#1359)

* Add `setNeedsLayout` to yoga tree changes. (#1361)

* Make ASCollectionElement Public (#1303)

* Update AsyncDisplayKit.h

* Update project.pbxproj

* Optimize _assertSubnodeState (#1352)

* Optimize _assertSubnodeState

This method is actually pretty painful in today's world. In one iPad mini trace, the first page of nodes spent 6.6ms in this call, just in time profiler.

* Clean it up, check count

* Check the right value

* _ASCollectionViewCell - The point isn't converted before to send to node, impossible to touch button into the node hierarchy (#1362)

* Revert node call, useless, the node has a ASDisplayView, and this view forward on the node in first.

* Use convertPoint to convert the given point in hittest & pointInside methods.
Keep the standard usage if the node didn't rasterized a view.

* Removed isNodeLoaded, finally it's useless in this case
In these methods, we are on the mainThread, we can create the view if the view is not created.

* Optimize ASCATransactionQueue (#1350)

* Optimize ASCATransactionQueue. This queue is very busy, and it runs on the main thread so it's important for it to be fast.

Avoid waking up the run loop for every single node.
Avoid a ton of NSPointerArray overhead that we don't need.
Avoid retain/release traffic on the singleton by using an inline function. I confirmed that in release mode, the static __strong is correctly inlined and no ARC traffic is incurred.

* Comment

* Unlock right

* Remove magic number

* Cleanup Yoga Categories (#1364)

* Add forwarding of UIAccessibilityAction methods (#1344)

* Add forwarding of UIAccessibilityAction methods

* Use OCMock for testing UIAccessibilityAction method forwarding

* Don't add extraneous truncation token during kCTLineTruncationMiddle. (#1297)

* Don't add extraneous truncation token during kCTLineTruncationMiddle

* Expand these comments a little.

* Update the FAQ to throw less shade. (#1379)

* Update the FAQ to throw less shade.

Both of these technologies have their place, no point in being assholes.

* Update faq.md

* [Updated Snapshots] Don't add extraneous truncation token during kCTLineTruncationMiddle (#1375)

* Don't add extraneous truncation token during kCTLineTruncationMiddle

* Expand these comments a little.

* Update snapshot tests with beautiful correct behavior

* Launches switching ASNetworkImageNode callbacks to global queue. (#1369)

* Launches switching ASNetworkImageNode callbacks to global queue.

* Good catch configuration tests!

* Make ASTextNode2 more forgiving when searching for links (#1374)

* Make ASTextNode2 more forgiving when searching for links by searching a 44x44 square around the touch

* Trailing whitespace

* Safely handle end-of-line

* Experiment with different strategies for image downloader priority (#1349)

Right now when an image node enters preload state, we kick off an image request with the default priority. Then when it enters display state, we change the priority to "imminent" which is mapped to the default priority as well. This means that requests from preload and display nodes have the same priority and are put to the same pool. The right behavior would be that preload requests should have a lower priority from the beginning.

Another problem is that, due to the execution order of -didEnter(Preload|Display|Visible)State calls, a node may kick off a low priority request when it enters preload state even though it knows that it's also visible. By the time -didEnterVisibleState is called, the low priority request may have already been consumed and the download/data task won't pick up the new higher priority, or some work needs to be done to move it to another queue. A better behavior would be to always use the current interface state to determine the priority. This means that visible nodes will kick off high priority requests as soon as -didEnterPreloadState is called.

The last (and smaller) issue is that a node marks its request as preload/low priority as soon as it exits visible state. I'd argue that this is too agressive. It may be reasonble for nodes in the trailing direction. Even so, we already handle this case by (almost always) have smaller trailing buffers. So this diff makes sure that nodes that exited visible state will have imminent/default priority if they remain in the display range.

All of these new behaviors are wrapped in an experiment and will be tested carefully before being rolled out.

* Add imports

* Fix build failure

* Encapsulate common logics into methods

* Address comments

* Whoops, someone forgot an else! (#1385)

Luckily it seems this didn't cause huge memory bloat because there's
a check below that keeps the display flag from being set in low memory
conditions when the node is off the screen.

* Catch invalid sizes during yoga layout (#1376)

* Correct View vs. Layer here (tho it doesn't make any difference) (#1378)

Older FBSnapshot versions, however, don't use VerifyViewOrLayer

* Expose initial constrained size before layout in case anyone is interested later during the layout on the same thread. (#1377)

Optionally, clients are expected to clean it up after usage to avoid accessing outdated data.

* Assert for context creation failure during displayBlock. (#1373)

Nothing good can possibly happen if we continue without one.

* Fix an issue where state change notifications can be sent mulitple times. (#1372)

Before the change: both - (void)setShouldInvertStrongReference:(BOOL)shouldInvertStrongReference and - (void)setNode:(ASDisplayNode *)node will call through [self setupReferencesWithNode:node]; which call the [node addInterfaceStateDelegate:self];

* Add Yoga support to ASButtonNode (#1381)

* Add Yoga support to ASButtonNode

* Drop unowned ASLayoutElementStyle parameter

* Fix access of Yoga properties

* Move ASButtonNode Yoga logic to Category

* Update header

* Fix CTLineRef leaks (#1386)

Found by Clang Static Analyzer:

~/Texture/Source/ASTextNode2.mm:663:39: warning: Potential leak of an object stored into 'truncationTokenLine'
      CTLineRef truncationTokenLine = CTLineCreateWithAttributedString((CFAttributedStringRef)_truncationAttributedText);
                                      ^
~/Texture/Source/ASTextNode2.mm:666:49: warning: Potential leak of an object stored into 'additionalTruncationTokenLine'
      CTLineRef additionalTruncationTokenLine = CTLineCreateWithAttributedString((CFAttributedStringRef)_additionalTruncationMessage);
                                                ^
2 warnings generated.

* Correct attributes lookup for supplementary elements. (#1318)

* Need some more locks for working with calculated yoga layouts (#1388)

* Adds support for using UIGraphicsImageRenderer in ASTextNode. (#1384)

* Adds support for using UIGraphicsImageRenderer in ASTextNode.

In many cases this reduces the backing store of text nodes by 1/2.

* Guard for UIGraphicsRenderer availability.

* Comma

* Add UIDataSourceModelAssociation to ASTableView and ASCollectionView (#1354)

* Add UIDataSourceModelAssociation protocol conformance to ASTableView and ASCollectionView.

* Implementing review feedback from @Adlai-Holler

* Rename ASDN C++ namespace to AS (#1366)

* Rename ASDN C++ namespace to "AS." Referring to the framework as ASDisplayNode is pretty out-dated and verbose. See CoreAnimation which usees CA for their internal namespace.

More using

* More cases

* Clean up a clang analyzer cast error (#1387)

~/Texture/Source/Private/ASMutableElementMap.mm:32:24: warning: Conversion from value of type 'NSMutableArray<NSMutableArray *> *' to incompatible type 'ASMutableCollectionElementTwoDimensionalArray *'
    _sectionsOfItems = (id)ASTwoDimensionalArrayDeepMutableCopy(items);
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

* Update for 9.4.1 CI (#1392)

* Remove experimental features (exp_skip_a11y_wait && exp_new_default_cell_layout_mode) (#1383)

* Remove experimental features

* prevent blocking main thread

* remove small content all together as none is the default

* Update ASExperimentalFeatures.h

* Make experiment checks faster (#1393)

* Make experiment checks use dispatch_once when not debugging, clean up singleton

* One more

* Pull out the variable

* Make shared CA transaction queue variable extern so it's actually shared (#1397)

* Fix header typo (#1402)

* Context is a pretty general name that will cause conflicts with subclasses (#1399)

* Suppress documentation warnings when using external libraries (#1401)

Fixes 1400

* Add layer-action support to nodes (#1396)

* Add layer-action support to nodes, unify hierarchy notifications on it

* Better pending state

* Fix bool

* Skip extra copy

* Never run default actions

* Continue the search

* Avoid an unnecessary lock & unlock pair in ASMainSerialQueue (#1409)

* Add clang-format for a common source code format (#1365)

* Add clang-format

* Update format to be as close as our current style

* Fix GIF Caching (#1405)

* Add support for reverse direction to yoga layouts (#1413)

* Add support for reverse direction to yoga layouts

* #ifdef YOGA yoga-specific additions

* oops

* Only set ASLayoutElementStyle delegate if Yoga is enabled (#1417)

* Fix bug in ASRangeController that causes some cell nodes of a collection view which is about to becomes invisible to load their backing view/layer and render (#1418)

* Fix a bug with Yoga nodes whose position change and don't update. (#1408)

* Follow up on the ASRangeController fix in #1418 (#1419)

The changes in #1418 is a bit too aggressive when it comes to nodes that are in display range. It forces those nodes to not preload.

Also update the changes to avoid diluting the experiment data by triggering too broadly (i.e avoid triggering when the old and new implementations yield the same result leading to no behavior change).

* Dev docs for threading in Texture (#1319)

* Getting started on adding threading by example

* writing writing writing

* more info

* More threading

* More more more

* Threading

* self lock

* Some language fixes

* Update docs/_docs/development/threading.md

Co-Authored-By: mikezucc <mikezuccarino@gmail.com>

* fix image references

* Removed locked jekyll version (#1322)

* showcase.md updated (#1421)

* Experiment with disabling ASViewController background dealloc (#1420)

* [Experiment] Dont forget about these collection view background deallocs (#1424)

* Dont forget about these collection view background deallocs

* Also Table view for completeness

* Fix retain cycle with transaction operations (#1429)

Add unit tests that help find cycles. `-testWeakWithSingleOperation` fails without the code fix applied.

* Replace +load initializers with __attribute__((constructor)) functions (#1425)

* Replace +load initializers with __attribute__((constructor)) functions

* Updating the documentation for textureDidInitialize, per @nguyenhuy

* Fix dealloc on bg (#1410)

* fix SIMULATE_WEB_RESPONSE not imported #449

* Fix to make rangeMode update in right time

* remove uncessary assert

* Fix collection cell editing bug for iOS 9 & 10

* Revert "Fix collection cell editing bug for iOS 9 & 10"

This reverts commit 06e18a1.

* Fix dealloc long gesture in background

* Add support for clipping only specific corners, add unit tests (#1415)

* Add support for clipping only specific corners, add unit tests

* Remove some cleanup to make the diff smaller

* Fix

* [ASImageNode]fix incorrect backing size calculation (#1189)

* fix backing size for image node which content mode is scaleAspectFit

* chore: update comments and naming

* add change log

* Update CHANGELOG.md

* Update CHANGELOG.md

Co-Authored-By: junjielu <348649634@qq.com>

* add unit test for backing size calculation

* correct license

* Have image nodes draw into opaque contexts automatically if possible (#1432)

* Have image nodes draw into opaque contexts if the image is opaque and it fills the context

* Call backingSize once

* Fix typo in batch-fetching-api.md (#1437)

* [ASDisplayNode] Stop infinite layout in _u_measureNodeWithBoundsIfNecessary (#1434)

We came across an infinite layout loop in `_u_measureNodeWithBoundsIfNecessary`. After requesting a layout from above, the sizes between pending and caluclated layout still do not match. We continue to prefer to use the pending layout and ask for another layout loop from above. We can’t seem to break out of this loop. The solution (thanks to Huy for the guidance) was to nil out the pending layout we get from requesting the layout from above.

I was only able to reproduce this when working with a node in a `UINavigationBarItem’s` `titleView`. I think that UIKit must be doing something sneaky with setting the frame on the view. While I was not able to create a unit test to catch this issue (I tried for a long time, and can post what I’ve come up with to see if anyone has any suggestions), I was able to create a pretty simple example project that shows the behavior:
https://github.com/rcancro/TextureLayoutLoopExample

* Add a verbose log for locking operations. Has no effect in production (#1436)

* Add a verbose log for locking operations. Has no effect in production

* Need check

* Wrap transaction operation retain cycle fix in an experiment (#1438)

* Wrap transaction operation retain cycle fix in an experiment

This is a follow on to #1429.

* fix typo in experiment name. fix copyright in tests file.

* Fix scroll node in yoga (#1435)

* fix SIMULATE_WEB_RESPONSE not imported #449

* Fix to make rangeMode update in right time

* remove uncessary assert

* Fix collection cell editing bug for iOS 9 & 10

* Revert "Fix collection cell editing bug for iOS 9 & 10"

This reverts commit 06e18a1.

* Fix child not fit to full scroll node's bounds when flex_grow = 1.0 is used on child

* Fix the stub for layerActionForKey: to let CA continue the search (#1441)

* Fix the stub for layerActionForKey: to let CA continue the search

* Kick CI

* Revert "Have image nodes draw into opaque contexts automatically if possible (#1432)" (#1443)

This reverts commit 28522ce.

* Use instance lock for ASPrimitiveTraitCollection (#1442)

* Use instance lock for ASPrimitiveTraitCollection

* Remove the atomic

* Simplify ASTraitCollection propagation in ASViewController (#1447)

* Use AS::Mutex in ASCollectionElement (#1445)

* [ASTextNode] Maintain isAccessibilityElement setting on text nodes when updating text (#1326)

* Add didEnterHierarchy/didExitHierarchy to ASNodeController. (#1444)

* Fix wrongly formatted RELEASE link (#1453)

* Only create activities during debug (#1456)

* [#1451] Add support for UIAccessibilityCustomAction (#1452)

This PR adds support for UIAccessibilityCustomAction propagation through ASPendingState so that it can be picked up by VoiceOver.

* Shut down graphics contexts experiment (#1458)

* Shut down graphics contexts experiment

* Remove dead import

* Remove gone class

* Remove lock of ASTextNodeRendererKey (#1454)

* Remove lock of ASTextNodeRendererKey

* Remove class check for isEqual

* Add const specifier to function parameter

* Fixes typo

* Fixes typo

* Disable ASAssertLocked and ASAssertUnlocked (#1412)

* Try to remove global lock when initialising TextKit components (#1455)

* Try to remove global lock when initialising TextKit components

* Adding experiment flag to dis/enable lock of textkit component

* Adding tests

* code clean

fix typo

Make remove lock optional

Keep locks

code clean

* Make ASCollectionNode's pan gesture customizable (#1457)

* changes done

* complete set of uigesturedeleagte methods

* Remove iOS 8 support from logging code. (#1462)

* Drop support for Xcode 8 and fix some compiler warnings (#1463)

* Remove ASEventLog (#1460)

* Remove ASEventLog. We'll focus on ASLog for the future, possibly making it triggerable on a per-node basis

* See ya!

* Hello semicolon

* Remove refs to gone tree methods

* Fix

* Remove irrelevant change, kick CI

* Clean up

* Cover the other background dealloc surfaces (#1464)

* Passthrough pagingEnabled for ASCollectionNode / ASTableNode (#1466)

* Passthrough pagingEnabled for ASCollectionNode and ASTableNode

* Add tvOS handling

* Fix open context bug introduced in #1458 (#1468)

* Make sure all ASDisplayNode properties have backing ivars for consistency. (#1475)

* Make sure all ASDisplayNodes have backing ivars for consistency.

Found this by enabling #pragma clang diagnostic error "-Wobjc-missing-property-synthesis" for ASDisplayNode. One property is unused, saving 8 bytes of heap space per instance on 64-bit builds. Implement setter/getters for these properties, and add appropriate locking. add the warning as error to the build for this file.

* Ensure ASControlMode properties lock before accessing their ivars (#1476)

Enable `#pragma clang diagnostic error "-Wobjc-missing-property-synthesis"` for this file.

* Add a new "global drawing" experiment to use UIGraphicsRenderer (#1469)

* Add a new "global drawing" experiment to use UIGraphicsRenderer everywhere, when available

* Fix logic

* Use preferredFormat

* Cut version 2.8.1 (#1491)

* Clean up documentation issues around periods (#1490)

There were so unnecessary `'` around periods for some reason. Just deleting those because they are distracting.

* Minor update in change log #changelog (#1492)

* Ship ASExperimentalFixRangeController (#1486)

* Shrink _ASCollectionPendingState from 144 to 128 bytes, a 12.5% reduction (#1485)

* Shrink _ASCollectionPendingState from 144 to 128 bytes, a 12.5% reduction

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* address review comments. move enums out. add comment. rename struct to _flags

* fix a missing rename

* Shrink _ASPendingState from 824 to 808 bytes, reduction of ~2% (#1483)

* Shrink _ASPendingState from 824 to 808 bytes, reduction of ~2%

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Shrink ASPendingState BOOLs. Use unsigned int for these bitfields for clarity. Separate from `_flags` as that struct is compared to `0` for testing. The `_boolFlags` struct is just storing other `BOOL`s.

* rename struct fields as suggested in garret's review.

* Shrink ASDisplayNode from 1072 to 968 bytes, reduction of 10.74% (#1484)

* Shrink ASDisplayNode from 1088 to 976 bytes, reduction of 11.48%

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* Forgot to bit-field-ify placeholderEnable; new small size is 968, old size is 1072 (measured consistentlyl on iPhoneSE simulator). 10.74% reduction.

* Shrink Button Node (#1494)

Button: 1312 to 1288 bytes, running on iPhone SE simulator. 1.9% reduction.

Shrink the enums it stores, and place them next to each other (along with a BOOL) to reduce instance size.

* Shrink TextNode(2) (#1495)

Running in iPhone SE Simulator:
- ASTextNode: 1360 to 1352 bytes .6% reduction
- ASTextNode2: 1360 to 1304 bytes 4.3% redction

Shrink stored enum sizes. Group BOOLs near these smaller enums. Override -usingExperiment to return constant instead of never set, but allocated ivar.

* Shrink Pager and Scroll Node (#1496)

Running on iPhone SE Simulator:
ASPagerNode 1240 to 1232 bytes .7% reduction
ASScrollNode 1104 to 1096 bytes .7% reduction

- make ASScrollNode smaller by shrinking ASScrollDirection, which requires a change to ASRangeController
- shrink ASPagerNode by declaring the BOOL next to the struct

* Shrink ASImageNode by .6% and ASNetworkImageNode by 2.2% (#1487)

* Shrink ASImageNode by .6% and ASNetworkImageNode by 2.2%

ASImageNode goes from 1384 to 1376. ASNetworkImageNode goes from 1496 to 1464.

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* add comments as requested in garrett's review.

* access ivar directly since already locked as suggested in review.

* Remove unused declaration, missed in #1460 (#1497)

* Keep the atomics - does not affect memory work (#1498)

Revert "Ensure ASControlMode properties lock before accessing their ivars (#1476)"
This reverts commit ce1e195.

Revert "Make sure all ASDisplayNode properties have backing ivars for consistency. (#1475)"
This reverts commit d6061f4.
- Except the unused property `interfaceStateSuspended` is still removed (this is a memory saver).

* Shrink ASCellNode by 8 bytes (#1499)

Group the BOOLs together, since there are only 4 (and there are no other auto-generated ivars that are < 64 bits) this is sufficient and keeps the properties `atomic`.

* Shrink ASEditableTextNode by 16 bytes (#1500)

Just shuffle some BOOLs around and explicitly declare an ivar so it is grouped with the others.

* ASSignpost: Add support for the os_signpost API, fixes (#1501)

* ASSignpost: Add support for the os_signpost API

- Removes support for colored intervals. These weren't really useful and they aren't part of the signpost api.
- Fixes an issue with range controller interval logging.
- Adds an interval for interface orientation changes.

* Rename

* Support Xcode 9

* Commentary

* Shrink ASLayout (#1503)

- Shrink the enum. Save 8 bytes. There are 1000s of these in the heap after running Pinterest for 10 minutes.

* Cleanup whitespace #trivial (#1507)

(It's easier to deal with these as silly oneoffs IMO than to
have them conflated with real work)

* Shrink LayoutSpec classes (#1502)

- Resize enums to make `ASStackLayoutSpec` 40 bytes smaller. This applies to the subclasses too.

Co-authored-by: Adlai Holler <adlai@icloud.com>
Co-authored-by: Garrett Moon <garrett@pinterest.com>
Co-authored-by: dirtmelon <272485887@qq.com>
Co-authored-by: Michael Schneider <maicki@users.noreply.github.com>
Co-authored-by: Kevin <kevin@wode.com>
Co-authored-by: dirtmelon <0xffdirtmelon@gmail.com>
Co-authored-by: Jonathan Downing <jd@jonathandowning.uk>
Co-authored-by: Xavier Deloge <Idefix60@users.noreply.github.com>
Co-authored-by: Eric Scheers <smeis@users.noreply.github.com>
Co-authored-by: Huy Nguyen <allforone1511@gmail.com>
Co-authored-by: Greg Bolsinga <bolsinga@mac.com>
Co-authored-by: Jacob Farkas <farktronix@users.noreply.github.com>
Co-authored-by: ernestmama <43187788+ernestmama@users.noreply.github.com>
Co-authored-by: Andrew Yates <contact@andydev.co.uk>
Co-authored-by: Tim Norman <tim@normsoft.com>
Co-authored-by: Michael Zuccarino <mikezuccarino@gmail.com>
Co-authored-by: Dmitry Gridnev <dmitr.gridnev@gmail.com>
Co-authored-by: Max Wang <max.wang.cs@gmail.com>
Co-authored-by: Ballad <348649634@qq.com>
Co-authored-by: ricky <rickycancro@gmail.com>
Co-authored-by: Patrick Balestra <me@patrickbalestra.com>
Co-authored-by: Harry Shamansky <harry.shamansky@gmail.com>
Co-authored-by: Wu Zhong <zhongwuzw@qq.com>
Co-authored-by: Oskar Zhang <i@oskarzhang.me>
Co-authored-by: Adlai Holler <adlai@google.com>
Co-authored-by: Greg Bolsinga <gbolsinga@pinterest.com>
Co-authored-by: Huy Nguyen <huy@pinterest.com>
Co-authored-by: Andrew Monshizadeh <amonshiz+github@gmail.com>

* use iOS 13.4.1 and default Xcode 11.4.1 for CI (#1831)

Co-authored-by: dmaclach <dmaclach@gmail.com>
Co-authored-by: Jeffrey Macko <mackoj@users.noreply.github.com>
Co-authored-by: vovasty <vlad@aramzamzam.net>
Co-authored-by: Heberti Almeida <hebertialmeida@gmail.com>
Co-authored-by: Adlai Holler <adlai@icloud.com>
Co-authored-by: Garrett Moon <garrett@pinterest.com>
Co-authored-by: dirtmelon <272485887@qq.com>
Co-authored-by: Michael Schneider <maicki@users.noreply.github.com>
Co-authored-by: Kevin <kevin@wode.com>
Co-authored-by: dirtmelon <0xffdirtmelon@gmail.com>
Co-authored-by: Jonathan Downing <jd@jonathandowning.uk>
Co-authored-by: Xavier Deloge <Idefix60@users.noreply.github.com>
Co-authored-by: Eric Scheers <smeis@users.noreply.github.com>
Co-authored-by: Huy Nguyen <allforone1511@gmail.com>
Co-authored-by: Greg Bolsinga <bolsinga@mac.com>
Co-authored-by: Jacob Farkas <farktronix@users.noreply.github.com>
Co-authored-by: ernestmama <43187788+ernestmama@users.noreply.github.com>
Co-authored-by: Andrew Yates <contact@andydev.co.uk>
Co-authored-by: Tim Norman <tim@normsoft.com>
Co-authored-by: Michael Zuccarino <mikezuccarino@gmail.com>
Co-authored-by: Dmitry Gridnev <dmitr.gridnev@gmail.com>
Co-authored-by: Max Wang <max.wang.cs@gmail.com>
Co-authored-by: Ballad <348649634@qq.com>
Co-authored-by: Patrick Balestra <me@patrickbalestra.com>
Co-authored-by: Harry Shamansky <harry.shamansky@gmail.com>
Co-authored-by: Wu Zhong <zhongwuzw@qq.com>
Co-authored-by: Oskar Zhang <i@oskarzhang.me>
Co-authored-by: Adlai Holler <adlai@google.com>
Co-authored-by: Greg Bolsinga <gbolsinga@pinterest.com>
Co-authored-by: Huy Nguyen <huy@pinterest.com>
Co-authored-by: Andrew Monshizadeh <amonshiz+github@gmail.com>
rcancro added a commit to rcancro/Texture that referenced this pull request May 28, 2020
…t are subviews of UIScrollView (TextureGroup#1821)

* [Accessibility] Do not exclude elements outside the window’s rect that are subviews of UIScrollView

Previously I put up a diff to exclude accessibility elements that were outside of the current window rect. However, I didn’t take the case of scrollViews (including table and collection views) into consideration. By ignoring cells outside of the window, the scroll view would not advance to additional elements in the scrollView but off screen.

I did some side-by-side testing with UIKit and it appears that no elements are excluded that are in a scroll view, even if the element’s rect is outside of the scroll view’s visible rect. In order to match this behavior, I added a recursive superview check to see if an element that is off screen has a scrollView as a parent. If so, we do not exclude it:

```    if (!CGRectIntersectsRect(view.window.frame, nodeInWindowCoords) && !recusivelyCheckSuperviewsForScrollView(view)) {
        continue;
    }```

* fix some spacings

* force a build

* build bump again

* Removes unnecessary `-tearDown` code. (TextureGroup#1822)

* Update Texture.podspec (TextureGroup#1773)

3.0.0

* support cancelation in ASGraphicsCreateImage (TextureGroup#1814)

* support cancelation in ASGraphicsCreateImage

* updated comment

* [IGListKit] Extended IGListKit support for displaying delegates (TextureGroup#1011)

* Extended IGListKit support for node deselect, highlight and unhighlight

* Proposal of renaming willDisplayItemWithNode and didEndDisplayingItemWithNode to be similiar to UICollectionView

* Extended support for IGListDisplayDelegate

* Updated changelog with displaying delegates change

* Removed extra deprecation supression flag

* Reverted ASCollectionNode changes and implemented displaing delegate with indexPathForNode:

* Sending a real UICollectionViewCell to the delegate if not nil

* Added safety check for nil indexPaths

* Discard any CHANGELOG changes for fix Danger error

* Add an experimental flag to use native dispatch_apply (TextureGroup#1345)

* Add an experimental flag to use native dispatch_apply instead of our core count * 2 approach. This has shown performance wins in some profiling.

* Add in other places

* Don't return non-animated GIFs for animation (update to latest PINRemoteImage beta) (TextureGroup#940)

* Don't return non-animated GIFs for animation

* Update to latest PINRemoteImage beta

* Fix typos  (TextureGroup#1348)

* Update containers-overview.md

* Update subclassing.md

* Update node-overview.md

ASImageNode, ASNetworkImageNode and ASMultiplexImageNode are in place of UIImageView, not UIImage.

* Revert "Have node and controller share lock (TextureGroup#1227)" (TextureGroup#1347)

This reverts commit 2baa943.

* Don't compile out ASExperimentalTextNode if ASTextNode is compiled out (TextureGroup#1353)

* Lock up to yogaRoot during layout to avoid deadlocks. (TextureGroup#1356)

* Lock up to yogaRoot during layout to avoid dead lock.

1) lock to root for tree
2) lock self to change parent (& consequently root)
3) Implement ASLocking (tryLock) on ASNodeController
4) add lockPair to try-lock node & controller together
5) lock controllers if they exist in lockToRoot...

Disable some asserts due to lock to root. :(

LL# No commands remaining.

* Add macro so non-Yoga still builds :)

* wut

* Update layout-transition-api.md (TextureGroup#1357)

* Optimize ASTwoDimensionalArrayUtils (TextureGroup#1351)

* Optimize ASTwoDimensionalArrayUtils

These methods are called on the main thread during range controller updates (i.e. every frame) and so they should be as fast as possible.

* Rename

* Use vector instead of stack array to handle really big cases (e.g. photos)

* If we check for batching before content size is available we'll always fetch (TextureGroup#1355)

* Do not lock the nodeController if we are not locking to root. (TextureGroup#1360)

Doing so leaves it locked when we elsewhere explicitly unlock the node to ascend.

* Resolve root constrained size before informing delegate to resolve infinite layout loop. (TextureGroup#1359)

* Add `setNeedsLayout` to yoga tree changes. (TextureGroup#1361)

* Make ASCollectionElement Public (TextureGroup#1303)

* Update AsyncDisplayKit.h

* Update project.pbxproj

* Optimize _assertSubnodeState (TextureGroup#1352)

* Optimize _assertSubnodeState

This method is actually pretty painful in today's world. In one iPad mini trace, the first page of nodes spent 6.6ms in this call, just in time profiler.

* Clean it up, check count

* Check the right value

* _ASCollectionViewCell - The point isn't converted before to send to node, impossible to touch button into the node hierarchy (TextureGroup#1362)

* Revert node call, useless, the node has a ASDisplayView, and this view forward on the node in first.

* Use convertPoint to convert the given point in hittest & pointInside methods.
Keep the standard usage if the node didn't rasterized a view.

* Removed isNodeLoaded, finally it's useless in this case
In these methods, we are on the mainThread, we can create the view if the view is not created.

* Optimize ASCATransactionQueue (TextureGroup#1350)

* Optimize ASCATransactionQueue. This queue is very busy, and it runs on the main thread so it's important for it to be fast.

Avoid waking up the run loop for every single node.
Avoid a ton of NSPointerArray overhead that we don't need.
Avoid retain/release traffic on the singleton by using an inline function. I confirmed that in release mode, the static __strong is correctly inlined and no ARC traffic is incurred.

* Comment

* Unlock right

* Remove magic number

* Cleanup Yoga Categories (TextureGroup#1364)

* Add forwarding of UIAccessibilityAction methods (TextureGroup#1344)

* Add forwarding of UIAccessibilityAction methods

* Use OCMock for testing UIAccessibilityAction method forwarding

* Don't add extraneous truncation token during kCTLineTruncationMiddle. (TextureGroup#1297)

* Don't add extraneous truncation token during kCTLineTruncationMiddle

* Expand these comments a little.

* Update the FAQ to throw less shade. (TextureGroup#1379)

* Update the FAQ to throw less shade.

Both of these technologies have their place, no point in being assholes.

* Update faq.md

* [Updated Snapshots] Don't add extraneous truncation token during kCTLineTruncationMiddle (TextureGroup#1375)

* Don't add extraneous truncation token during kCTLineTruncationMiddle

* Expand these comments a little.

* Update snapshot tests with beautiful correct behavior

* Launches switching ASNetworkImageNode callbacks to global queue. (TextureGroup#1369)

* Launches switching ASNetworkImageNode callbacks to global queue.

* Good catch configuration tests!

* Make ASTextNode2 more forgiving when searching for links (TextureGroup#1374)

* Make ASTextNode2 more forgiving when searching for links by searching a 44x44 square around the touch

* Trailing whitespace

* Safely handle end-of-line

* Experiment with different strategies for image downloader priority (TextureGroup#1349)

Right now when an image node enters preload state, we kick off an image request with the default priority. Then when it enters display state, we change the priority to "imminent" which is mapped to the default priority as well. This means that requests from preload and display nodes have the same priority and are put to the same pool. The right behavior would be that preload requests should have a lower priority from the beginning.

Another problem is that, due to the execution order of -didEnter(Preload|Display|Visible)State calls, a node may kick off a low priority request when it enters preload state even though it knows that it's also visible. By the time -didEnterVisibleState is called, the low priority request may have already been consumed and the download/data task won't pick up the new higher priority, or some work needs to be done to move it to another queue. A better behavior would be to always use the current interface state to determine the priority. This means that visible nodes will kick off high priority requests as soon as -didEnterPreloadState is called.

The last (and smaller) issue is that a node marks its request as preload/low priority as soon as it exits visible state. I'd argue that this is too agressive. It may be reasonble for nodes in the trailing direction. Even so, we already handle this case by (almost always) have smaller trailing buffers. So this diff makes sure that nodes that exited visible state will have imminent/default priority if they remain in the display range.

All of these new behaviors are wrapped in an experiment and will be tested carefully before being rolled out.

* Add imports

* Fix build failure

* Encapsulate common logics into methods

* Address comments

* Whoops, someone forgot an else! (TextureGroup#1385)

Luckily it seems this didn't cause huge memory bloat because there's
a check below that keeps the display flag from being set in low memory
conditions when the node is off the screen.

* Catch invalid sizes during yoga layout (TextureGroup#1376)

* Correct View vs. Layer here (tho it doesn't make any difference) (TextureGroup#1378)

Older FBSnapshot versions, however, don't use VerifyViewOrLayer

* Expose initial constrained size before layout in case anyone is interested later during the layout on the same thread. (TextureGroup#1377)

Optionally, clients are expected to clean it up after usage to avoid accessing outdated data.

* Assert for context creation failure during displayBlock. (TextureGroup#1373)

Nothing good can possibly happen if we continue without one.

* Fix an issue where state change notifications can be sent mulitple times. (TextureGroup#1372)

Before the change: both - (void)setShouldInvertStrongReference:(BOOL)shouldInvertStrongReference and - (void)setNode:(ASDisplayNode *)node will call through [self setupReferencesWithNode:node]; which call the [node addInterfaceStateDelegate:self];

* Add Yoga support to ASButtonNode (TextureGroup#1381)

* Add Yoga support to ASButtonNode

* Drop unowned ASLayoutElementStyle parameter

* Fix access of Yoga properties

* Move ASButtonNode Yoga logic to Category

* Update header

* Fix CTLineRef leaks (TextureGroup#1386)

Found by Clang Static Analyzer:

~/Texture/Source/ASTextNode2.mm:663:39: warning: Potential leak of an object stored into 'truncationTokenLine'
      CTLineRef truncationTokenLine = CTLineCreateWithAttributedString((CFAttributedStringRef)_truncationAttributedText);
                                      ^
~/Texture/Source/ASTextNode2.mm:666:49: warning: Potential leak of an object stored into 'additionalTruncationTokenLine'
      CTLineRef additionalTruncationTokenLine = CTLineCreateWithAttributedString((CFAttributedStringRef)_additionalTruncationMessage);
                                                ^
2 warnings generated.

* Correct attributes lookup for supplementary elements. (TextureGroup#1318)

* Need some more locks for working with calculated yoga layouts (TextureGroup#1388)

* Adds support for using UIGraphicsImageRenderer in ASTextNode. (TextureGroup#1384)

* Adds support for using UIGraphicsImageRenderer in ASTextNode.

In many cases this reduces the backing store of text nodes by 1/2.

* Guard for UIGraphicsRenderer availability.

* Comma

* Add UIDataSourceModelAssociation to ASTableView and ASCollectionView (TextureGroup#1354)

* Add UIDataSourceModelAssociation protocol conformance to ASTableView and ASCollectionView.

* Implementing review feedback from @Adlai-Holler

* Rename ASDN C++ namespace to AS (TextureGroup#1366)

* Rename ASDN C++ namespace to "AS." Referring to the framework as ASDisplayNode is pretty out-dated and verbose. See CoreAnimation which usees CA for their internal namespace.

More using

* More cases

* Clean up a clang analyzer cast error (TextureGroup#1387)

~/Texture/Source/Private/ASMutableElementMap.mm:32:24: warning: Conversion from value of type 'NSMutableArray<NSMutableArray *> *' to incompatible type 'ASMutableCollectionElementTwoDimensionalArray *'
    _sectionsOfItems = (id)ASTwoDimensionalArrayDeepMutableCopy(items);
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

* Update for 9.4.1 CI (TextureGroup#1392)

* Remove experimental features (exp_skip_a11y_wait && exp_new_default_cell_layout_mode) (TextureGroup#1383)

* Remove experimental features

* prevent blocking main thread

* remove small content all together as none is the default

* Update ASExperimentalFeatures.h

* Make experiment checks faster (TextureGroup#1393)

* Make experiment checks use dispatch_once when not debugging, clean up singleton

* One more

* Pull out the variable

* Make shared CA transaction queue variable extern so it's actually shared (TextureGroup#1397)

* Fix header typo (TextureGroup#1402)

* Context is a pretty general name that will cause conflicts with subclasses (TextureGroup#1399)

* Suppress documentation warnings when using external libraries (TextureGroup#1401)

Fixes 1400

* Add layer-action support to nodes (TextureGroup#1396)

* Add layer-action support to nodes, unify hierarchy notifications on it

* Better pending state

* Fix bool

* Skip extra copy

* Never run default actions

* Continue the search

* Avoid an unnecessary lock & unlock pair in ASMainSerialQueue (TextureGroup#1409)

* Add clang-format for a common source code format (TextureGroup#1365)

* Add clang-format

* Update format to be as close as our current style

* Fix GIF Caching (TextureGroup#1405)

* Add support for reverse direction to yoga layouts (TextureGroup#1413)

* Add support for reverse direction to yoga layouts

* #ifdef YOGA yoga-specific additions

* oops

* Only set ASLayoutElementStyle delegate if Yoga is enabled (TextureGroup#1417)

* Fix bug in ASRangeController that causes some cell nodes of a collection view which is about to becomes invisible to load their backing view/layer and render (TextureGroup#1418)

* Fix a bug with Yoga nodes whose position change and don't update. (TextureGroup#1408)

* Follow up on the ASRangeController fix in TextureGroup#1418 (TextureGroup#1419)

The changes in TextureGroup#1418 is a bit too aggressive when it comes to nodes that are in display range. It forces those nodes to not preload.

Also update the changes to avoid diluting the experiment data by triggering too broadly (i.e avoid triggering when the old and new implementations yield the same result leading to no behavior change).

* Dev docs for threading in Texture (TextureGroup#1319)

* Getting started on adding threading by example

* writing writing writing

* more info

* More threading

* More more more

* Threading

* self lock

* Some language fixes

* Update docs/_docs/development/threading.md

Co-Authored-By: mikezucc <mikezuccarino@gmail.com>

* fix image references

* Removed locked jekyll version (TextureGroup#1322)

* showcase.md updated (TextureGroup#1421)

* Experiment with disabling ASViewController background dealloc (TextureGroup#1420)

* [Experiment] Dont forget about these collection view background deallocs (TextureGroup#1424)

* Dont forget about these collection view background deallocs

* Also Table view for completeness

* Fix retain cycle with transaction operations (TextureGroup#1429)

Add unit tests that help find cycles. `-testWeakWithSingleOperation` fails without the code fix applied.

* Replace +load initializers with __attribute__((constructor)) functions (TextureGroup#1425)

* Replace +load initializers with __attribute__((constructor)) functions

* Updating the documentation for textureDidInitialize, per @nguyenhuy

* Fix dealloc on bg (TextureGroup#1410)

* fix SIMULATE_WEB_RESPONSE not imported TextureGroup#449

* Fix to make rangeMode update in right time

* remove uncessary assert

* Fix collection cell editing bug for iOS 9 & 10

* Revert "Fix collection cell editing bug for iOS 9 & 10"

This reverts commit 06e18a1.

* Fix dealloc long gesture in background

* Add support for clipping only specific corners, add unit tests (TextureGroup#1415)

* Add support for clipping only specific corners, add unit tests

* Remove some cleanup to make the diff smaller

* Fix

* [ASImageNode]fix incorrect backing size calculation (TextureGroup#1189)

* fix backing size for image node which content mode is scaleAspectFit

* chore: update comments and naming

* add change log

* Update CHANGELOG.md

* Update CHANGELOG.md

Co-Authored-By: junjielu <348649634@qq.com>

* add unit test for backing size calculation

* correct license

* Have image nodes draw into opaque contexts automatically if possible (TextureGroup#1432)

* Have image nodes draw into opaque contexts if the image is opaque and it fills the context

* Call backingSize once

* Fix typo in batch-fetching-api.md (TextureGroup#1437)

* [ASDisplayNode] Stop infinite layout in _u_measureNodeWithBoundsIfNecessary (TextureGroup#1434)

We came across an infinite layout loop in `_u_measureNodeWithBoundsIfNecessary`. After requesting a layout from above, the sizes between pending and caluclated layout still do not match. We continue to prefer to use the pending layout and ask for another layout loop from above. We can’t seem to break out of this loop. The solution (thanks to Huy for the guidance) was to nil out the pending layout we get from requesting the layout from above.

I was only able to reproduce this when working with a node in a `UINavigationBarItem’s` `titleView`. I think that UIKit must be doing something sneaky with setting the frame on the view. While I was not able to create a unit test to catch this issue (I tried for a long time, and can post what I’ve come up with to see if anyone has any suggestions), I was able to create a pretty simple example project that shows the behavior:
https://github.com/rcancro/TextureLayoutLoopExample

* Add a verbose log for locking operations. Has no effect in production (TextureGroup#1436)

* Add a verbose log for locking operations. Has no effect in production

* Need check

* Wrap transaction operation retain cycle fix in an experiment (TextureGroup#1438)

* Wrap transaction operation retain cycle fix in an experiment

This is a follow on to TextureGroup#1429.

* fix typo in experiment name. fix copyright in tests file.

* Fix scroll node in yoga (TextureGroup#1435)

* fix SIMULATE_WEB_RESPONSE not imported TextureGroup#449

* Fix to make rangeMode update in right time

* remove uncessary assert

* Fix collection cell editing bug for iOS 9 & 10

* Revert "Fix collection cell editing bug for iOS 9 & 10"

This reverts commit 06e18a1.

* Fix child not fit to full scroll node's bounds when flex_grow = 1.0 is used on child

* Fix the stub for layerActionForKey: to let CA continue the search (TextureGroup#1441)

* Fix the stub for layerActionForKey: to let CA continue the search

* Kick CI

* Revert "Have image nodes draw into opaque contexts automatically if possible (TextureGroup#1432)" (TextureGroup#1443)

This reverts commit 28522ce.

* Use instance lock for ASPrimitiveTraitCollection (TextureGroup#1442)

* Use instance lock for ASPrimitiveTraitCollection

* Remove the atomic

* Simplify ASTraitCollection propagation in ASViewController (TextureGroup#1447)

* Use AS::Mutex in ASCollectionElement (TextureGroup#1445)

* [ASTextNode] Maintain isAccessibilityElement setting on text nodes when updating text (TextureGroup#1326)

* Add didEnterHierarchy/didExitHierarchy to ASNodeController. (TextureGroup#1444)

* Fix wrongly formatted RELEASE link (TextureGroup#1453)

* Only create activities during debug (TextureGroup#1456)

* [TextureGroup#1451] Add support for UIAccessibilityCustomAction (TextureGroup#1452)

This PR adds support for UIAccessibilityCustomAction propagation through ASPendingState so that it can be picked up by VoiceOver.

* Shut down graphics contexts experiment (TextureGroup#1458)

* Shut down graphics contexts experiment

* Remove dead import

* Remove gone class

* Remove lock of ASTextNodeRendererKey (TextureGroup#1454)

* Remove lock of ASTextNodeRendererKey

* Remove class check for isEqual

* Add const specifier to function parameter

* Fixes typo

* Fixes typo

* Disable ASAssertLocked and ASAssertUnlocked (TextureGroup#1412)

* Try to remove global lock when initialising TextKit components (TextureGroup#1455)

* Try to remove global lock when initialising TextKit components

* Adding experiment flag to dis/enable lock of textkit component

* Adding tests

* code clean

fix typo

Make remove lock optional

Keep locks

code clean

* Make ASCollectionNode's pan gesture customizable (TextureGroup#1457)

* changes done

* complete set of uigesturedeleagte methods

* Remove iOS 8 support from logging code. (TextureGroup#1462)

* Drop support for Xcode 8 and fix some compiler warnings (TextureGroup#1463)

* Remove ASEventLog (TextureGroup#1460)

* Remove ASEventLog. We'll focus on ASLog for the future, possibly making it triggerable on a per-node basis

* See ya!

* Hello semicolon

* Remove refs to gone tree methods

* Fix

* Remove irrelevant change, kick CI

* Clean up

* Cover the other background dealloc surfaces (TextureGroup#1464)

* Passthrough pagingEnabled for ASCollectionNode / ASTableNode (TextureGroup#1466)

* Passthrough pagingEnabled for ASCollectionNode and ASTableNode

* Add tvOS handling

* Fix open context bug introduced in TextureGroup#1458 (TextureGroup#1468)

* Make sure all ASDisplayNode properties have backing ivars for consistency. (TextureGroup#1475)

* Make sure all ASDisplayNodes have backing ivars for consistency.

Found this by enabling #pragma clang diagnostic error "-Wobjc-missing-property-synthesis" for ASDisplayNode. One property is unused, saving 8 bytes of heap space per instance on 64-bit builds. Implement setter/getters for these properties, and add appropriate locking. add the warning as error to the build for this file.

* Ensure ASControlMode properties lock before accessing their ivars (TextureGroup#1476)

Enable `#pragma clang diagnostic error "-Wobjc-missing-property-synthesis"` for this file.

* Add a new "global drawing" experiment to use UIGraphicsRenderer (TextureGroup#1469)

* Add a new "global drawing" experiment to use UIGraphicsRenderer everywhere, when available

* Fix logic

* Use preferredFormat

* Cut version 2.8.1 (TextureGroup#1491)

* Clean up documentation issues around periods (TextureGroup#1490)

There were so unnecessary `'` around periods for some reason. Just deleting those because they are distracting.

* Minor update in change log #changelog (TextureGroup#1492)

* Ship ASExperimentalFixRangeController (TextureGroup#1486)

* Shrink _ASCollectionPendingState from 144 to 128 bytes, a 12.5% reduction (TextureGroup#1485)

* Shrink _ASCollectionPendingState from 144 to 128 bytes, a 12.5% reduction

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* address review comments. move enums out. add comment. rename struct to _flags

* fix a missing rename

* Shrink _ASPendingState from 824 to 808 bytes, reduction of ~2% (TextureGroup#1483)

* Shrink _ASPendingState from 824 to 808 bytes, reduction of ~2%

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Shrink ASPendingState BOOLs. Use unsigned int for these bitfields for clarity. Separate from `_flags` as that struct is compared to `0` for testing. The `_boolFlags` struct is just storing other `BOOL`s.

* rename struct fields as suggested in garret's review.

* Shrink ASDisplayNode from 1072 to 968 bytes, reduction of 10.74% (TextureGroup#1484)

* Shrink ASDisplayNode from 1088 to 976 bytes, reduction of 11.48%

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* Forgot to bit-field-ify placeholderEnable; new small size is 968, old size is 1072 (measured consistentlyl on iPhoneSE simulator). 10.74% reduction.

* Shrink Button Node (TextureGroup#1494)

Button: 1312 to 1288 bytes, running on iPhone SE simulator. 1.9% reduction.

Shrink the enums it stores, and place them next to each other (along with a BOOL) to reduce instance size.

* Shrink TextNode(2) (TextureGroup#1495)

Running in iPhone SE Simulator:
- ASTextNode: 1360 to 1352 bytes .6% reduction
- ASTextNode2: 1360 to 1304 bytes 4.3% redction

Shrink stored enum sizes. Group BOOLs near these smaller enums. Override -usingExperiment to return constant instead of never set, but allocated ivar.

* Shrink Pager and Scroll Node (TextureGroup#1496)

Running on iPhone SE Simulator:
ASPagerNode 1240 to 1232 bytes .7% reduction
ASScrollNode 1104 to 1096 bytes .7% reduction

- make ASScrollNode smaller by shrinking ASScrollDirection, which requires a change to ASRangeController
- shrink ASPagerNode by declaring the BOOL next to the struct

* Shrink ASImageNode by .6% and ASNetworkImageNode by 2.2% (TextureGroup#1487)

* Shrink ASImageNode by .6% and ASNetworkImageNode by 2.2%

ASImageNode goes from 1384 to 1376. ASNetworkImageNode goes from 1496 to 1464.

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* add comments as requested in garrett's review.

* access ivar directly since already locked as suggested in review.

* Remove unused declaration, missed in TextureGroup#1460 (TextureGroup#1497)

* Keep the atomics - does not affect memory work (TextureGroup#1498)

Revert "Ensure ASControlMode properties lock before accessing their ivars (TextureGroup#1476)"
This reverts commit ce1e195.

Revert "Make sure all ASDisplayNode properties have backing ivars for consistency. (TextureGroup#1475)"
This reverts commit d6061f4.
- Except the unused property `interfaceStateSuspended` is still removed (this is a memory saver).

* Shrink ASCellNode by 8 bytes (TextureGroup#1499)

Group the BOOLs together, since there are only 4 (and there are no other auto-generated ivars that are < 64 bits) this is sufficient and keeps the properties `atomic`.

* Shrink ASEditableTextNode by 16 bytes (TextureGroup#1500)

Just shuffle some BOOLs around and explicitly declare an ivar so it is grouped with the others.

* ASSignpost: Add support for the os_signpost API, fixes (TextureGroup#1501)

* ASSignpost: Add support for the os_signpost API

- Removes support for colored intervals. These weren't really useful and they aren't part of the signpost api.
- Fixes an issue with range controller interval logging.
- Adds an interval for interface orientation changes.

* Rename

* Support Xcode 9

* Commentary

* Shrink ASLayout (TextureGroup#1503)

- Shrink the enum. Save 8 bytes. There are 1000s of these in the heap after running Pinterest for 10 minutes.

* Cleanup whitespace #trivial (TextureGroup#1507)

(It's easier to deal with these as silly oneoffs IMO than to
have them conflated with real work)

* Shrink LayoutSpec classes (TextureGroup#1502)

- Resize enums to make `ASStackLayoutSpec` 40 bytes smaller. This applies to the subclasses too.

Co-authored-by: Adlai Holler <adlai@icloud.com>
Co-authored-by: Garrett Moon <garrett@pinterest.com>
Co-authored-by: dirtmelon <272485887@qq.com>
Co-authored-by: Michael Schneider <maicki@users.noreply.github.com>
Co-authored-by: Kevin <kevin@wode.com>
Co-authored-by: dirtmelon <0xffdirtmelon@gmail.com>
Co-authored-by: Jonathan Downing <jd@jonathandowning.uk>
Co-authored-by: Xavier Deloge <Idefix60@users.noreply.github.com>
Co-authored-by: Eric Scheers <smeis@users.noreply.github.com>
Co-authored-by: Huy Nguyen <allforone1511@gmail.com>
Co-authored-by: Greg Bolsinga <bolsinga@mac.com>
Co-authored-by: Jacob Farkas <farktronix@users.noreply.github.com>
Co-authored-by: ernestmama <43187788+ernestmama@users.noreply.github.com>
Co-authored-by: Andrew Yates <contact@andydev.co.uk>
Co-authored-by: Tim Norman <tim@normsoft.com>
Co-authored-by: Michael Zuccarino <mikezuccarino@gmail.com>
Co-authored-by: Dmitry Gridnev <dmitr.gridnev@gmail.com>
Co-authored-by: Max Wang <max.wang.cs@gmail.com>
Co-authored-by: Ballad <348649634@qq.com>
Co-authored-by: ricky <rickycancro@gmail.com>
Co-authored-by: Patrick Balestra <me@patrickbalestra.com>
Co-authored-by: Harry Shamansky <harry.shamansky@gmail.com>
Co-authored-by: Wu Zhong <zhongwuzw@qq.com>
Co-authored-by: Oskar Zhang <i@oskarzhang.me>
Co-authored-by: Adlai Holler <adlai@google.com>
Co-authored-by: Greg Bolsinga <gbolsinga@pinterest.com>
Co-authored-by: Huy Nguyen <huy@pinterest.com>
Co-authored-by: Andrew Monshizadeh <amonshiz+github@gmail.com>

* use iOS 13.4.1 and default Xcode 11.4.1 for CI (TextureGroup#1831)

Co-authored-by: dmaclach <dmaclach@gmail.com>
Co-authored-by: Jeffrey Macko <mackoj@users.noreply.github.com>
Co-authored-by: vovasty <vlad@aramzamzam.net>
Co-authored-by: Heberti Almeida <hebertialmeida@gmail.com>
Co-authored-by: Adlai Holler <adlai@icloud.com>
Co-authored-by: Garrett Moon <garrett@pinterest.com>
Co-authored-by: dirtmelon <272485887@qq.com>
Co-authored-by: Michael Schneider <maicki@users.noreply.github.com>
Co-authored-by: Kevin <kevin@wode.com>
Co-authored-by: dirtmelon <0xffdirtmelon@gmail.com>
Co-authored-by: Jonathan Downing <jd@jonathandowning.uk>
Co-authored-by: Xavier Deloge <Idefix60@users.noreply.github.com>
Co-authored-by: Eric Scheers <smeis@users.noreply.github.com>
Co-authored-by: Huy Nguyen <allforone1511@gmail.com>
Co-authored-by: Greg Bolsinga <bolsinga@mac.com>
Co-authored-by: Jacob Farkas <farktronix@users.noreply.github.com>
Co-authored-by: ernestmama <43187788+ernestmama@users.noreply.github.com>
Co-authored-by: Andrew Yates <contact@andydev.co.uk>
Co-authored-by: Tim Norman <tim@normsoft.com>
Co-authored-by: Michael Zuccarino <mikezuccarino@gmail.com>
Co-authored-by: Dmitry Gridnev <dmitr.gridnev@gmail.com>
Co-authored-by: Max Wang <max.wang.cs@gmail.com>
Co-authored-by: Ballad <348649634@qq.com>
Co-authored-by: Patrick Balestra <me@patrickbalestra.com>
Co-authored-by: Harry Shamansky <harry.shamansky@gmail.com>
Co-authored-by: Wu Zhong <zhongwuzw@qq.com>
Co-authored-by: Oskar Zhang <i@oskarzhang.me>
Co-authored-by: Adlai Holler <adlai@google.com>
Co-authored-by: Greg Bolsinga <gbolsinga@pinterest.com>
Co-authored-by: Huy Nguyen <huy@pinterest.com>
Co-authored-by: Andrew Monshizadeh <amonshiz+github@gmail.com>
piotrdebosz pushed a commit to getstoryteller/Texture that referenced this pull request Mar 1, 2021
…ureGroup#1011)

* Extended IGListKit support for node deselect, highlight and unhighlight

* Proposal of renaming willDisplayItemWithNode and didEndDisplayingItemWithNode to be similiar to UICollectionView

* Extended support for IGListDisplayDelegate

* Updated changelog with displaying delegates change

* Removed extra deprecation supression flag

* Reverted ASCollectionNode changes and implemented displaing delegate with indexPathForNode:

* Sending a real UICollectionViewCell to the delegate if not nil

* Added safety check for nil indexPaths

* Discard any CHANGELOG changes for fix Danger error

* Add an experimental flag to use native dispatch_apply (TextureGroup#1345)

* Add an experimental flag to use native dispatch_apply instead of our core count * 2 approach. This has shown performance wins in some profiling.

* Add in other places

* Don't return non-animated GIFs for animation (update to latest PINRemoteImage beta) (TextureGroup#940)

* Don't return non-animated GIFs for animation

* Update to latest PINRemoteImage beta

* Fix typos  (TextureGroup#1348)

* Update containers-overview.md

* Update subclassing.md

* Update node-overview.md

ASImageNode, ASNetworkImageNode and ASMultiplexImageNode are in place of UIImageView, not UIImage.

* Revert "Have node and controller share lock (TextureGroup#1227)" (TextureGroup#1347)

This reverts commit 2baa943.

* Don't compile out ASExperimentalTextNode if ASTextNode is compiled out (TextureGroup#1353)

* Lock up to yogaRoot during layout to avoid deadlocks. (TextureGroup#1356)

* Lock up to yogaRoot during layout to avoid dead lock.

1) lock to root for tree
2) lock self to change parent (& consequently root)
3) Implement ASLocking (tryLock) on ASNodeController
4) add lockPair to try-lock node & controller together
5) lock controllers if they exist in lockToRoot...

Disable some asserts due to lock to root. :(

LL# No commands remaining.

* Add macro so non-Yoga still builds :)

* wut

* Update layout-transition-api.md (TextureGroup#1357)

* Optimize ASTwoDimensionalArrayUtils (TextureGroup#1351)

* Optimize ASTwoDimensionalArrayUtils

These methods are called on the main thread during range controller updates (i.e. every frame) and so they should be as fast as possible.

* Rename

* Use vector instead of stack array to handle really big cases (e.g. photos)

* If we check for batching before content size is available we'll always fetch (TextureGroup#1355)

* Do not lock the nodeController if we are not locking to root. (TextureGroup#1360)

Doing so leaves it locked when we elsewhere explicitly unlock the node to ascend.

* Resolve root constrained size before informing delegate to resolve infinite layout loop. (TextureGroup#1359)

* Add `setNeedsLayout` to yoga tree changes. (TextureGroup#1361)

* Make ASCollectionElement Public (TextureGroup#1303)

* Update AsyncDisplayKit.h

* Update project.pbxproj

* Optimize _assertSubnodeState (TextureGroup#1352)

* Optimize _assertSubnodeState

This method is actually pretty painful in today's world. In one iPad mini trace, the first page of nodes spent 6.6ms in this call, just in time profiler.

* Clean it up, check count

* Check the right value

* _ASCollectionViewCell - The point isn't converted before to send to node, impossible to touch button into the node hierarchy (TextureGroup#1362)

* Revert node call, useless, the node has a ASDisplayView, and this view forward on the node in first.

* Use convertPoint to convert the given point in hittest & pointInside methods.
Keep the standard usage if the node didn't rasterized a view.

* Removed isNodeLoaded, finally it's useless in this case
In these methods, we are on the mainThread, we can create the view if the view is not created.

* Optimize ASCATransactionQueue (TextureGroup#1350)

* Optimize ASCATransactionQueue. This queue is very busy, and it runs on the main thread so it's important for it to be fast.

Avoid waking up the run loop for every single node.
Avoid a ton of NSPointerArray overhead that we don't need.
Avoid retain/release traffic on the singleton by using an inline function. I confirmed that in release mode, the static __strong is correctly inlined and no ARC traffic is incurred.

* Comment

* Unlock right

* Remove magic number

* Cleanup Yoga Categories (TextureGroup#1364)

* Add forwarding of UIAccessibilityAction methods (TextureGroup#1344)

* Add forwarding of UIAccessibilityAction methods

* Use OCMock for testing UIAccessibilityAction method forwarding

* Don't add extraneous truncation token during kCTLineTruncationMiddle. (TextureGroup#1297)

* Don't add extraneous truncation token during kCTLineTruncationMiddle

* Expand these comments a little.

* Update the FAQ to throw less shade. (TextureGroup#1379)

* Update the FAQ to throw less shade.

Both of these technologies have their place, no point in being assholes.

* Update faq.md

* [Updated Snapshots] Don't add extraneous truncation token during kCTLineTruncationMiddle (TextureGroup#1375)

* Don't add extraneous truncation token during kCTLineTruncationMiddle

* Expand these comments a little.

* Update snapshot tests with beautiful correct behavior

* Launches switching ASNetworkImageNode callbacks to global queue. (TextureGroup#1369)

* Launches switching ASNetworkImageNode callbacks to global queue.

* Good catch configuration tests!

* Make ASTextNode2 more forgiving when searching for links (TextureGroup#1374)

* Make ASTextNode2 more forgiving when searching for links by searching a 44x44 square around the touch

* Trailing whitespace

* Safely handle end-of-line

* Experiment with different strategies for image downloader priority (TextureGroup#1349)

Right now when an image node enters preload state, we kick off an image request with the default priority. Then when it enters display state, we change the priority to "imminent" which is mapped to the default priority as well. This means that requests from preload and display nodes have the same priority and are put to the same pool. The right behavior would be that preload requests should have a lower priority from the beginning.

Another problem is that, due to the execution order of -didEnter(Preload|Display|Visible)State calls, a node may kick off a low priority request when it enters preload state even though it knows that it's also visible. By the time -didEnterVisibleState is called, the low priority request may have already been consumed and the download/data task won't pick up the new higher priority, or some work needs to be done to move it to another queue. A better behavior would be to always use the current interface state to determine the priority. This means that visible nodes will kick off high priority requests as soon as -didEnterPreloadState is called.

The last (and smaller) issue is that a node marks its request as preload/low priority as soon as it exits visible state. I'd argue that this is too agressive. It may be reasonble for nodes in the trailing direction. Even so, we already handle this case by (almost always) have smaller trailing buffers. So this diff makes sure that nodes that exited visible state will have imminent/default priority if they remain in the display range.

All of these new behaviors are wrapped in an experiment and will be tested carefully before being rolled out.

* Add imports

* Fix build failure

* Encapsulate common logics into methods

* Address comments

* Whoops, someone forgot an else! (TextureGroup#1385)

Luckily it seems this didn't cause huge memory bloat because there's
a check below that keeps the display flag from being set in low memory
conditions when the node is off the screen.

* Catch invalid sizes during yoga layout (TextureGroup#1376)

* Correct View vs. Layer here (tho it doesn't make any difference) (TextureGroup#1378)

Older FBSnapshot versions, however, don't use VerifyViewOrLayer

* Expose initial constrained size before layout in case anyone is interested later during the layout on the same thread. (TextureGroup#1377)

Optionally, clients are expected to clean it up after usage to avoid accessing outdated data.

* Assert for context creation failure during displayBlock. (TextureGroup#1373)

Nothing good can possibly happen if we continue without one.

* Fix an issue where state change notifications can be sent mulitple times. (TextureGroup#1372)

Before the change: both - (void)setShouldInvertStrongReference:(BOOL)shouldInvertStrongReference and - (void)setNode:(ASDisplayNode *)node will call through [self setupReferencesWithNode:node]; which call the [node addInterfaceStateDelegate:self];

* Add Yoga support to ASButtonNode (TextureGroup#1381)

* Add Yoga support to ASButtonNode

* Drop unowned ASLayoutElementStyle parameter

* Fix access of Yoga properties

* Move ASButtonNode Yoga logic to Category

* Update header

* Fix CTLineRef leaks (TextureGroup#1386)

Found by Clang Static Analyzer:

~/Texture/Source/ASTextNode2.mm:663:39: warning: Potential leak of an object stored into 'truncationTokenLine'
      CTLineRef truncationTokenLine = CTLineCreateWithAttributedString((CFAttributedStringRef)_truncationAttributedText);
                                      ^
~/Texture/Source/ASTextNode2.mm:666:49: warning: Potential leak of an object stored into 'additionalTruncationTokenLine'
      CTLineRef additionalTruncationTokenLine = CTLineCreateWithAttributedString((CFAttributedStringRef)_additionalTruncationMessage);
                                                ^
2 warnings generated.

* Correct attributes lookup for supplementary elements. (TextureGroup#1318)

* Need some more locks for working with calculated yoga layouts (TextureGroup#1388)

* Adds support for using UIGraphicsImageRenderer in ASTextNode. (TextureGroup#1384)

* Adds support for using UIGraphicsImageRenderer in ASTextNode.

In many cases this reduces the backing store of text nodes by 1/2.

* Guard for UIGraphicsRenderer availability.

* Comma

* Add UIDataSourceModelAssociation to ASTableView and ASCollectionView (TextureGroup#1354)

* Add UIDataSourceModelAssociation protocol conformance to ASTableView and ASCollectionView.

* Implementing review feedback from @Adlai-Holler

* Rename ASDN C++ namespace to AS (TextureGroup#1366)

* Rename ASDN C++ namespace to "AS." Referring to the framework as ASDisplayNode is pretty out-dated and verbose. See CoreAnimation which usees CA for their internal namespace.

More using

* More cases

* Clean up a clang analyzer cast error (TextureGroup#1387)

~/Texture/Source/Private/ASMutableElementMap.mm:32:24: warning: Conversion from value of type 'NSMutableArray<NSMutableArray *> *' to incompatible type 'ASMutableCollectionElementTwoDimensionalArray *'
    _sectionsOfItems = (id)ASTwoDimensionalArrayDeepMutableCopy(items);
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

* Update for 9.4.1 CI (TextureGroup#1392)

* Remove experimental features (exp_skip_a11y_wait && exp_new_default_cell_layout_mode) (TextureGroup#1383)

* Remove experimental features

* prevent blocking main thread

* remove small content all together as none is the default

* Update ASExperimentalFeatures.h

* Make experiment checks faster (TextureGroup#1393)

* Make experiment checks use dispatch_once when not debugging, clean up singleton

* One more

* Pull out the variable

* Make shared CA transaction queue variable extern so it's actually shared (TextureGroup#1397)

* Fix header typo (TextureGroup#1402)

* Context is a pretty general name that will cause conflicts with subclasses (TextureGroup#1399)

* Suppress documentation warnings when using external libraries (TextureGroup#1401)

Fixes 1400

* Add layer-action support to nodes (TextureGroup#1396)

* Add layer-action support to nodes, unify hierarchy notifications on it

* Better pending state

* Fix bool

* Skip extra copy

* Never run default actions

* Continue the search

* Avoid an unnecessary lock & unlock pair in ASMainSerialQueue (TextureGroup#1409)

* Add clang-format for a common source code format (TextureGroup#1365)

* Add clang-format

* Update format to be as close as our current style

* Fix GIF Caching (TextureGroup#1405)

* Add support for reverse direction to yoga layouts (TextureGroup#1413)

* Add support for reverse direction to yoga layouts

* #ifdef YOGA yoga-specific additions

* oops

* Only set ASLayoutElementStyle delegate if Yoga is enabled (TextureGroup#1417)

* Fix bug in ASRangeController that causes some cell nodes of a collection view which is about to becomes invisible to load their backing view/layer and render (TextureGroup#1418)

* Fix a bug with Yoga nodes whose position change and don't update. (TextureGroup#1408)

* Follow up on the ASRangeController fix in TextureGroup#1418 (TextureGroup#1419)

The changes in TextureGroup#1418 is a bit too aggressive when it comes to nodes that are in display range. It forces those nodes to not preload.

Also update the changes to avoid diluting the experiment data by triggering too broadly (i.e avoid triggering when the old and new implementations yield the same result leading to no behavior change).

* Dev docs for threading in Texture (TextureGroup#1319)

* Getting started on adding threading by example

* writing writing writing

* more info

* More threading

* More more more

* Threading

* self lock

* Some language fixes

* Update docs/_docs/development/threading.md

Co-Authored-By: mikezucc <mikezuccarino@gmail.com>

* fix image references

* Removed locked jekyll version (TextureGroup#1322)

* showcase.md updated (TextureGroup#1421)

* Experiment with disabling ASViewController background dealloc (TextureGroup#1420)

* [Experiment] Dont forget about these collection view background deallocs (TextureGroup#1424)

* Dont forget about these collection view background deallocs

* Also Table view for completeness

* Fix retain cycle with transaction operations (TextureGroup#1429)

Add unit tests that help find cycles. `-testWeakWithSingleOperation` fails without the code fix applied.

* Replace +load initializers with __attribute__((constructor)) functions (TextureGroup#1425)

* Replace +load initializers with __attribute__((constructor)) functions

* Updating the documentation for textureDidInitialize, per @nguyenhuy

* Fix dealloc on bg (TextureGroup#1410)

* fix SIMULATE_WEB_RESPONSE not imported TextureGroup#449

* Fix to make rangeMode update in right time

* remove uncessary assert

* Fix collection cell editing bug for iOS 9 & 10

* Revert "Fix collection cell editing bug for iOS 9 & 10"

This reverts commit 06e18a1.

* Fix dealloc long gesture in background

* Add support for clipping only specific corners, add unit tests (TextureGroup#1415)

* Add support for clipping only specific corners, add unit tests

* Remove some cleanup to make the diff smaller

* Fix

* [ASImageNode]fix incorrect backing size calculation (TextureGroup#1189)

* fix backing size for image node which content mode is scaleAspectFit

* chore: update comments and naming

* add change log

* Update CHANGELOG.md

* Update CHANGELOG.md

Co-Authored-By: junjielu <348649634@qq.com>

* add unit test for backing size calculation

* correct license

* Have image nodes draw into opaque contexts automatically if possible (TextureGroup#1432)

* Have image nodes draw into opaque contexts if the image is opaque and it fills the context

* Call backingSize once

* Fix typo in batch-fetching-api.md (TextureGroup#1437)

* [ASDisplayNode] Stop infinite layout in _u_measureNodeWithBoundsIfNecessary (TextureGroup#1434)

We came across an infinite layout loop in `_u_measureNodeWithBoundsIfNecessary`. After requesting a layout from above, the sizes between pending and caluclated layout still do not match. We continue to prefer to use the pending layout and ask for another layout loop from above. We can’t seem to break out of this loop. The solution (thanks to Huy for the guidance) was to nil out the pending layout we get from requesting the layout from above.

I was only able to reproduce this when working with a node in a `UINavigationBarItem’s` `titleView`. I think that UIKit must be doing something sneaky with setting the frame on the view. While I was not able to create a unit test to catch this issue (I tried for a long time, and can post what I’ve come up with to see if anyone has any suggestions), I was able to create a pretty simple example project that shows the behavior:
https://github.com/rcancro/TextureLayoutLoopExample

* Add a verbose log for locking operations. Has no effect in production (TextureGroup#1436)

* Add a verbose log for locking operations. Has no effect in production

* Need check

* Wrap transaction operation retain cycle fix in an experiment (TextureGroup#1438)

* Wrap transaction operation retain cycle fix in an experiment

This is a follow on to TextureGroup#1429.

* fix typo in experiment name. fix copyright in tests file.

* Fix scroll node in yoga (TextureGroup#1435)

* fix SIMULATE_WEB_RESPONSE not imported TextureGroup#449

* Fix to make rangeMode update in right time

* remove uncessary assert

* Fix collection cell editing bug for iOS 9 & 10

* Revert "Fix collection cell editing bug for iOS 9 & 10"

This reverts commit 06e18a1.

* Fix child not fit to full scroll node's bounds when flex_grow = 1.0 is used on child

* Fix the stub for layerActionForKey: to let CA continue the search (TextureGroup#1441)

* Fix the stub for layerActionForKey: to let CA continue the search

* Kick CI

* Revert "Have image nodes draw into opaque contexts automatically if possible (TextureGroup#1432)" (TextureGroup#1443)

This reverts commit 28522ce.

* Use instance lock for ASPrimitiveTraitCollection (TextureGroup#1442)

* Use instance lock for ASPrimitiveTraitCollection

* Remove the atomic

* Simplify ASTraitCollection propagation in ASViewController (TextureGroup#1447)

* Use AS::Mutex in ASCollectionElement (TextureGroup#1445)

* [ASTextNode] Maintain isAccessibilityElement setting on text nodes when updating text (TextureGroup#1326)

* Add didEnterHierarchy/didExitHierarchy to ASNodeController. (TextureGroup#1444)

* Fix wrongly formatted RELEASE link (TextureGroup#1453)

* Only create activities during debug (TextureGroup#1456)

* [TextureGroup#1451] Add support for UIAccessibilityCustomAction (TextureGroup#1452)

This PR adds support for UIAccessibilityCustomAction propagation through ASPendingState so that it can be picked up by VoiceOver.

* Shut down graphics contexts experiment (TextureGroup#1458)

* Shut down graphics contexts experiment

* Remove dead import

* Remove gone class

* Remove lock of ASTextNodeRendererKey (TextureGroup#1454)

* Remove lock of ASTextNodeRendererKey

* Remove class check for isEqual

* Add const specifier to function parameter

* Fixes typo

* Fixes typo

* Disable ASAssertLocked and ASAssertUnlocked (TextureGroup#1412)

* Try to remove global lock when initialising TextKit components (TextureGroup#1455)

* Try to remove global lock when initialising TextKit components

* Adding experiment flag to dis/enable lock of textkit component

* Adding tests

* code clean

fix typo

Make remove lock optional

Keep locks

code clean

* Make ASCollectionNode's pan gesture customizable (TextureGroup#1457)

* changes done

* complete set of uigesturedeleagte methods

* Remove iOS 8 support from logging code. (TextureGroup#1462)

* Drop support for Xcode 8 and fix some compiler warnings (TextureGroup#1463)

* Remove ASEventLog (TextureGroup#1460)

* Remove ASEventLog. We'll focus on ASLog for the future, possibly making it triggerable on a per-node basis

* See ya!

* Hello semicolon

* Remove refs to gone tree methods

* Fix

* Remove irrelevant change, kick CI

* Clean up

* Cover the other background dealloc surfaces (TextureGroup#1464)

* Passthrough pagingEnabled for ASCollectionNode / ASTableNode (TextureGroup#1466)

* Passthrough pagingEnabled for ASCollectionNode and ASTableNode

* Add tvOS handling

* Fix open context bug introduced in TextureGroup#1458 (TextureGroup#1468)

* Make sure all ASDisplayNode properties have backing ivars for consistency. (TextureGroup#1475)

* Make sure all ASDisplayNodes have backing ivars for consistency.

Found this by enabling #pragma clang diagnostic error "-Wobjc-missing-property-synthesis" for ASDisplayNode. One property is unused, saving 8 bytes of heap space per instance on 64-bit builds. Implement setter/getters for these properties, and add appropriate locking. add the warning as error to the build for this file.

* Ensure ASControlMode properties lock before accessing their ivars (TextureGroup#1476)

Enable `#pragma clang diagnostic error "-Wobjc-missing-property-synthesis"` for this file.

* Add a new "global drawing" experiment to use UIGraphicsRenderer (TextureGroup#1469)

* Add a new "global drawing" experiment to use UIGraphicsRenderer everywhere, when available

* Fix logic

* Use preferredFormat

* Cut version 2.8.1 (TextureGroup#1491)

* Clean up documentation issues around periods (TextureGroup#1490)

There were so unnecessary `'` around periods for some reason. Just deleting those because they are distracting.

* Minor update in change log #changelog (TextureGroup#1492)

* Ship ASExperimentalFixRangeController (TextureGroup#1486)

* Shrink _ASCollectionPendingState from 144 to 128 bytes, a 12.5% reduction (TextureGroup#1485)

* Shrink _ASCollectionPendingState from 144 to 128 bytes, a 12.5% reduction

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* address review comments. move enums out. add comment. rename struct to _flags

* fix a missing rename

* Shrink _ASPendingState from 824 to 808 bytes, reduction of ~2% (TextureGroup#1483)

* Shrink _ASPendingState from 824 to 808 bytes, reduction of ~2%

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Shrink ASPendingState BOOLs. Use unsigned int for these bitfields for clarity. Separate from `_flags` as that struct is compared to `0` for testing. The `_boolFlags` struct is just storing other `BOOL`s.

* rename struct fields as suggested in garret's review.

* Shrink ASDisplayNode from 1072 to 968 bytes, reduction of 10.74% (TextureGroup#1484)

* Shrink ASDisplayNode from 1088 to 976 bytes, reduction of 11.48%

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* Forgot to bit-field-ify placeholderEnable; new small size is 968, old size is 1072 (measured consistentlyl on iPhoneSE simulator). 10.74% reduction.

* Shrink Button Node (TextureGroup#1494)

Button: 1312 to 1288 bytes, running on iPhone SE simulator. 1.9% reduction.

Shrink the enums it stores, and place them next to each other (along with a BOOL) to reduce instance size.

* Shrink TextNode(2) (TextureGroup#1495)

Running in iPhone SE Simulator:
- ASTextNode: 1360 to 1352 bytes .6% reduction
- ASTextNode2: 1360 to 1304 bytes 4.3% redction

Shrink stored enum sizes. Group BOOLs near these smaller enums. Override -usingExperiment to return constant instead of never set, but allocated ivar.

* Shrink Pager and Scroll Node (TextureGroup#1496)

Running on iPhone SE Simulator:
ASPagerNode 1240 to 1232 bytes .7% reduction
ASScrollNode 1104 to 1096 bytes .7% reduction

- make ASScrollNode smaller by shrinking ASScrollDirection, which requires a change to ASRangeController
- shrink ASPagerNode by declaring the BOOL next to the struct

* Shrink ASImageNode by .6% and ASNetworkImageNode by 2.2% (TextureGroup#1487)

* Shrink ASImageNode by .6% and ASNetworkImageNode by 2.2%

ASImageNode goes from 1384 to 1376. ASNetworkImageNode goes from 1496 to 1464.

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* add comments as requested in garrett's review.

* access ivar directly since already locked as suggested in review.

* Remove unused declaration, missed in TextureGroup#1460 (TextureGroup#1497)

* Keep the atomics - does not affect memory work (TextureGroup#1498)

Revert "Ensure ASControlMode properties lock before accessing their ivars (TextureGroup#1476)"
This reverts commit ce1e195.

Revert "Make sure all ASDisplayNode properties have backing ivars for consistency. (TextureGroup#1475)"
This reverts commit d6061f4.
- Except the unused property `interfaceStateSuspended` is still removed (this is a memory saver).

* Shrink ASCellNode by 8 bytes (TextureGroup#1499)

Group the BOOLs together, since there are only 4 (and there are no other auto-generated ivars that are < 64 bits) this is sufficient and keeps the properties `atomic`.

* Shrink ASEditableTextNode by 16 bytes (TextureGroup#1500)

Just shuffle some BOOLs around and explicitly declare an ivar so it is grouped with the others.

* ASSignpost: Add support for the os_signpost API, fixes (TextureGroup#1501)

* ASSignpost: Add support for the os_signpost API

- Removes support for colored intervals. These weren't really useful and they aren't part of the signpost api.
- Fixes an issue with range controller interval logging.
- Adds an interval for interface orientation changes.

* Rename

* Support Xcode 9

* Commentary

* Shrink ASLayout (TextureGroup#1503)

- Shrink the enum. Save 8 bytes. There are 1000s of these in the heap after running Pinterest for 10 minutes.

* Cleanup whitespace #trivial (TextureGroup#1507)

(It's easier to deal with these as silly oneoffs IMO than to
have them conflated with real work)

* Shrink LayoutSpec classes (TextureGroup#1502)

- Resize enums to make `ASStackLayoutSpec` 40 bytes smaller. This applies to the subclasses too.

Co-authored-by: Adlai Holler <adlai@icloud.com>
Co-authored-by: Garrett Moon <garrett@pinterest.com>
Co-authored-by: dirtmelon <272485887@qq.com>
Co-authored-by: Michael Schneider <maicki@users.noreply.github.com>
Co-authored-by: Kevin <kevin@wode.com>
Co-authored-by: dirtmelon <0xffdirtmelon@gmail.com>
Co-authored-by: Jonathan Downing <jd@jonathandowning.uk>
Co-authored-by: Xavier Deloge <Idefix60@users.noreply.github.com>
Co-authored-by: Eric Scheers <smeis@users.noreply.github.com>
Co-authored-by: Huy Nguyen <allforone1511@gmail.com>
Co-authored-by: Greg Bolsinga <bolsinga@mac.com>
Co-authored-by: Jacob Farkas <farktronix@users.noreply.github.com>
Co-authored-by: ernestmama <43187788+ernestmama@users.noreply.github.com>
Co-authored-by: Andrew Yates <contact@andydev.co.uk>
Co-authored-by: Tim Norman <tim@normsoft.com>
Co-authored-by: Michael Zuccarino <mikezuccarino@gmail.com>
Co-authored-by: Dmitry Gridnev <dmitr.gridnev@gmail.com>
Co-authored-by: Max Wang <max.wang.cs@gmail.com>
Co-authored-by: Ballad <348649634@qq.com>
Co-authored-by: ricky <rickycancro@gmail.com>
Co-authored-by: Patrick Balestra <me@patrickbalestra.com>
Co-authored-by: Harry Shamansky <harry.shamansky@gmail.com>
Co-authored-by: Wu Zhong <zhongwuzw@qq.com>
Co-authored-by: Oskar Zhang <i@oskarzhang.me>
Co-authored-by: Adlai Holler <adlai@google.com>
Co-authored-by: Greg Bolsinga <gbolsinga@pinterest.com>
Co-authored-by: Huy Nguyen <huy@pinterest.com>
Co-authored-by: Andrew Monshizadeh <amonshiz+github@gmail.com>
piotrdebosz pushed a commit to getstoryteller/Texture that referenced this pull request Mar 1, 2021
…t are subviews of UIScrollView (TextureGroup#1821)

* [Accessibility] Do not exclude elements outside the window’s rect that are subviews of UIScrollView

Previously I put up a diff to exclude accessibility elements that were outside of the current window rect. However, I didn’t take the case of scrollViews (including table and collection views) into consideration. By ignoring cells outside of the window, the scroll view would not advance to additional elements in the scrollView but off screen.

I did some side-by-side testing with UIKit and it appears that no elements are excluded that are in a scroll view, even if the element’s rect is outside of the scroll view’s visible rect. In order to match this behavior, I added a recursive superview check to see if an element that is off screen has a scrollView as a parent. If so, we do not exclude it:

```    if (!CGRectIntersectsRect(view.window.frame, nodeInWindowCoords) && !recusivelyCheckSuperviewsForScrollView(view)) {
        continue;
    }```

* fix some spacings

* force a build

* build bump again

* Removes unnecessary `-tearDown` code. (TextureGroup#1822)

* Update Texture.podspec (TextureGroup#1773)

3.0.0

* support cancelation in ASGraphicsCreateImage (TextureGroup#1814)

* support cancelation in ASGraphicsCreateImage

* updated comment

* [IGListKit] Extended IGListKit support for displaying delegates (TextureGroup#1011)

* Extended IGListKit support for node deselect, highlight and unhighlight

* Proposal of renaming willDisplayItemWithNode and didEndDisplayingItemWithNode to be similiar to UICollectionView

* Extended support for IGListDisplayDelegate

* Updated changelog with displaying delegates change

* Removed extra deprecation supression flag

* Reverted ASCollectionNode changes and implemented displaing delegate with indexPathForNode:

* Sending a real UICollectionViewCell to the delegate if not nil

* Added safety check for nil indexPaths

* Discard any CHANGELOG changes for fix Danger error

* Add an experimental flag to use native dispatch_apply (TextureGroup#1345)

* Add an experimental flag to use native dispatch_apply instead of our core count * 2 approach. This has shown performance wins in some profiling.

* Add in other places

* Don't return non-animated GIFs for animation (update to latest PINRemoteImage beta) (TextureGroup#940)

* Don't return non-animated GIFs for animation

* Update to latest PINRemoteImage beta

* Fix typos  (TextureGroup#1348)

* Update containers-overview.md

* Update subclassing.md

* Update node-overview.md

ASImageNode, ASNetworkImageNode and ASMultiplexImageNode are in place of UIImageView, not UIImage.

* Revert "Have node and controller share lock (TextureGroup#1227)" (TextureGroup#1347)

This reverts commit 2baa943.

* Don't compile out ASExperimentalTextNode if ASTextNode is compiled out (TextureGroup#1353)

* Lock up to yogaRoot during layout to avoid deadlocks. (TextureGroup#1356)

* Lock up to yogaRoot during layout to avoid dead lock.

1) lock to root for tree
2) lock self to change parent (& consequently root)
3) Implement ASLocking (tryLock) on ASNodeController
4) add lockPair to try-lock node & controller together
5) lock controllers if they exist in lockToRoot...

Disable some asserts due to lock to root. :(

LL# No commands remaining.

* Add macro so non-Yoga still builds :)

* wut

* Update layout-transition-api.md (TextureGroup#1357)

* Optimize ASTwoDimensionalArrayUtils (TextureGroup#1351)

* Optimize ASTwoDimensionalArrayUtils

These methods are called on the main thread during range controller updates (i.e. every frame) and so they should be as fast as possible.

* Rename

* Use vector instead of stack array to handle really big cases (e.g. photos)

* If we check for batching before content size is available we'll always fetch (TextureGroup#1355)

* Do not lock the nodeController if we are not locking to root. (TextureGroup#1360)

Doing so leaves it locked when we elsewhere explicitly unlock the node to ascend.

* Resolve root constrained size before informing delegate to resolve infinite layout loop. (TextureGroup#1359)

* Add `setNeedsLayout` to yoga tree changes. (TextureGroup#1361)

* Make ASCollectionElement Public (TextureGroup#1303)

* Update AsyncDisplayKit.h

* Update project.pbxproj

* Optimize _assertSubnodeState (TextureGroup#1352)

* Optimize _assertSubnodeState

This method is actually pretty painful in today's world. In one iPad mini trace, the first page of nodes spent 6.6ms in this call, just in time profiler.

* Clean it up, check count

* Check the right value

* _ASCollectionViewCell - The point isn't converted before to send to node, impossible to touch button into the node hierarchy (TextureGroup#1362)

* Revert node call, useless, the node has a ASDisplayView, and this view forward on the node in first.

* Use convertPoint to convert the given point in hittest & pointInside methods.
Keep the standard usage if the node didn't rasterized a view.

* Removed isNodeLoaded, finally it's useless in this case
In these methods, we are on the mainThread, we can create the view if the view is not created.

* Optimize ASCATransactionQueue (TextureGroup#1350)

* Optimize ASCATransactionQueue. This queue is very busy, and it runs on the main thread so it's important for it to be fast.

Avoid waking up the run loop for every single node.
Avoid a ton of NSPointerArray overhead that we don't need.
Avoid retain/release traffic on the singleton by using an inline function. I confirmed that in release mode, the static __strong is correctly inlined and no ARC traffic is incurred.

* Comment

* Unlock right

* Remove magic number

* Cleanup Yoga Categories (TextureGroup#1364)

* Add forwarding of UIAccessibilityAction methods (TextureGroup#1344)

* Add forwarding of UIAccessibilityAction methods

* Use OCMock for testing UIAccessibilityAction method forwarding

* Don't add extraneous truncation token during kCTLineTruncationMiddle. (TextureGroup#1297)

* Don't add extraneous truncation token during kCTLineTruncationMiddle

* Expand these comments a little.

* Update the FAQ to throw less shade. (TextureGroup#1379)

* Update the FAQ to throw less shade.

Both of these technologies have their place, no point in being assholes.

* Update faq.md

* [Updated Snapshots] Don't add extraneous truncation token during kCTLineTruncationMiddle (TextureGroup#1375)

* Don't add extraneous truncation token during kCTLineTruncationMiddle

* Expand these comments a little.

* Update snapshot tests with beautiful correct behavior

* Launches switching ASNetworkImageNode callbacks to global queue. (TextureGroup#1369)

* Launches switching ASNetworkImageNode callbacks to global queue.

* Good catch configuration tests!

* Make ASTextNode2 more forgiving when searching for links (TextureGroup#1374)

* Make ASTextNode2 more forgiving when searching for links by searching a 44x44 square around the touch

* Trailing whitespace

* Safely handle end-of-line

* Experiment with different strategies for image downloader priority (TextureGroup#1349)

Right now when an image node enters preload state, we kick off an image request with the default priority. Then when it enters display state, we change the priority to "imminent" which is mapped to the default priority as well. This means that requests from preload and display nodes have the same priority and are put to the same pool. The right behavior would be that preload requests should have a lower priority from the beginning.

Another problem is that, due to the execution order of -didEnter(Preload|Display|Visible)State calls, a node may kick off a low priority request when it enters preload state even though it knows that it's also visible. By the time -didEnterVisibleState is called, the low priority request may have already been consumed and the download/data task won't pick up the new higher priority, or some work needs to be done to move it to another queue. A better behavior would be to always use the current interface state to determine the priority. This means that visible nodes will kick off high priority requests as soon as -didEnterPreloadState is called.

The last (and smaller) issue is that a node marks its request as preload/low priority as soon as it exits visible state. I'd argue that this is too agressive. It may be reasonble for nodes in the trailing direction. Even so, we already handle this case by (almost always) have smaller trailing buffers. So this diff makes sure that nodes that exited visible state will have imminent/default priority if they remain in the display range.

All of these new behaviors are wrapped in an experiment and will be tested carefully before being rolled out.

* Add imports

* Fix build failure

* Encapsulate common logics into methods

* Address comments

* Whoops, someone forgot an else! (TextureGroup#1385)

Luckily it seems this didn't cause huge memory bloat because there's
a check below that keeps the display flag from being set in low memory
conditions when the node is off the screen.

* Catch invalid sizes during yoga layout (TextureGroup#1376)

* Correct View vs. Layer here (tho it doesn't make any difference) (TextureGroup#1378)

Older FBSnapshot versions, however, don't use VerifyViewOrLayer

* Expose initial constrained size before layout in case anyone is interested later during the layout on the same thread. (TextureGroup#1377)

Optionally, clients are expected to clean it up after usage to avoid accessing outdated data.

* Assert for context creation failure during displayBlock. (TextureGroup#1373)

Nothing good can possibly happen if we continue without one.

* Fix an issue where state change notifications can be sent mulitple times. (TextureGroup#1372)

Before the change: both - (void)setShouldInvertStrongReference:(BOOL)shouldInvertStrongReference and - (void)setNode:(ASDisplayNode *)node will call through [self setupReferencesWithNode:node]; which call the [node addInterfaceStateDelegate:self];

* Add Yoga support to ASButtonNode (TextureGroup#1381)

* Add Yoga support to ASButtonNode

* Drop unowned ASLayoutElementStyle parameter

* Fix access of Yoga properties

* Move ASButtonNode Yoga logic to Category

* Update header

* Fix CTLineRef leaks (TextureGroup#1386)

Found by Clang Static Analyzer:

~/Texture/Source/ASTextNode2.mm:663:39: warning: Potential leak of an object stored into 'truncationTokenLine'
      CTLineRef truncationTokenLine = CTLineCreateWithAttributedString((CFAttributedStringRef)_truncationAttributedText);
                                      ^
~/Texture/Source/ASTextNode2.mm:666:49: warning: Potential leak of an object stored into 'additionalTruncationTokenLine'
      CTLineRef additionalTruncationTokenLine = CTLineCreateWithAttributedString((CFAttributedStringRef)_additionalTruncationMessage);
                                                ^
2 warnings generated.

* Correct attributes lookup for supplementary elements. (TextureGroup#1318)

* Need some more locks for working with calculated yoga layouts (TextureGroup#1388)

* Adds support for using UIGraphicsImageRenderer in ASTextNode. (TextureGroup#1384)

* Adds support for using UIGraphicsImageRenderer in ASTextNode.

In many cases this reduces the backing store of text nodes by 1/2.

* Guard for UIGraphicsRenderer availability.

* Comma

* Add UIDataSourceModelAssociation to ASTableView and ASCollectionView (TextureGroup#1354)

* Add UIDataSourceModelAssociation protocol conformance to ASTableView and ASCollectionView.

* Implementing review feedback from @Adlai-Holler

* Rename ASDN C++ namespace to AS (TextureGroup#1366)

* Rename ASDN C++ namespace to "AS." Referring to the framework as ASDisplayNode is pretty out-dated and verbose. See CoreAnimation which usees CA for their internal namespace.

More using

* More cases

* Clean up a clang analyzer cast error (TextureGroup#1387)

~/Texture/Source/Private/ASMutableElementMap.mm:32:24: warning: Conversion from value of type 'NSMutableArray<NSMutableArray *> *' to incompatible type 'ASMutableCollectionElementTwoDimensionalArray *'
    _sectionsOfItems = (id)ASTwoDimensionalArrayDeepMutableCopy(items);
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

* Update for 9.4.1 CI (TextureGroup#1392)

* Remove experimental features (exp_skip_a11y_wait && exp_new_default_cell_layout_mode) (TextureGroup#1383)

* Remove experimental features

* prevent blocking main thread

* remove small content all together as none is the default

* Update ASExperimentalFeatures.h

* Make experiment checks faster (TextureGroup#1393)

* Make experiment checks use dispatch_once when not debugging, clean up singleton

* One more

* Pull out the variable

* Make shared CA transaction queue variable extern so it's actually shared (TextureGroup#1397)

* Fix header typo (TextureGroup#1402)

* Context is a pretty general name that will cause conflicts with subclasses (TextureGroup#1399)

* Suppress documentation warnings when using external libraries (TextureGroup#1401)

Fixes 1400

* Add layer-action support to nodes (TextureGroup#1396)

* Add layer-action support to nodes, unify hierarchy notifications on it

* Better pending state

* Fix bool

* Skip extra copy

* Never run default actions

* Continue the search

* Avoid an unnecessary lock & unlock pair in ASMainSerialQueue (TextureGroup#1409)

* Add clang-format for a common source code format (TextureGroup#1365)

* Add clang-format

* Update format to be as close as our current style

* Fix GIF Caching (TextureGroup#1405)

* Add support for reverse direction to yoga layouts (TextureGroup#1413)

* Add support for reverse direction to yoga layouts

* #ifdef YOGA yoga-specific additions

* oops

* Only set ASLayoutElementStyle delegate if Yoga is enabled (TextureGroup#1417)

* Fix bug in ASRangeController that causes some cell nodes of a collection view which is about to becomes invisible to load their backing view/layer and render (TextureGroup#1418)

* Fix a bug with Yoga nodes whose position change and don't update. (TextureGroup#1408)

* Follow up on the ASRangeController fix in TextureGroup#1418 (TextureGroup#1419)

The changes in TextureGroup#1418 is a bit too aggressive when it comes to nodes that are in display range. It forces those nodes to not preload.

Also update the changes to avoid diluting the experiment data by triggering too broadly (i.e avoid triggering when the old and new implementations yield the same result leading to no behavior change).

* Dev docs for threading in Texture (TextureGroup#1319)

* Getting started on adding threading by example

* writing writing writing

* more info

* More threading

* More more more

* Threading

* self lock

* Some language fixes

* Update docs/_docs/development/threading.md

Co-Authored-By: mikezucc <mikezuccarino@gmail.com>

* fix image references

* Removed locked jekyll version (TextureGroup#1322)

* showcase.md updated (TextureGroup#1421)

* Experiment with disabling ASViewController background dealloc (TextureGroup#1420)

* [Experiment] Dont forget about these collection view background deallocs (TextureGroup#1424)

* Dont forget about these collection view background deallocs

* Also Table view for completeness

* Fix retain cycle with transaction operations (TextureGroup#1429)

Add unit tests that help find cycles. `-testWeakWithSingleOperation` fails without the code fix applied.

* Replace +load initializers with __attribute__((constructor)) functions (TextureGroup#1425)

* Replace +load initializers with __attribute__((constructor)) functions

* Updating the documentation for textureDidInitialize, per @nguyenhuy

* Fix dealloc on bg (TextureGroup#1410)

* fix SIMULATE_WEB_RESPONSE not imported TextureGroup#449

* Fix to make rangeMode update in right time

* remove uncessary assert

* Fix collection cell editing bug for iOS 9 & 10

* Revert "Fix collection cell editing bug for iOS 9 & 10"

This reverts commit 06e18a1.

* Fix dealloc long gesture in background

* Add support for clipping only specific corners, add unit tests (TextureGroup#1415)

* Add support for clipping only specific corners, add unit tests

* Remove some cleanup to make the diff smaller

* Fix

* [ASImageNode]fix incorrect backing size calculation (TextureGroup#1189)

* fix backing size for image node which content mode is scaleAspectFit

* chore: update comments and naming

* add change log

* Update CHANGELOG.md

* Update CHANGELOG.md

Co-Authored-By: junjielu <348649634@qq.com>

* add unit test for backing size calculation

* correct license

* Have image nodes draw into opaque contexts automatically if possible (TextureGroup#1432)

* Have image nodes draw into opaque contexts if the image is opaque and it fills the context

* Call backingSize once

* Fix typo in batch-fetching-api.md (TextureGroup#1437)

* [ASDisplayNode] Stop infinite layout in _u_measureNodeWithBoundsIfNecessary (TextureGroup#1434)

We came across an infinite layout loop in `_u_measureNodeWithBoundsIfNecessary`. After requesting a layout from above, the sizes between pending and caluclated layout still do not match. We continue to prefer to use the pending layout and ask for another layout loop from above. We can’t seem to break out of this loop. The solution (thanks to Huy for the guidance) was to nil out the pending layout we get from requesting the layout from above.

I was only able to reproduce this when working with a node in a `UINavigationBarItem’s` `titleView`. I think that UIKit must be doing something sneaky with setting the frame on the view. While I was not able to create a unit test to catch this issue (I tried for a long time, and can post what I’ve come up with to see if anyone has any suggestions), I was able to create a pretty simple example project that shows the behavior:
https://github.com/rcancro/TextureLayoutLoopExample

* Add a verbose log for locking operations. Has no effect in production (TextureGroup#1436)

* Add a verbose log for locking operations. Has no effect in production

* Need check

* Wrap transaction operation retain cycle fix in an experiment (TextureGroup#1438)

* Wrap transaction operation retain cycle fix in an experiment

This is a follow on to TextureGroup#1429.

* fix typo in experiment name. fix copyright in tests file.

* Fix scroll node in yoga (TextureGroup#1435)

* fix SIMULATE_WEB_RESPONSE not imported TextureGroup#449

* Fix to make rangeMode update in right time

* remove uncessary assert

* Fix collection cell editing bug for iOS 9 & 10

* Revert "Fix collection cell editing bug for iOS 9 & 10"

This reverts commit 06e18a1.

* Fix child not fit to full scroll node's bounds when flex_grow = 1.0 is used on child

* Fix the stub for layerActionForKey: to let CA continue the search (TextureGroup#1441)

* Fix the stub for layerActionForKey: to let CA continue the search

* Kick CI

* Revert "Have image nodes draw into opaque contexts automatically if possible (TextureGroup#1432)" (TextureGroup#1443)

This reverts commit 28522ce.

* Use instance lock for ASPrimitiveTraitCollection (TextureGroup#1442)

* Use instance lock for ASPrimitiveTraitCollection

* Remove the atomic

* Simplify ASTraitCollection propagation in ASViewController (TextureGroup#1447)

* Use AS::Mutex in ASCollectionElement (TextureGroup#1445)

* [ASTextNode] Maintain isAccessibilityElement setting on text nodes when updating text (TextureGroup#1326)

* Add didEnterHierarchy/didExitHierarchy to ASNodeController. (TextureGroup#1444)

* Fix wrongly formatted RELEASE link (TextureGroup#1453)

* Only create activities during debug (TextureGroup#1456)

* [TextureGroup#1451] Add support for UIAccessibilityCustomAction (TextureGroup#1452)

This PR adds support for UIAccessibilityCustomAction propagation through ASPendingState so that it can be picked up by VoiceOver.

* Shut down graphics contexts experiment (TextureGroup#1458)

* Shut down graphics contexts experiment

* Remove dead import

* Remove gone class

* Remove lock of ASTextNodeRendererKey (TextureGroup#1454)

* Remove lock of ASTextNodeRendererKey

* Remove class check for isEqual

* Add const specifier to function parameter

* Fixes typo

* Fixes typo

* Disable ASAssertLocked and ASAssertUnlocked (TextureGroup#1412)

* Try to remove global lock when initialising TextKit components (TextureGroup#1455)

* Try to remove global lock when initialising TextKit components

* Adding experiment flag to dis/enable lock of textkit component

* Adding tests

* code clean

fix typo

Make remove lock optional

Keep locks

code clean

* Make ASCollectionNode's pan gesture customizable (TextureGroup#1457)

* changes done

* complete set of uigesturedeleagte methods

* Remove iOS 8 support from logging code. (TextureGroup#1462)

* Drop support for Xcode 8 and fix some compiler warnings (TextureGroup#1463)

* Remove ASEventLog (TextureGroup#1460)

* Remove ASEventLog. We'll focus on ASLog for the future, possibly making it triggerable on a per-node basis

* See ya!

* Hello semicolon

* Remove refs to gone tree methods

* Fix

* Remove irrelevant change, kick CI

* Clean up

* Cover the other background dealloc surfaces (TextureGroup#1464)

* Passthrough pagingEnabled for ASCollectionNode / ASTableNode (TextureGroup#1466)

* Passthrough pagingEnabled for ASCollectionNode and ASTableNode

* Add tvOS handling

* Fix open context bug introduced in TextureGroup#1458 (TextureGroup#1468)

* Make sure all ASDisplayNode properties have backing ivars for consistency. (TextureGroup#1475)

* Make sure all ASDisplayNodes have backing ivars for consistency.

Found this by enabling #pragma clang diagnostic error "-Wobjc-missing-property-synthesis" for ASDisplayNode. One property is unused, saving 8 bytes of heap space per instance on 64-bit builds. Implement setter/getters for these properties, and add appropriate locking. add the warning as error to the build for this file.

* Ensure ASControlMode properties lock before accessing their ivars (TextureGroup#1476)

Enable `#pragma clang diagnostic error "-Wobjc-missing-property-synthesis"` for this file.

* Add a new "global drawing" experiment to use UIGraphicsRenderer (TextureGroup#1469)

* Add a new "global drawing" experiment to use UIGraphicsRenderer everywhere, when available

* Fix logic

* Use preferredFormat

* Cut version 2.8.1 (TextureGroup#1491)

* Clean up documentation issues around periods (TextureGroup#1490)

There were so unnecessary `'` around periods for some reason. Just deleting those because they are distracting.

* Minor update in change log #changelog (TextureGroup#1492)

* Ship ASExperimentalFixRangeController (TextureGroup#1486)

* Shrink _ASCollectionPendingState from 144 to 128 bytes, a 12.5% reduction (TextureGroup#1485)

* Shrink _ASCollectionPendingState from 144 to 128 bytes, a 12.5% reduction

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* address review comments. move enums out. add comment. rename struct to _flags

* fix a missing rename

* Shrink _ASPendingState from 824 to 808 bytes, reduction of ~2% (TextureGroup#1483)

* Shrink _ASPendingState from 824 to 808 bytes, reduction of ~2%

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Shrink ASPendingState BOOLs. Use unsigned int for these bitfields for clarity. Separate from `_flags` as that struct is compared to `0` for testing. The `_boolFlags` struct is just storing other `BOOL`s.

* rename struct fields as suggested in garret's review.

* Shrink ASDisplayNode from 1072 to 968 bytes, reduction of 10.74% (TextureGroup#1484)

* Shrink ASDisplayNode from 1088 to 976 bytes, reduction of 11.48%

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* Forgot to bit-field-ify placeholderEnable; new small size is 968, old size is 1072 (measured consistentlyl on iPhoneSE simulator). 10.74% reduction.

* Shrink Button Node (TextureGroup#1494)

Button: 1312 to 1288 bytes, running on iPhone SE simulator. 1.9% reduction.

Shrink the enums it stores, and place them next to each other (along with a BOOL) to reduce instance size.

* Shrink TextNode(2) (TextureGroup#1495)

Running in iPhone SE Simulator:
- ASTextNode: 1360 to 1352 bytes .6% reduction
- ASTextNode2: 1360 to 1304 bytes 4.3% redction

Shrink stored enum sizes. Group BOOLs near these smaller enums. Override -usingExperiment to return constant instead of never set, but allocated ivar.

* Shrink Pager and Scroll Node (TextureGroup#1496)

Running on iPhone SE Simulator:
ASPagerNode 1240 to 1232 bytes .7% reduction
ASScrollNode 1104 to 1096 bytes .7% reduction

- make ASScrollNode smaller by shrinking ASScrollDirection, which requires a change to ASRangeController
- shrink ASPagerNode by declaring the BOOL next to the struct

* Shrink ASImageNode by .6% and ASNetworkImageNode by 2.2% (TextureGroup#1487)

* Shrink ASImageNode by .6% and ASNetworkImageNode by 2.2%

ASImageNode goes from 1384 to 1376. ASNetworkImageNode goes from 1496 to 1464.

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* add comments as requested in garrett's review.

* access ivar directly since already locked as suggested in review.

* Remove unused declaration, missed in TextureGroup#1460 (TextureGroup#1497)

* Keep the atomics - does not affect memory work (TextureGroup#1498)

Revert "Ensure ASControlMode properties lock before accessing their ivars (TextureGroup#1476)"
This reverts commit ce1e195.

Revert "Make sure all ASDisplayNode properties have backing ivars for consistency. (TextureGroup#1475)"
This reverts commit d6061f4.
- Except the unused property `interfaceStateSuspended` is still removed (this is a memory saver).

* Shrink ASCellNode by 8 bytes (TextureGroup#1499)

Group the BOOLs together, since there are only 4 (and there are no other auto-generated ivars that are < 64 bits) this is sufficient and keeps the properties `atomic`.

* Shrink ASEditableTextNode by 16 bytes (TextureGroup#1500)

Just shuffle some BOOLs around and explicitly declare an ivar so it is grouped with the others.

* ASSignpost: Add support for the os_signpost API, fixes (TextureGroup#1501)

* ASSignpost: Add support for the os_signpost API

- Removes support for colored intervals. These weren't really useful and they aren't part of the signpost api.
- Fixes an issue with range controller interval logging.
- Adds an interval for interface orientation changes.

* Rename

* Support Xcode 9

* Commentary

* Shrink ASLayout (TextureGroup#1503)

- Shrink the enum. Save 8 bytes. There are 1000s of these in the heap after running Pinterest for 10 minutes.

* Cleanup whitespace #trivial (TextureGroup#1507)

(It's easier to deal with these as silly oneoffs IMO than to
have them conflated with real work)

* Shrink LayoutSpec classes (TextureGroup#1502)

- Resize enums to make `ASStackLayoutSpec` 40 bytes smaller. This applies to the subclasses too.

Co-authored-by: Adlai Holler <adlai@icloud.com>
Co-authored-by: Garrett Moon <garrett@pinterest.com>
Co-authored-by: dirtmelon <272485887@qq.com>
Co-authored-by: Michael Schneider <maicki@users.noreply.github.com>
Co-authored-by: Kevin <kevin@wode.com>
Co-authored-by: dirtmelon <0xffdirtmelon@gmail.com>
Co-authored-by: Jonathan Downing <jd@jonathandowning.uk>
Co-authored-by: Xavier Deloge <Idefix60@users.noreply.github.com>
Co-authored-by: Eric Scheers <smeis@users.noreply.github.com>
Co-authored-by: Huy Nguyen <allforone1511@gmail.com>
Co-authored-by: Greg Bolsinga <bolsinga@mac.com>
Co-authored-by: Jacob Farkas <farktronix@users.noreply.github.com>
Co-authored-by: ernestmama <43187788+ernestmama@users.noreply.github.com>
Co-authored-by: Andrew Yates <contact@andydev.co.uk>
Co-authored-by: Tim Norman <tim@normsoft.com>
Co-authored-by: Michael Zuccarino <mikezuccarino@gmail.com>
Co-authored-by: Dmitry Gridnev <dmitr.gridnev@gmail.com>
Co-authored-by: Max Wang <max.wang.cs@gmail.com>
Co-authored-by: Ballad <348649634@qq.com>
Co-authored-by: ricky <rickycancro@gmail.com>
Co-authored-by: Patrick Balestra <me@patrickbalestra.com>
Co-authored-by: Harry Shamansky <harry.shamansky@gmail.com>
Co-authored-by: Wu Zhong <zhongwuzw@qq.com>
Co-authored-by: Oskar Zhang <i@oskarzhang.me>
Co-authored-by: Adlai Holler <adlai@google.com>
Co-authored-by: Greg Bolsinga <gbolsinga@pinterest.com>
Co-authored-by: Huy Nguyen <huy@pinterest.com>
Co-authored-by: Andrew Monshizadeh <amonshiz+github@gmail.com>

* use iOS 13.4.1 and default Xcode 11.4.1 for CI (TextureGroup#1831)

Co-authored-by: dmaclach <dmaclach@gmail.com>
Co-authored-by: Jeffrey Macko <mackoj@users.noreply.github.com>
Co-authored-by: vovasty <vlad@aramzamzam.net>
Co-authored-by: Heberti Almeida <hebertialmeida@gmail.com>
Co-authored-by: Adlai Holler <adlai@icloud.com>
Co-authored-by: Garrett Moon <garrett@pinterest.com>
Co-authored-by: dirtmelon <272485887@qq.com>
Co-authored-by: Michael Schneider <maicki@users.noreply.github.com>
Co-authored-by: Kevin <kevin@wode.com>
Co-authored-by: dirtmelon <0xffdirtmelon@gmail.com>
Co-authored-by: Jonathan Downing <jd@jonathandowning.uk>
Co-authored-by: Xavier Deloge <Idefix60@users.noreply.github.com>
Co-authored-by: Eric Scheers <smeis@users.noreply.github.com>
Co-authored-by: Huy Nguyen <allforone1511@gmail.com>
Co-authored-by: Greg Bolsinga <bolsinga@mac.com>
Co-authored-by: Jacob Farkas <farktronix@users.noreply.github.com>
Co-authored-by: ernestmama <43187788+ernestmama@users.noreply.github.com>
Co-authored-by: Andrew Yates <contact@andydev.co.uk>
Co-authored-by: Tim Norman <tim@normsoft.com>
Co-authored-by: Michael Zuccarino <mikezuccarino@gmail.com>
Co-authored-by: Dmitry Gridnev <dmitr.gridnev@gmail.com>
Co-authored-by: Max Wang <max.wang.cs@gmail.com>
Co-authored-by: Ballad <348649634@qq.com>
Co-authored-by: Patrick Balestra <me@patrickbalestra.com>
Co-authored-by: Harry Shamansky <harry.shamansky@gmail.com>
Co-authored-by: Wu Zhong <zhongwuzw@qq.com>
Co-authored-by: Oskar Zhang <i@oskarzhang.me>
Co-authored-by: Adlai Holler <adlai@google.com>
Co-authored-by: Greg Bolsinga <gbolsinga@pinterest.com>
Co-authored-by: Huy Nguyen <huy@pinterest.com>
Co-authored-by: Andrew Monshizadeh <amonshiz+github@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants