506 Commits
Author SHA1 Message Date
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
Michael Schneider 3d37e55c7b Some more improvements around constrained size 2016-11-19 06:43:46 -08:00
Michael Schneider 30b7644415 Factor out constrainedSize usage for layout pass 2016-11-19 06:43:46 -08:00
Michael Schneider 257d4c3a1f Further improvements and fixing tests 2016-11-19 06:43:46 -08:00
Michael Schneider c14a86c4d6 More improvements to figure out the constrained size that should be used in the layout pass 2016-11-19 06:43:46 -08:00
Michael Schneider a71a1d8519 Address comments 2016-11-19 06:43:46 -08:00
Michael Schneider 2744998a10 Further progress 2016-11-19 06:43:46 -08:00
Michael Schneider c7765f6183 Add pending layout to ASDisplayNode 2016-11-19 06:43:46 -08:00
Michael Schneider d21a512907 Some commit 2016-11-19 06:43:46 -08:00
Michael Schneider b0eb2f81c2 Cleanup 2016-11-19 06:43:46 -08:00
Michael Schneider 0eb882bae5 Some more changes 2016-11-19 06:43:46 -08:00
Michael Schneider c819d716b4 Implement sizeToFit: 2016-11-19 06:43:46 -08:00
Michael Schneider 0f8eac4757 Some other commit 2016-11-19 06:43:45 -08:00
Michael Schneider 6f40e9a654 Some more stuff in flux 2016-11-19 06:43:45 -08:00
Michael Schneider c61ba65ba3 Some commit 2016-11-19 06:43:45 -08:00