520 Commits

Author SHA1 Message Date
Adlai Holler
fab98b32ef Fix Pager Node Issues (#3028)
* Fix pager node and deprecate zeroContentInsets flag

* Do it with the visible state callback

* There we are

* Put viewController in node debug description
2017-02-14 14:10:51 -08:00
Michael Schneider
2dca7a0c8d [Debug] Remove not used code around visualizing layout specs (#2991)
* Remove not used code around visualizing layout specs

* This is sad to see but let’s remove the LayoutSpecPlayground for now
2017-02-10 13:09:09 -08:00
appleguy
f91265757e [Yoga] Initial commit for supporting Yoga-powered layout calculation. (#2982)
* [Yoga + AsyncDisplayKit] Initial commit for supporting Yoga-powered layout calculation.

Because this results in ASLayout objects, it preserve support for automaticallyManagesSubnodes
as well as the animated transition system. More work remains to vet performance of the new mode,
and it will remain in +Beta for the forseeable future.

I'm not sure that this should ever be used as the primary ASDK layout system, but it should remain an
option for some apps to experiment with if they require an implementation that more strictly mirrors
W3C standard Flexbox.

* [Yoga] Improve usage of ASHierarchyState to ensure simultaneous yoga layouts can't happen.

* [Yoga] Strictly minimize the impact of the Yoga integration on existing code.

Created new file ASDisplayNode+Yoga.mm, reduced size and number of integration points in core code.

* [Yoga] Figured out how to further reduce ASDisplayNode.mm impact by allocating _yogaNode in property accessor, and changing all accesses to use the property.
2017-02-09 16:10:29 -08:00
Rocir Santiago
b33cced1eb [ASDisplayNode] Add support for setting non-fatal error block (#2993)
* Add support for setting non-fatal error block

* Better documentation and fix typos

* Added ASDisplayNodeAssertNonFatal macro that asserts in dev and call block in prod

* Make non fatal error code equals to 1

* Add support for condition in ASDisplayNodeAssertNonFatal

* Only call non fatal block if condition isn’t satisfied
2017-02-07 17:13:33 -08:00
Michael Schneider
d2da941960 Fix some static analyzer warnings (#2999) 2017-02-07 10:33:34 -08:00
Michael Schneider
aedac5c299 Remove legacy parent pointer of ASLayoutSpec (#2987) 2017-02-06 20:01:37 -08:00
Michael Schneider
42b53c9331 [ASLayoutTransition] Remove taking a snapshot in the default layout transition code (#2940)
* Remove taking a snapshot in the default default layout transition code

* Set groupOpacity for root node of animation to true before and restore after animation finished
2017-02-06 15:29:37 -08:00
Michael Schneider
12e4e5b048 [Layout] Improve Layout System Abstraction (#2941)
* Improve Layout Abstraction

* Address naming comments

- Rename ASPrimitiveTraitEnvironment to ASTraitEnvironment
- Rename ASPrimitiveTraitCollectionPropagateDown to ASTraitCollectionPropagateDown
- Rename progagateNewPrimitiveTraitCollection: to propagateNewTraitCollection:
2017-02-03 13:04:20 -08:00
Adlai Holler
404795dc02 Remove Support for iOS 7 (#2930)
* Drop support for iOS 7

* Copy reference images

* Update deployment for sample projects

* Update version

* Update "Life Without Cocoapods"
2017-02-01 14:40:37 -08:00
Hannah Troisi
7f7f28385d [ASNodeController] First implementation of node controller class (#2945)
* [ASNodeController] initial commit for node controller class

* create <ASInterfaceState> protocol, -[ASDisplayNode interfaceDelegate], and use these to forward to ASNodeController

* rename ASInterfaceStateDelegate, fix setting in it ASNodeController.mm
2017-01-31 14:27:02 -08:00
Adlai Holler
38aac9d019 IGListKit Support II: Electric Boogaloo (#2942)
* Reimplement IGListKit support in a cleaner way

* Rename and fix some stuff

* Fix supplementaries more

* Update docs

* Update test

* Cleanup minor things

* Tweak it

* Indentation

* Remove irrelevant changes

* Break out cell into its own file

* Fix indentation

* Address feedback
2017-01-30 11:16:59 -08:00
Michael Schneider
e143942d22 [ASDisplayNode] Overall code cleanup and restructuring (#2931)
* First round of ASDisplayNode cleanup: Move together sections that are related

* Cleanup hierarchy and interface state
2017-01-25 16:41:42 -08:00
appleguy
b8872c24db [AsyncDisplayKit] Fix a few comment typos and minor compiler strictness warnings. (#2932) 2017-01-25 12:53:13 -08:00
Michael Schneider
9a5f6d3ece Consider the deduce compiler flag for duplicate elements in a subtree (#2922) 2017-01-23 17:03:54 -08:00
Adlai Holler
7c4ee350b0 Use Native convertRect:, convertPoint: Methods to Handle Nil Cases (#2889)
* When converting rects, points on loaded nodes, call into UIKit/CoreAnimation

* Always use view-ish behavior

* Improve nil window handling, add documentation
2017-01-11 13:44:35 -08:00
Michael Schneider
7872cfb5a4 Reverting back _finishOrCancelTransition that was mistakingly moved in a recent PR (#2820) 2016-12-21 11:24:34 -08:00
Garrett Moon
4ae2948d53 These messages must be called on main. (#2814) 2016-12-20 14:29:32 -08:00
Adlai Holler
3e53d26686 Ensure that all nodes are deallocated inside the thrash testing method to avoid polluting other tests (#2800) 2016-12-19 18:45:57 -05:00
haritowa
64ee8dbffb [ASDisplayNode Deallocation] Fix for crash when certain types are used as instance variables. (#2803)
* Fix https://github.com/facebook/AsyncDisplayKit/issues/2802

* Change nil to NULL
2016-12-19 17:06:23 -05:00
Huy Nguyen
f7a0ac9760 [ASThread][ASDisplayNode] Detect and avoid deadlocks caused by upward lock gathering in didEnter/Exit states (#2764)
* Implement mutex ownership and use it to check potential upward lock gathering

* Don't hold instance lock and call willEnterHierarchy/didExitHierarchy of ASDisplayNode
- This can cause deadlocks (e.g #2605) if subsequent methods, that are implemented by developers, walk up the node tree.
- This is a way to keep the optimizations introduced in 9e87813 while making sure the locking situation is a bit safer.

* More lock ownership assertions in ASDisplayNode

* Document main thread contract  of -clearContents

* ASNetworkImageNode shoud not call setNeedsPreload while holding instance lock
- This helps to avoid potentially deadlocks caused if the node (esp in case it's a subclass of ASNetworkImageNode) walks up the tree in didEnterPreloadState, for example to build logging context.

* ASVideoNode should not call setNeedsPreload while holding instance lock
- This helps to avoid potentially deadlocks caused if the node (esp. if it's a subclass of ASVideoNode) walks up the tree in didEnterPreloadState, for example to build logging context.

* Don't hold instance lock for the entire insert subnode operation
- The recursive lock should not be held throughout `_insertSubnode:atSubnodeIndex:sublayerIndex:andRemoveSubnode:`. The method instead should manage the lock itself and acquire it as shortly as possible. The reason is that this method calls many methods outside the scope of `self`. `[subnode __setSupernode:self]` is especially troublesome because it causes the subnode to migrate to new hierarchy and interface states, which triggers `didEnter/Exit(.*)State` methods. These methods are meant to be overriden by subclasses. Thus they might walk up the node tree and potentially cause deadlocks, or they perform expensive tasks and cause the lock to be held for too long.
- Other methods that call this method should release the lock before doing so.

* Lock getter and setter of `synchronous` flag

* Address comment in ASVideoNode

* Add main thread assertions to methods that change asset and assetURL of ASVideoNode

* Explain CHECK_LOCKING_SAFETY flag

* More thread and locking assertions in ASVideNode
- It's not safe to call `-[subnode __setSupernode:self]` while holding instance lock of soon-to-be supernode (e.g `self`).
- It's also not safe to call `[subnode __setSupernode:nil]` while holding the instance lock of the old supernode (e.g `self`).
- did(Enter|Exit)(.*)State methods are always called on main. Add main thread assertions to indicate that.

* Minor change in explanation of CHECK_LOCKING_SAFETY flag
2016-12-19 12:11:26 -08:00
Huy Nguyen
c0ae709b88 [ASDisplayNode][ASImageNode] Small refactorings (#2778)
* Comment out template code and fix another comment in ASDisplayNode

* Release instance lock a bit sooner and fix indentation in ASImageNode
2016-12-18 20:57:35 -08:00
ricky
8920b60dcd [ASDisplayNode] Remove node from supernode before adding it as a subview (#2746)
* [ASDisplayNode] Remove node from supernode before adding it as a subview

If a node is being added as a subview to a UIVIew, we must make sure to remove it as a subnode of its supernode.

* remove from supernode if adding to a layer.
2016-12-13 09:34:05 -08:00
Michael Schneider
ddc23af8e7 [Layout Transition] Reset the alpha value for inserted and removed subnode to initial value (#2729)
* Reset the alpha value for removed subnodes in layout transition to 1 after removal

* Some improvements

* Restore alpha value of inserted and removed subnodes to original alpha value in animated layout transition
2016-12-12 19:46:01 -08:00
appleguy
eeb977e145 [ASDisplayNode] Ensure all subclasses are using base class __instanceLock__ and not re-defining their own. (#2754)
* [ASDisplayNode] Ensure all subclasses are using base class __instanceLock__ and not re-defining their own.

This also moves the @package definition of the instance variable to +FrameworkPrivate instead of Internal.h,
because Internal.h should ideally not be used outside of the ASDisplayNode file setup.  This has greatly reduced
the number of imports of Internal.h.

* [ASDisplayNode] Add ASDisplayNode+FrameworkSubclasses.h to share __instanceLock__ definition.
2016-12-12 19:42:41 -08:00
appleguy
2feabd2832 [ASScrollNode] Support for automaticallyManagesContentSize, adopting the ASLayoutSpec's size as the scrollable contentSize. (#2753)
* [ASScrollNode] Support for automaticallyManagesContentSize, adopting the ASLayoutSpec's size as the scrollable contentSize.

This feature has been desired for a long time, and has turned out to be phenomenally useful and easy to use.

It works well either for a blank ASScrollNode with .layoutSpecBlock set on it, or a subclass of ASScrollNode with a more
traditional layoutSpecThatFits: implementation.  With this approach there is no need to capture the layout size, use
an Absolute layout spec as a wrapper, or set contentSize anywhere in the code and it will update as the layout changes!

There is no automatic management of contentInset, but it would make sense to add this with keyboard listeners in the future.

* [ASScrollNode] Add locking to new properties, adjust how calculateLayout override is done.
2016-12-12 12:03:54 -08:00
Adlai Holler
5b80a641af Improve Handling of Rasterized Node Interface & Hierarchy States (#2731)
* Improve handling of rasterize node interface states and testing

* Fix harder

* Finish fixes and move rasterization flag into beta header

* Re-enable rasterization in ASDKgram

* Re-enable working test

* Only do it in debug
2016-12-08 09:52:21 -08:00
Michael Schneider
a2e75152f8 [ASDisplayNode] Fix flickering for nodes that support range managed interface state (#2710)
* Fix flickering for range managed nodes

* Go back to old behavior to check for range managed before calling didExitPreloadState in interface state change
2016-12-05 10:34:03 -08:00
Michael Schneider
e361d00a73 Our calculated layout is suitable for this constrainedSize, so keep using it and invalidate any pending layout that has been generated in the past. (#2706) 2016-12-02 16:17:14 -08:00
Garrett Moon
ba2268ac99 2611 rename fetch data (#2689)
* Replace fetch data with preload terminology
- Deprecate `-fetchData` and `-clearFetchedData` in favor of `-preload` and `-clearPreloadedData`
- Move `-setNeedsPreload`, `-recursivelyPreload` and `-recursivelyClearPreloadedData` to ASDisplayNode+FrameworkPrivate.h
- Update internal implementation, comments and tests

* Folllow up on #2642:
- Remove -preload and -clearPreloadedData in favor of -didEnterPreloadState and -didExitPreloadState.
- -didEnterPreloadState and -didExitPreloadState call the deprecated -fetchData and -clearFetchedData methods if they are overriden.

* Missed one in a test

* Get rid of behavior change for now.

* Revert more behavior changes, fix tests.

* Don't need these anymore.
2016-12-01 13:41:22 -08:00
Michael Schneider
52bb2a3a6e Revert constrainedSize changes that should have never made it in 2016-11-28 17:20:26 -08:00
Michael Schneider
4928af4635 [Layout Transition] Layout Transition Fixes (#2657)
* Don’t call layoutIfNeeded before starting the layout transition

* Further improvements
2016-11-28 12:57:03 -08:00
Scott Goodson
1c70412868 [ASDisplayNode] Create placeholders off main when possible.
This is a fix for https://github.com/facebook/AsyncDisplayKit/issues/2620,
which is a followup to https://github.com/facebook/AsyncDisplayKit/pull/2610

This will ensure thread affinity is respected for .contents but still run
placeholderImage off-main when possible (node isn't loaded).
2016-11-22 22:29:24 -08:00
Adlai Holler
9a762f9832 Make a public function ASPerformMainThreadDeallocation 2016-11-21 11:17:24 +09:00
Adlai Holler
71872a298e Merge pull request #2223 from facebook/AHNaturalDealloc
[ASDisplayNode] Let Nodes Deallocate Naturally, Deallocate UIKit Components in Run Loop
2016-11-21 01:20:47 +09:00
Adlai Holler
e923943e8c Use CACurrentMediaTime instead of CFAbsoluteTime 2016-11-21 00:54:07 +09:00
Adlai Holler
887f48cbda Add support for run loop queues with no handler, optimize 2016-11-21 00:49:54 +09:00
Adlai Holler
6d01bbeb19 Let nodes deallocate naturally, manually trampoline UIKit ivars
Be more aggressive with main thread punting

Trampoline setting the dataSource/delegate onto the main thread

Short-circuit the supplementary nodes method if no data source

Don't rely on assertions

Mark variable unused to fix release builds

Handle ASCollectionNode/ASTableNode deallocation better

Add some comments about new macro
2016-11-21 00:46:57 +09:00
Michael Schneider
ddd4ef62ae Fix overlapping of nodes in layout transitions 2016-11-19 20:53:32 -08:00
Michael Schneider
9530b609f1 Readd layout transition check for invalid constrained size 2016-11-19 18:31:56 -08:00
Michael Schneider
8d5fc9efe3 We need to invalidate the layout before the transition does start 2016-11-19 06:58:07 -08:00
Michael Schneider
66ad9bd5e3 Apply patch from Scott 2016-11-19 06:46:21 -08:00
Michael Schneider
eef4a61ea0 Add checks to bail out early in layout transition 2016-11-19 06:43:46 -08:00
Michael Schneider
f9c70470d8 Address another round of comments 2016-11-19 06:43:46 -08:00
Michael Schneider
fc747ca58a Small code improvements 2016-11-19 06:43:46 -08:00
Michael Schneider
b762998336 Add detection for a loop if invalidation of a size is happening multiple times 2016-11-19 06:43:46 -08:00
Michael Schneider
5d61b2b4e6 Address further comments 2016-11-19 06:43:46 -08:00
Michael Schneider
2cd49642b9 Address comments from @appleguy 2016-11-19 06:43:46 -08:00
Michael Schneider
d73712059d Remove unecessary measurement pass in ASCellNode 2016-11-19 06:43:46 -08:00
Michael Schneider
c29b7a184c Introduce ASFloorSizeValues and ASCeilSizeValues 2016-11-19 06:43:46 -08:00
Michael Schneider
cc297a2dae Fix some tests and add a workaround to ceil the values from self.bounds.size before checking for equality 2016-11-19 06:43:46 -08:00