Commit Graph
756 Commits
Author SHA1 Message Date
Tim Norman 5937ac3333 Fix a bug with Yoga nodes whose position change and don't update. (#1408) 2019-03-22 11:30:40 -07:00
Huy Nguyen 09365b90ee 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) 2019-03-22 06:40:18 -07:00
Michael Schneider 74de765b62 Only set ASLayoutElementStyle delegate if Yoga is enabled (#1417) 2019-03-21 07:41:02 -07:00
Kevin f4d6b95f1c Add support for reverse direction to yoga layouts (#1413)
* Add support for reverse direction to yoga layouts

* #ifdef YOGA yoga-specific additions

* oops
2019-03-20 15:09:21 -07:00
Andrew Yates 59279e7920 Fix GIF Caching (#1405) 2019-03-18 13:32:01 -07:00
Huy Nguyen e3ae6635c7 Avoid an unnecessary lock & unlock pair in ASMainSerialQueue (#1409) 2019-03-16 09:34:39 -07:00
Adlai Holler 34f16217a6 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
2019-03-13 11:58:08 -07:00
Garrett Moon 96a7723d3b Context is a pretty general name that will cause conflicts with subclasses (#1399) 2019-03-12 15:32:58 -07:00
Adlai Holler 223d6bdca7 Fix header typo (#1402) 2019-03-12 14:34:58 -07:00
Adlai Holler abe46b08a9 Make shared CA transaction queue variable extern so it's actually shared (#1397) 2019-03-12 08:22:21 -07:00
Adlai Holler 5490d4d1fa Make experiment checks faster (#1393)
* Make experiment checks use dispatch_once when not debugging, clean up singleton

* One more

* Pull out the variable
2019-03-12 07:43:38 -07:00
ernestmama 6f44c3921e 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
2019-03-11 13:34:35 -07:00
Greg Bolsinga 593b56aaff 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.
2019-03-09 12:15:20 -08:00
Adlai Holler 9cd0d58373 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
2019-03-09 12:14:58 -08:00
Jacob Farkas a38b3f547e Add UIDataSourceModelAssociation to ASTableView and ASCollectionView (#1354)
* Add UIDataSourceModelAssociation protocol conformance to ASTableView and ASCollectionView.

* Implementing review feedback from @Adlai-Holler
2019-03-09 07:56:10 -08:00
Garrett Moon 9b80eabd8f 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
2019-03-09 07:55:46 -08:00
Kevin 872e89b772 Need some more locks for working with calculated yoga layouts (#1388) 2019-03-09 07:55:35 -08:00
Kevin 510000ee85 Correct attributes lookup for supplementary elements. (#1318) 2019-03-08 09:41:25 -08:00
Greg Bolsinga dffe22f12d 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.
2019-03-08 09:40:51 -08:00
Michael Schneider bb6102aa18 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
2019-03-08 08:32:57 -08:00
Kevin aeb370ff13 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];
2019-03-08 08:27:49 -08:00
Kevin d7eda2ec34 Assert for context creation failure during displayBlock. (#1373)
Nothing good can possibly happen if we continue without one.
2019-03-08 08:26:52 -08:00
Kevin 3089a3e3b0 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.
2019-03-08 08:26:35 -08:00
Kevin 65061b9d3d Catch invalid sizes during yoga layout (#1376) 2019-03-08 08:24:08 -08:00
Garrett Moon 3547f5add3 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.
2019-03-08 08:18:11 -08:00
Huy Nguyen d102ec81ee 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
2019-03-08 08:11:03 -08:00
Adlai Holler 5e8721ebe8 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
2019-03-07 13:29:13 -08:00
Garrett Moon fce6f23b97 Launches switching ASNetworkImageNode callbacks to global queue. (#1369)
* Launches switching ASNetworkImageNode callbacks to global queue.

* Good catch configuration tests!
2019-03-07 09:47:56 -08:00
Kevin 7bb3079082 Don't add extraneous truncation token during kCTLineTruncationMiddle. (#1297)
* Don't add extraneous truncation token during kCTLineTruncationMiddle

* Expand these comments a little.
2019-03-06 10:05:30 -08:00
Eric Scheers a0012d90c2 Add forwarding of UIAccessibilityAction methods (#1344)
* Add forwarding of UIAccessibilityAction methods

* Use OCMock for testing UIAccessibilityAction method forwarding
2019-03-06 10:02:50 -08:00
Michael Schneider 07becd0fc8 Cleanup Yoga Categories (#1364) 2019-03-06 07:37:40 -08:00
Adlai Holler dd4359db7b 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
2019-03-05 18:20:17 -08:00
Xavier Deloge 2a9379248b _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.
2019-03-05 09:00:38 -08:00
Adlai Holler 17dbd8e1e5 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
2019-03-04 21:07:31 -08:00
Jonathan Downing 6dc0edf839 Make ASCollectionElement Public (#1303)
* Update AsyncDisplayKit.h

* Update project.pbxproj
2019-03-04 17:34:56 -08:00
Kevin babd81bd23 Add setNeedsLayout to yoga tree changes. (#1361) 2019-03-04 17:33:28 -08:00
Kevin 96e6a6c595 Resolve root constrained size before informing delegate to resolve infinite layout loop. (#1359) 2019-03-04 17:21:01 -08:00
Kevin 50e8dbfb9c 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.
2019-03-04 17:20:47 -08:00
Garrett Moon 001765a85e If we check for batching before content size is available we'll always fetch (#1355) 2019-03-03 19:33:32 -06:00
Adlai Holler d14a3b03e9 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)
2019-03-03 12:49:36 -06:00
Kevin 1410b29b63 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
2019-03-03 08:05:01 -08:00
Michael Schneider ddc4fd2ddb Don't compile out ASExperimentalTextNode if ASTextNode is compiled out (#1353) 2019-03-03 07:56:09 -08:00
Adlai Holler 6428077e01 Revert "Have node and controller share lock (#1227)" (#1347)
This reverts commit 2baa9438d7.
2019-02-22 11:28:36 -08:00
Garrett Moon 999cb6e485 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
2019-02-21 15:21:19 -08:00
Adlai Holler efeb3d2749 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
2019-02-21 12:33:39 -08:00
Michael Schneider 8edb5a45d3 Move ASSectionController and ASSupplementaryNodeSource method to be optional (#1302) 2019-02-20 11:21:47 -08:00
Leonid Lyadveykin 8908030eeb Add backgroundView for ASCellNode #trivial (#1333) 2019-02-15 12:52:48 -08:00
Michael Schneider 2a1e03fe75 Move ASCellLayoutModeSyncForSmallContent to the end of bitmask (#1341) 2019-02-15 12:52:07 -08:00
Adlai Holler 6e7cdea797 Add extension points for global node behaviors, potentially replacing interface state delegates (#1229)
* Add extension points for global node behaviors via categories and a public ivar

* Update documentation on context ivar
2019-02-14 14:17:03 -08:00
Kevin affa588654 Correct some dereferences in as_log_verbose invocations (#1317) 2019-02-14 09:22:38 -08:00