359 Commits

Author SHA1 Message Date
Michael Schneider
01fed69b26 Adds trampoline for inserting and deletion of nodes
Currently measurement always needs to happen on the main thread if implicit hierarchy management is enabled as adding and removing from nodes needs to happen on the main thread. We now will trampoline to the main thread to do the insertion and deletion of nodes.

This also resolves the issue that can occur if a node is already loaded deep in the layout hierarchy in the layout that the node is transforming to. Before insertion or deletion is happening we need to crawl the layout hierarchy to check that though.
2016-07-01 16:33:37 -07:00
Adlai Holler
211dcdf0e8 [_ASHierarchyChangeSet] Remove unused new method 2016-06-24 13:56:08 -07:00
Adlai Holler
27dc52c0c5 [ASHierarchyChangeSet] Document reload-splitting behavior 2016-06-24 13:20:06 -07:00
Adlai Holler
304f8f6cb1 [ASHierarchyChangeSet] Clean up and add documentation 2016-06-24 13:17:00 -07:00
Adlai Holler
d8d2524b89 One more critical update integrity fix 2016-06-24 11:12:37 -07:00
Adlai Holler
681876bd59 Fix more issues with data integrity 2016-06-24 11:12:37 -07:00
Adlai Holler
35056f708b [ASDataController] Improve update handling 2016-06-24 11:12:37 -07:00
Adlai Holler
71d9f64535 Carry over first-pass change set improvements 2016-06-24 11:12:37 -07:00
Adlai Holler
77f24231b3 [Documentation] Add a comment why we prefer -indexPathForItem:inSection: 2016-06-24 10:13:51 -07:00
Adlai Holler
457e08005f [ASDataController] Remove asyncDataFetching Option, Cleanup (#1794)
* [ASDataController] Add some assertions to clarify what queues things happen on

* [ASCollectionDataController] Optimize willReloadData

* [ASDataController] Minor optimizations, no functional changes

* [ASDataController] Always reload data on _editingTransactionQueue

* [ASDataController] Remove async data fetching option, deprecate callbacks

* [ASDataController] Not mutable

* [ASMultidimensionalArrayUtils] Use fast enumeration

* Optimize ASMultidimensionalArrayUtils
2016-06-23 21:08:44 -07:00
Adlai Holler
57310a6fe4 Merge pull request #1802 from facebook/AHThrashTesting
[Unit Tests] Add Table View Data Thrash Testing
2016-06-22 21:35:58 -07:00
John Engelhart
ea64d7d09b Pr/fix unit tests memory leaks (#1795)
* Fix some concurrency problems detected by Xcode 8's new Thread Sanitizer.

Some of these changes are arguably just to silence the warnings from Thread Sanitizer.

* Fix several memory leaks in the unit tests.

A number of the unit test source files are compield with `-fno-objc-arc`.  This was clearly overlooked when writing several of the unit tests.

Fixed by (mostly) switching to use of `-autorelease` for the problem code.

NOTE: This commit doesn't fix all the memory leaks found.  There's still at least one leak in `-[ASDisplayNodeTests testSetNeedsDataFetchImmediateState]`, and several leaks in `ASBasicImageDownloader.mm`.  I wasn't able to find a trivial cause to these, unfortunately.
2016-06-22 16:56:53 -07:00
Adlai Holler
fcf2db79f8 [ASTableViewThrashTests] Initial commit 2016-06-21 18:46:08 -07:00
Michael Schneider
eef22074a4 Add caching for checking if ASDisplayNode can clear it contents or setNeedsDisplay: can be called on the layer 2016-06-20 13:04:44 -07:00
Adlai Holler
5d434d418f Merge pull request #1765 from facebook/AHLockingPassOne
[ASDisplayNode] Resolve Deadlock Caused By removeFromSupernode
2016-06-17 13:58:10 -07:00
Michael Schneider
aa5d730eab Deallocate objects on a serial queue specific for deallocation (#1737)
[Performance] Prevent GCD thread explosion due to object deallocation workloads (serial deallocation queue).
2016-06-16 18:18:43 -07:00
Adlai Holler
15b6f2e281 [ASLayoutTransition] Optimize add/remove subnode methods 2016-06-16 17:10:33 -07:00
Hannah Troisi
c857e809f4 Clean up header comments (for consistent Facebook licensing info) (#1741)
[Licensing] Clean up header comments (for consistent Facebook licensing info)
2016-06-11 23:31:39 -07:00
Levi McCallum
a3e8f556a3 Clean up flattening process in ASLayout 2016-06-10 12:43:46 -07:00
Eric Jensen
fdc57410ee Move the default animated image runloop mode to a constant, and fallback to the constant if the runloop mode is set to nil 2016-06-09 10:53:37 -07:00
Eric Jensen
370e5f1006 Allow configuration of ASImageNode's animation runloop 2016-06-08 10:38:43 -07:00
Eric Horacek
d89504e345 Fix index path arithmetic error 2016-06-05 21:38:08 -07:00
Eric Horacek
8f3e511b22 Fix warning 2016-06-05 21:38:08 -07:00
Eric Horacek
fc5eef3269 Repopulate supplementary views on item-level changes
Currently within `ASCollectionView`, there is an assumption that there will always be a static number of supplementary views per section—even when additional items are added or removed from that section. This is evidenced by the fact that when you invoke -[ASCollectionView insertItemsAtIndexPaths:], the data source method -[ASCollectionDataSource collectionView:nodeForSupplementaryElementOfKind:atIndexPath:] is not invoked, preventing consumers from specifying a new number of supplementary nodes for the new set of items.

With this change, the set of supplementary nodes for a section is now recalculated not only on section-level mutations, but also on item-level mutations as well. This adds item-level counterparts to the section-level `-prepareFor...` subclassing hooks in `ASDataController+Subclasses.h` to make this possible.

This should fix #1278 and #1322

This has been tested in my project and seen to fix the assertion. Open to suggestions on how to test in a more universal way.
2016-06-05 21:38:08 -07:00
Levi McCallum
f809d4a1c9 Let ASLayout determine if a node should measure 2016-06-05 09:32:48 -07:00
Levi McCallum
19e949e02f [ASDisplayNode] Move constrainedSize to layout 2016-06-05 09:30:57 -07:00
Levi McCallum
c469ad273b [ASLayout] Cache constrained size range 2016-06-05 09:22:46 -07:00
appleguy
e5eed560e1 Merge pull request #1693 from rcancro/traitUpdate
[ASTraitCollection] Bug fixing/LayoutSpec propagation
2016-06-03 22:01:13 -07:00
ricky
01dbc86778 First pass of comments
* make variable naming reflect ASEnvironmentTraitCollection vs ASTraitCollection
* move trait propagation to cell allocation instead of via a nested block
* move trait propagation when setting a displaynode's supernode instead of when adding a subnode
* fixed misspelling of "colection"
2016-06-03 09:59:24 -07:00
Erekle
4f40f3c12f Merge remote-tracking branch 'facebook/master' into ASVideoPlayerNode
# Conflicts:
#	AsyncDisplayKit.xcodeproj/project.pbxproj
2016-05-26 12:15:23 +04:00
Levi McCallum
95f1ab4902 [ASDisplayNode] Rename ASDisplayNodeTransitionContext to ASLayoutTransition (#1680)
* [ASDisplayNode] Rename ASDisplayNodeTransitionContext to ASLayoutTransition

* Rename internal ivar to fit new naming

* Fix tabbing
2016-05-25 10:10:27 +07:00
ricky
59a26ee111 [ASTraitCollection] Bug fixing/LayoutSpec propagation
* Fixed bug in `ASEnvironmentMergeObjectAndState`
* New ASLayoutSpec methods for `setChild`/`setChildren`/`setChild:forIdentifier:` have been added to take in a trait collection.
* Added `setChild:`-like methods for ASLayoutSpecs take a traitCollection
* Fixed instances where nodes in a data controller were not getting their trait collections
* propagate traitCollection in ASDisplayNode on insertSubnode or addSubnode
2016-05-23 16:37:40 -07:00
Erekle
8c8fc3dba0 Adding ASVideoPlayerNode 2016-05-17 11:08:53 -07:00
rcancro
4b54144f55 Levi's comments 2016-05-11 10:21:11 -07:00
rcancro
9d622c7eac changed DisplayTraits to TraitCollection 2016-05-10 14:45:03 -07:00
rcancro
b4a6f87ca6 addressed some comments 2016-05-10 14:44:32 -07:00
rcancro
8bb4eba080 Initial attempt at implementing Display Traits
Initial attempt to get display traits working with ASEnvironment.

To get proper ASDisplayTraits support, you must use an ASViewController. The ASViewController implements UITraitCollection-related methods (`traitCollectionDidChange:`, `willTransitionToTraitCollection:withTransitionCoordinator:`, viewWillTransitionToSize:withTransitionCoordinator`) to update the internal ASDisplayTraits and propagate them to subnodes.

ASTableNode and ASCollectionNode don't actually have their cells as subnodes, so a little bit of trickery is involved (on `setEnvironment:` the table/collection node gets its data controllers completedNodes and propagates the new traits. see `ASDisplayTraitsCollectionTableSetEnvironmentState`). The data controller also passes the current display traits when creating new cells.

ASViewController also supports the ability to return a custom set of display traits. So if you have a modal dialog that should always be told it is in a compact size class, you can set the override block before displaying the VC.

A new example, called Display Traits, has been added. It shows how display traits can be used in a ASViewController with a normal ASDisplayNode as its root, as well as in ASViewControllers hosting table nodes and collection nodes. There is also an example of overriding the default display traits of a VC.

Please provide feedback!
2016-05-10 14:44:22 -07:00
Michael Schneider
d1054d6ed9 Move from ASSentinel to a atomic int 2016-05-05 20:25:07 -07:00
Michael Schneider
dc6d2e7660 Improve Transition ID handling 2016-05-05 20:25:07 -07:00
Garrett Moon
938ecd9b6f Fix deadlock when laying out on multiple threads
Summary:
We observed a deadlock which occurred when two threads were laying out the same set of nodes.

On one thread, layout would occur on a leaf node. It would lock and as part of this layout
process, ASDK walks up the node tree and calls __setNeedsLayout on its supernode until it
reaches the supernode with no supernode. When the supernode gets its call to __setNeedsLayout
it also locks. So leaf node locks and then awaits supernode lock.

On another thread, we're doing a layout pass on the supernode in the above thread. This locks
the supernode and attempts to lock the leaf node. This deadlocks (remember the above thread
is holding onto the leaf lock and awaiting the supernode lock. This thread is holding onto
the supernode lock and awaiting the leaf lock).

This is all exacerbated by the use of recursive locks.
2016-05-03 15:56:38 -07:00
appleguy
dd4853bf3a Merge pull request #1273 from aaronschubert0/tvOS
[tvOS] Add default focus states to ASControlNode & ASImageNode.
2016-04-20 13:29:31 -07:00
appleguy
b8379a07a6 Merge pull request #1563 from maicki/FollowupFixASCollectionNodeASTableNodeBackgroundColor
Follow up for ASCollectionNode and ASTableNode background color fix
2016-04-19 18:11:28 -07:00
Michael Schneider
42174210c5 Follow up for ASCollectionNode and ASTableNode background color fix 2016-04-19 16:07:42 -07:00
Garrett Moon
0fc39d1ccd Follow up to animated GIF PR 2016-04-19 13:43:41 -07:00
appleguy
39da0987a3 Merge pull request #1537 from maicki/FixASCollectionNodeASTableNodeBackgroundColor
Fix ASTableNode / ASCollectionNode backgroundColor does not apply correctly.
2016-04-19 12:30:54 -07:00
Michael Schneider
3793dc024e Improve setting special properties for certain classes directly to the UIView
- Remove duplicated code in ASCollectionNode and ASTableNode
- Fix setting the pending state to the view if applying the pending state to the view
2016-04-19 10:50:22 -07:00
Vivian Qu
ccb5860c78 Update ASSentinel to use OSAtomicAdd32 to support iOS7.0 2016-04-19 10:46:55 -07:00
Aaron Schubert
21abe8f899 Fix merge conflicts 2016-04-19 09:02:07 +01:00
Michael Schneider
9d07336c75 Fix static analyzer issue with common indexes algorithm in _asdk_commonIndexesWithArray:
The issue was: The left operand of '>=' is a garbage value in else if check for lengths[i+1][j] ... I had to rewrite the algorithm to quiet the static analyzer.
2016-04-18 14:38:32 -07:00
appleguy
30a0c471ca Merge pull request #1528 from ejensen/instancetype
[Refactoring] Replace id with instancetype in initializers
2016-04-16 20:53:41 -07:00