448 Commits

Author SHA1 Message Date
Huy Nguyen
fb6d1830a0 Beter table/collection update history (#2562)
- Introduce thread-safe ASEventLog
- ASCollectionNode and ASTableNode share their event log with their ASDataController. The controller uses it to log change set submitting and finishing events.
- ASCollectionNode and ASTableNode print their data source and delegate in their debug description.
2016-11-08 16:44:49 -08:00
Garrett Moon
17bd3acdee Revert "Need to trampoline to main to make contents check safe if nodes are loaded. (#2545)"
This reverts commit 11e07ff409d64ed7cf48877a325b8b4ad737daef.
2016-11-06 18:09:29 -08:00
Garrett Moon
11e07ff409 Need to trampoline to main to make contents check safe if nodes are loaded. (#2545) 2016-11-04 11:33:17 -07:00
Michael Schneider
dae374d482 Initial commit to cleanup modifying subnode hierarchy (#2535) 2016-11-02 17:12:35 -07:00
Michael Schneider
58e9c807b9 Fix using UIActivityIndicatorView provided in view block (#2522) 2016-11-01 07:58:54 -07:00
Michael Schneider
4464b7de60 Improve deprecation situation for 2.0 (#2514)
* Improve deprecations for 2.0

- Add deprecations for node / layoutSpec style properties
- Implement missing methods on ASDisplay from deprecation header
- Cleanup all of the deprecation categories

* Remove DeprecatedProtocolMethods

* Fix "Life without Cocoapods"

* Update comments
2016-10-31 16:46:21 -07:00
Michael Schneider
7ecce6b677 Remove thread affinity for _displaysAsynchronously (#2518) 2016-10-31 14:12:50 -07:00
Michael Schneider
c4451edab1 Add assertion for invalid constrainedSize in calculateSizeThatFits: (#2507) 2016-10-28 16:45:22 -07:00
Michael Schneider
fb92b448e0 [ASDisplayNode] Proper handling of constrainedSize (#2505)
* Check in ASLayout if size is valid for sizing instead of valid for layout

* Return constrainedSize from calculateSizeThatFits:

Remove invalid constrainedSize check within ASNetworkImageNode. Furthermore as ASDisplayNode does not return CGSizeZero anymore we have to give the display nodes we use in tests and are involving a stack spec an intrinsic content size.

* Remove extra constrainedSize handling in ASNetworkImageNode handling

* Change test to use FLT_MAX
2016-10-28 15:39:03 -07:00
Michael Schneider
6d5bd6e969 Cleanup calculateLayoutThatFits: (#2480) 2016-10-26 11:26:57 -07:00
Scott Goodson
30a7edf30f [ASLayout] Remove new ASLayoutPrivate.h file and put contents into ASLayoutSpec+Subclasses.h 2016-10-21 13:23:05 -07:00
appleguy
2c6f8b0506 [AsyncDisplayKit 2] Final changes to ease migration of clients to 2.0 APIs. (#2460) 2016-10-21 13:12:13 -07:00
Scott Goodson
3a2ca70676 [ASDisplayNode] Simplify / shorten temporary bridged implementation of preferredFrameSize. 2016-10-21 11:21:21 -07:00
Hannah Troisi
9719357901 [ASLayoutElement] Move ASDisplayNode's .name property to ASLayoutElement (renamed to .debugName) (#2395)
* Move ASDisplay .name property to ASLayoutElement

* keep ASDisplayNode.name deprecated

* address @appleguy's comments
2016-10-20 17:27:31 -07:00
Adlai Holler
dbe3b1bd71 Remove block copying (#2438) 2016-10-20 12:53:25 -07:00
Adlai Holler
6e76daf279 [Layout] Check Layout Spec Tree for Duplicated Elements (#2408)
* Check layout spec tree for duplicated elements

* Enable layout spec tree dedupe only in debug
2016-10-18 09:33:37 -07:00
Michael Schneider
d407663e3f [ASLayout] Improve ASLayout (#2404)
* Add internal header for ASLayout and change position to readonly publicly

* Don't copy sublayouts during tree filtering

* Revert "Don't copy sublayouts during tree filtering"

This reverts commit 6b0d54d5ffe5bb3941ec13696c9c45b0098b6ba1.
2016-10-18 08:36:38 -07:00
appleguy
42d1c9a55b [ASCellNode] Add subclass method cache; skip visibility rect calculations in the common case. (#2388)
Profiling showed this area as the most expensive part of ASRangeController propogation of .interfaceState,
when scrolling an ASTableView.  This is very much on the critical path for sustained 60FPS in these views.
2016-10-15 09:58:57 -07:00
Michael Schneider
507bc55504 [Layout] Add ASLayoutElementStylability protocol (#2366)
* Add ASLayoutElementStylability protocol

* Rename to styledWithBlock:, add instancetype and add noescape
2016-10-11 09:16:18 -07:00
Michael Schneider
166414dfc9 [Layout] Lazy initialize ASLayoutElementStyle in ASDisplayNode and ASLayoutSpec (#2352)
* Lazy initialize `ASLayoutElementStyle` in `ASDisplayNode`

* Lazy initialize `ASLayoutElementStyle` in `ASLayoutSpec`
2016-10-06 16:53:40 -04:00
appleguy
3f1f5667c3 [ASDisplayNode] Add -displayWillStartAsynchronously: method to allow skipping synchronous image cache check. (#2344) 2016-10-05 12:48:54 -04:00
Scott Goodson
b928e79cb5 [ASDisplayNode] Optimize pendingDisplayNodes check using isEmpty (ASWeakSet). 2016-10-05 00:13:34 -07:00
Michael Schneider
f369be43dd [Examples] Fix extra examples (#2342)
* Fix

* Add building extra examples to build.sh

* Fix example projects

* Fix CarthageBuildTest

* Export NSArray+Diffing.h to fix life without cocoapods
2016-10-04 19:34:14 -04:00
Michael Schneider
d6e5e27c39 [Layout] Add helper properties for setting sizes via CGSize and ASRelativeSize (#2324)
* Remove set layout style size helper

* Update API to set and get a CGSize / ASRelativeSize from an ASLayoutElementStyle

- Expose ASRelativeSize type
- Add new helper properties to set a size / relative size to ASLayoutElementStyle
- Don't expose the size in ASLayoutElementStyle anymore and move into ASLayoutElementStylePrivate

* Update examples

* Update comments for size helpers
2016-10-04 12:35:45 -04:00
Adlai Holler
f027a8be80 Remove ASSentinel (#2336) 2016-10-04 12:22:16 -04:00
appleguy
360541fac5 [ASDisplayNode] Change _pendingDisplayNodes from NSMutableSet to ASWeakSet. (#2340)
In at least some cases, _pendingDisplayNodes referencing self can cause the
object to live longer than the application needs, while tearing down views.

It also appears there may be a cancellation condition where this state is
not balanced properly, which can cause a reference-cycle leak.  This change
safely fixes this problem when tested against a repro case for it.

I'm filing a followup task to make sure all cancellation edge cases have
proper accounting for this codepath, even though the leak is fixed.
2016-10-04 10:22:54 -04:00
Garrett Moon
5205ef6840 [API] Remove old deprecated methods. (#2312)
* Remove old deprecated methods. Will restore ones that were removed recently based on PR.

* Update example to use non-deprecated method.

* Don't remove locking / unlocking, insets or willDisplayNode deprecated methods yet.
2016-10-03 14:57:01 -04:00
Hannah Troisi
7551627b58 [Layout] Rename ASLayoutable to ASLayoutElement (#2290)
* [Layout API] Rename ASLayoutable to ASLayoutElement

* arg

* fix wrapperWithLayoutElement

* [Layout API] Rename ASLayoutable to ASLayoutElement

* arg

* address Michael's comments

* Remove ASLayoutValidation files that were deleted on master since this diff was created.
2016-09-29 00:02:47 -07:00
Michael Schneider
1abc1a833c Remove legacy layout validation code (#2311) 2016-09-28 16:46:31 -07:00
Michael Schneider
2f99951732 [Layout] Move [ASLayoutSpec children] from std::map to NSMutableArray (#2253)
* Initial commit to move [ASLayoutSpec children] from std::map to NSMutableArray

* Add NSFastEnumeration to ASLayoutable

* ASNullLayoutSpec is a Singleton now

* Move ASLayoutSpecPrivate in Private folder

* Move to NSArrayPointer and remove ASNullLayoutSpec

* Revert "Move to NSArrayPointer and remove ASNullLayoutSpec"

This reverts commit 9ab9cf7024b1f6e1984d84fe58af2b84e84cdf94.

* Move to childAtIndex: and setChild:atIndex:
2016-09-27 19:41:45 -04:00
Michael Schneider
f574f2c54e [Layout] Further deprecation steps for preferredFrameSize (#2255)
* Deprecate preferredFrameSize

- Remove all support for preferredFrameSize in ASDK
- preferredFrameSize setter calls through and sets the width and height of the node
- preferredFrameSize getter tries to return a CGSize based on the width and height properties otherwise if this is not possible it throws

* Address comments

* Return CGSizeZero for preferredFrameSize unless width and height are ASDimensionUnitPoints

* Better comment for preferredFrameSize and remove lock in calculateSizeThatFits:
2016-09-27 16:07:36 -04:00
Michael Schneider
9f55de2c6c Remove styleClass property from ASLayoutable for now (#2279) 2016-09-23 09:30:17 -07:00
Michael Schneider
75dca556e6 [Layout] Add style property to ASLayoutable (#2261)
* Add style property to ASLayoutable

* Add styles property to further layout specs

* Adjust some examples

* Add `loadStyle` to create the style object in a ASLayoutable

* Revert "Add `loadStyle` to create the style object in a ASLayoutable"

This reverts commit 2b7240f2c7dc993e38cadf290cfdf08482dd70c7.

* Revert "Adjust some examples"

This reverts commit 3254ae0a321e75db3ecfa80adee9d96bde93a33d.

* Revert "Add styles property to further layout specs"

This reverts commit c779dcb876ead27122c1af1300146a6ad36912cb.

* Rename ASLayoutableStyleDeclaration to ASLayoutableStyle

* Add styleClass class property for extensibility support of the ASLayoutable style object

* flexShrink should not be YES by default
2016-09-22 16:00:52 -07:00
Harry Shamansky
71fc2dd18d Revise performance measurement naming and structure (#2265)
* Revise performance measurement naming and structure

- Revises naming from LayoutSpecGeneration to LayoutSpecComputation
- Adds a struct instead of an NSDictionary to retrieve performance metrics
- Includes ASEnvironmentStatePropagateDown in LayoutSpecComputation measurements

* Revise SumScopeTimer to include enable flag

* Make struct a typedef
2016-09-20 15:39:09 -04:00
appleguy
3e5b8c3096 [ASDisplayNode] Ensure ASHierarchyState propagation does not jump discontinuities in the node hierarchy. (#2263)
Scenario: An ASCollectionNode is a subnode of an ASCellNode.  A layout transition is started, resulting in
the removal of the ASCollectionNode as a subnode.  As it is removed, the hierarchy state is cleared - including
the "range managed" bit - on the ASCollectionNode.  However, the deep recursion traverses the layer hierarchy
too, and clears this bit on the ASCellNodes inside the ASCollectionNode.  A moment later, the collection performs
its final ASRangeController update to mark its cells as invisible and free memory.  Then an assertion is triggered
in ASRangeController, because it is operating on nodes that do not have the "range managed" bit set.

It turns out that ASInterfaceState also propogates in this way, but that behavior is efficient and beneficial in
its current configuration (it assists how multi-dimensional preloading works).  However, hierarchy state should
never need to jump discontinuities in the node hierarchy.  For now, disabling that case and will revisit
other use cases soon.
2016-09-19 12:04:39 -07:00
Adlai Holler
25de53bb13 [ASDisplayNode] Add Event Tracing to Help Debugging (#2243)
* Add some simple event logging for ASDisplayNode

Improve the tracing

* Add header to copy files phase

* Make event header public
2016-09-15 13:24:19 -07:00
Adlai Holler
8459c1e825 Remove some thread affinity assertions that we no longer need (#2251) 2016-09-15 12:13:24 -07:00
Adlai Holler
88d588d590 [ASDisplayNode] Use Weak Proxy to Avoid Dangling CALayer.delegate (#2249)
* Add weak proxy between node and layer to avoid dangling layer problem

* Add failing test case for dangling CALayer.delegate pointer issue

* Add docs

* Remove asynctransactioncontainer forwarding preprocessor macro

* Improve comments

* Remove asyncTransactionContainerStateDidChange callback
2016-09-15 10:49:31 -07:00
Adlai Holler
337e908390 Make Description Functions Dealloc-Safe (#2241)
* Make description functions dealloc-safe

* Make -debugDescription also dealloc-safe
2016-09-13 17:48:31 -07:00
Adlai Holler
8c380d1601 Don't crash in production on invalid subnode insert (#2231) 2016-09-12 10:29:31 -07:00
Harry Shamansky
59fbfb682d Measure performance for ASCellNode layout (#2209)
* Measure performance for ASCellNode layout

* Address Adlai and Levi's feedback:
* Move to ASDisplayNode level
* Lock around setting/getting measurement options and results
* Record all measurement passes and report times as an array
* Only add relevant entries to the performanceMetrics dictionary
* Rebase

* Store sum and count instead of array

* Rename ScopeTimerDataPoint to ScopeTimerSum

* Address Levi's feedback

* Address Adlai's feedback
2016-09-09 10:38:13 -07:00
John Engelhart
8c2f3f666f Fixes unsafe use of asyncdisplaykit_node. (#2207)
The previous code used either a `@property` with `assign, nonatomic` semantics, or a `__unsafe_unretained` (non-atomic) ivar pointer to an instance for `asyncdisplaykit_node`.

This commit changes those access so that they have the equivalent of `weak, atomic` semantics.

- `_ASDisplayView.mm`
  - Removes the `_node` ivar that was qualified with `__unsafe_unretained`.
  - Removes `@synthesize asyncdisplaykit_node = _node;`.
  - All direct uses of `_node` were replaced with:
    - Creates a strong reference via `ASDisplayNode *node = _asyncdisplaykit_node;`.
    - `s/_node/node/`.
    - These changes were made even if there's a single use of `_asyncdisplaykit_node` as a consistency / defensive measure so that anyone editing this code in the future does not accidentally use a `weak` reference twice.

- `ASDisplayNode.mm`
  - Getters and setters for `asyncdisplaykit_node` were changed from `nonatomic, assign` semantics to the equivalent of `atomic, weak` semantics.
  - `weak` semantics were implemented by using a `ASWeakProxy` object.
  - `objc_setAssociatedObject` was changed from `OBJC_ASSOCIATION_ASSIGN` to `OBJC_ASSOCIATION_RETAIN` (the `atomic` version of retain).

- `ASDisplayNode+FrameworkPrivate.h`
  - Changed the `@property` declarations for `asyncdisplaykit_node` from `nonatomic, assign` to `atomic, weak`.
    - The actual getters and setters are implemented in `ASDisplayNode.mm`, which were changed accordingly.
2016-09-08 17:27:49 -07:00
Adlai Holler
bc59b96ca9 [ASDisplayNode] Add onDidLoad Method to Perform Work When Loaded (#2128)
* [ASDisplayNode] Add `onDidLoad:` method

* Prevent user from rasterizing wrapper nodes – they can't be reloaded in the future
2016-09-08 14:18:35 -07:00
Michael Schneider
0d8518912e Initial commit to throw an exception if manually adding / removing subnodes if node has automaticallyManagesSubnodes enabled (#2214) 2016-09-08 11:59:57 -07:00
Adlai Holler
5593bfa4d1 [ASDisplayNode] Majorly Improve Descriptions (#2208)
* Up our description game big time

* Couple tweaks

* Explain logic

* Fix indentation
2016-09-07 20:11:27 -07:00
Michael Schneider
0aeefaf25f [Layout] Automatic measurement on layout fixes (#2206)
* Don't measure range managed nodes automatically in the layout pass

* Fix auto measure a node mid transition
2016-09-07 12:46:05 -07:00
Michael Schneider
8897614f0e [Layout] Layout API based on content area (#2110)
* Initial commit for adding a size constraint to ASLayoutable's

* Some more commits

* Fix sample projects in extra/

* Remove preferredFrameSize test of ASEditableTextNode

* Remove preferredFrameSize from examples_extra

* Add deprecation warning to -[ASDisplayNode preferredFrameSize]

* Add deprecation warning to -[ASDisplayNode measureWithSizeRange:]

* Commit

* Commit

* Remove ASRelativeSizeRange

* Make ASRelativeSize private

* Adjust examples

* Improve setting of -[ASLayoutable size] with points or fractions

* Add ASWrapperLayoutSpec

* Improve creation of ASRelativeDimension

* Add `preferredFrameSize` back and add deprecated logging

* Add `layoutSpecBlock` setter and getter and add locking for it

* Add better documentation and fix macros to create ASRelativeDimension

* Create new ASSizeRangeMake with just a CGSize as parameter

* Update Kitten and Social App Layout example

* Add layoutThatFits: and deprecate measure:

* Rename ASRelativeDimension to ASDimension

* Fix examples for ASDimension renaming

* Remove fancy height and width setter

* Fix ASDimension helper

* Rename -[ASLayout layoutableObject] to -[ASLayout layoutable]

* Update layout related methods and more clearer documentation around how to use it

* Deprecate old ASLayout class constructors

* Don't unnecessary recalculate layout if constrained or parent size did not change

* Use shared pointer for ASDisplayNodeLayout

* Fix rebase conflicts

* Add documentation and move implementation in mm file of ASDisplayNodeLayout

* Fix test errors

* Rename ASSize to ASLayoutableSize

* Address comments

* Rename setSizeFromCGSize to setSizeWithCGSize

* Improve inline functions in ASDimension

* Fix rebase conflicts
2016-09-07 08:44:48 -07:00
Hannah Troisi
03c21830a5 improve layoutSpecThatFits: assertion message (#2201) 2016-09-06 11:42:59 -07:00
Michael Schneider
9b823ebdc9 Add better exception message for adding or removing ASDisplayNode's in layoutSpecThatFits: (#2183) 2016-09-02 14:58:19 -07:00
Adlai Holler
33a680255c [ASDisplayNode] Add Convenience Interface State Accessors (#2168)
* Finish renaming fetchData range, add convenience accessors

* Update example

* Update new tests
2016-09-01 16:44:16 -07:00