86 Commits

Author SHA1 Message Date
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
Leonid Lyadveykin
8908030eeb Add backgroundView for ASCellNode #trivial (#1333) 2019-02-15 12:52:48 -08:00
Huy Nguyen
f1801388be
Add experiments to skip waiting for updates of collection and table views under some circumstances (#1311)
* Add experiment to skip waiting until all updates of collection/table view are committed in -accessibilityElements

The wait was introduced in #1217 which blocks the main thread until updates are proccessed. We suspect this causes perf regressions accross the app and need to confirm this via an experiment.

* Add option to skip default behavior of ASCellLayoutMode

* Fix unit test

* Fix unit test in another way

* Remove import

* Minor change

* Add ASCellLayoutModeSyncForSmallContent

* Update unit tests

* Remove unnecessary change

* Remove unnecessary changes
2019-01-24 10:13:54 -08:00
Adlai Holler
2a4b77b6d5
Remove let and var macros now that we're all-C++ (#1312)
* Remove let and var macros now that we're all-C++

* Another fix

* More!

* And more!
2019-01-17 10:16:53 -08:00
Michael Schneider
7a782f8176 Fix deprecated implementations warning (#1306) 2019-01-16 18:28:37 -08:00
appleguy
2d43f468d0 [ASCollectionView] Supplementary nodes should not enter ASHierarchyStateRangeManaged. (#1310)
As of today, ASRangeController doesn't manage the interfaceState for supplementary nodes. This bug was introduced with a refactoring of this code a couple months ago.

With this change, the supplementary nodes will automatically enter each interfaceState bit when they are added to a view hierarchy.
2019-01-11 08:11:55 +01:00
Michael Schneider
52b84bac01
Use cell mode while wrapping supplementary nodes (#1282) 2019-01-10 08:50:23 +01:00
Huy Nguyen
17e56042d3
Add a way to opt out of always-clear-data behavior in ASCollectionView and ASTableView (#1284) 2018-12-20 13:47:58 -08:00
Kevin
b69fe703fd Wrap supplementary node blocks to enable resizing them. (#1265)
* Wrap supplementary node blocks to enable resizing them.

Most ASCellNodeBlocks are wrapped by ASCollectionView.mm to add an `interactionDelegate` as well as calling `enterHierarchyState` on the node and setting its transform to a reflection if `inverted` is set on the collectionView.

This PR adds this behavior to supplementary nodes as well.

* Simplify code / block will never be nil
2018-12-10 14:33:04 -08:00
Michael Schneider
82b4d34e5b Introduce ASCellLayoutMode (#1273)
* Introduce ASCellLayoutMode

* Some smaller improvements

* Improve logic around _superPerformBatchUpdates:completion:

* Add comment about default values for ASCellLayoutModeNone

* Always call _superReloadData:completion: within UICollectionView

* Add initial range test for ASCellLayoutModeNone
2018-12-09 23:39:28 -08:00
Michael Schneider
8029632460
Fix A11Y for horizontal collection nodes in Texture (#1217)
* Fix A11Y for horizontal collection nodes in Texture.

Collections have their own handling in UIKit that we shouldn't mess with. As such no nodes that contain CollectionNodes should ever be treated as AccessibilityContainers.

* Update braces
2018-11-14 08:11:32 -08:00
Michael Schneider
fec14f8310
Fix logic cleaning data if delegate / dataSource changes and bring over logic to ASTableView (#1200)
* Cleanup in ASTableView datasource/delegate change

* Fix experiments logic

* Add changelog entry
2018-11-01 08:08:45 -07:00
Eric Jensen
565da7d493 Add missing NS_NOESCAPE in overwritten methods (#1139)
Fixes -Wmissing-noescape warnings
2018-10-04 09:33:08 -07:00
Huy Nguyen
e70325563a
Only clear ASCollectionView's data during deallocation (#1154)
This is a follow up on #1136. Our experiment results show that clearing data frequently is the cause of our #1 crash. @maicki and I believe that this is because if the collection view is being used, silently clearing its data without notifying the backing UICollectionView can put it out-of-sync and causes mayhem next time the collection view processes a batch update. If you look at the stack trace closely, you'll notice that the crash doesn't occur on the same run loop that clearData is called. This made it extremely tricky to investigate and identify the root cause.

Another interesting question would be whether or not we want to clear the data during deallocation at all, since the data will be cleared out soon anyway.
2018-10-03 16:14:01 -07:00
Michael Schneider
4708522bd0
Add ASExperimentalSkipClearData #trivial (#1136)
* Add ASExperimentalSkipClearData

* Move the experiment check within the if clause
2018-09-20 09:22:18 -07:00
Max Wang
dbcf8babb8 Fix collection editing (#1081)
* fix SIMULATE_WEB_RESPONSE not imported #449

* Fix to make rangeMode update in right time

* remove uncessary assert

* Fix collection cell editing bug for iOS 9 & 10

* Rename to reordering.

* Adjust _reordering more acuratedly

* Add change log
2018-09-05 08:08:46 -07:00
appleguy
465abb1ded [License] Simplify the Texture license to be pure Apache 2 (removing ASDK-Licenses). (#1077)
* [License] Simplify the Texture license to be pure Apache 2 (removing ASDK-Licenses)

With permission of the Facebook Open Source team, we are simplifying the Texture
license so that clients can rely on the Apache 2 terms that most of Texture is
already covered by. This means that code originally forked from AsyncDisplayKit
will be re-licensed from "BSD 3-clause + PATENTS v2" to Apache 2 without a
PATENTS file.

After getting confirmation that the updates to these core files look good, we'll
propagate this new license header to all files (in this same PR) and get sign-off
from all parties before landing.

* [License] Update all Texture source files to be pure Apache 2.

* Changelog entry for Apache 2 license update.

* Revert "[License] Update all Texture source files to be pure Apache 2."

This reverts commit ffa0fbbba9717d871dd16c4b07539f2f8208fc2b.

* [License] Update all Texture source files to be pure Apache 2, maintaining copyrights.

* [License] Update CONTRIBUTING, README, Podspec & Dangerfile.
2018-08-28 07:39:18 -07:00
Michael Schneider
55abeed743
Introduce let / var macros and some further cleanup (#1012)
* Introduce let / var and some further cleanup

* Address first comments

* Update changelog

* Move the const before auto
2018-07-10 09:37:53 -07:00
Adlai Holler
77e2d28919
Create transfer-array method and use it (#987)
* Create transfer-array method and use it

* License headers

* Update ASArrayByFlatMapping
2018-06-29 18:21:55 -07:00
Adlai Holler
a0e5f4c002
Create an experiment to remove extra collection teardown step (#975)
* Create an experiment to remove extra collection teardown step, simplify delegate proxy

* chagelog

* Remove detritus
2018-06-19 08:32:02 -07:00
Adlai Holler
a11506564a
Reduce usage of autorelease pools (#968)
* Reduce reliance on the autorelease pool

* changelog

* A few more places

* Use it in another place
2018-06-15 10:15:25 -07:00
Huy Nguyen
8a4bb6cf06
[ASTableView] Generate a new cell layout if existing ones are invalid (#942) 2018-05-28 18:26:01 +03:00
Max Wang
62b07e100e Match interfacestate update sequence to uikit (#882)
* fix SIMULATE_WEB_RESPONSE not imported #449

* Fix to make rangeMode update in right time

* Match interface update closer to UIKit.

* allow the correct exiting sequence for thrashing

* refactor
2018-05-25 18:21:50 -07:00
Huy Nguyen
0830f6cf23
[ASCollectionNode/ASTableNode] Fix a crash occurs while remeasuring cell nodes (#917) 2018-05-15 20:18:54 +01:00
appleguy
a41cbb48b3
[ASWrapperCellNode] Introduce a new class allowing more control of UIKit passthrough cells. (#797)
* - [ASWrapperCellNode] Introduce a new class allowing more control of UIKit passthrough cells.

A few minor fixes to Collections behavior as well, including a new isSynchronized
API. The difference from processingUpdates is that after Synchronized, all animations
have also completed (or runloop turn if animations disabled, so .collectionViewLayout
can be relied on being fully in sync).

More upstreaming to come after this can land...

* Fix -[ASDataController clearData] to take no action before initial data loading.

* Empty commit to kick CI

* Spacing change to kick CI (since an empty commit doesn't work...)

* Tweak ASDataController changes to handle an edge case in _editingTransactionQueueCount management.

* Avoid excess cyclic calls to onDidFinishProcessingUpdates: by avoiding ASMainSerialQueue.

* Reverting my initial change as it wasn't the right approach, following the real fix before this.
2018-03-13 01:03:18 -07:00
Alex Hill
d9d9a29365 [tvOS] Fixes errors when building against tvOS SDK (#728)
* [tvOS] Fixes errors when building against tvOS SDK

* Update CHANGELOG.md

* [tvOS] Fixes implicit conversion between UIViewAnimationCurve +
UIViewAnimationOptions

* Enable tvOS deployment target in Texture.podspec (for CI)

* [ASMultiplexImageNode] Fixes typo

* [tvOS] Fixes warnings related to @available guards in Xcode 9
[ASMultiplexImageNode] Enables support for Photos framework on tvOS 10+

[ASMultiplexImageNode] Fixes comment depth

[ASAvailability] Adjust logic in AS_AVAILABLE_IOS_TVOS to account for
both versions
Adjusts API_AVAILABLE to minimum deployment target

* [ASAvailability] Update AS_AVAILABLE_XXX fallbacks to function more like
the built-in solution (more accurately target OS by checking target)
Change AS_AVAILABLE_IOS -> AS_AVAILABLE_IOS_TVOS in places that shoud
allow for both

[ASAvailability] Simplify AS_AVAILABLE_IOS_TVOS

* [ASControlNode] Adds missing 'super' call in -[ASControlNode didLoad]
when targeting tvOS

* Fix API_AVAILABLE iOS requirement

* [ASDisplayNode] Fixes last of the linker warnings related to category
overrides. Removes methods already implemented in
ASDisplayNode+UIViewBridge category.
[ASControlNode] Moves tvOS category declaration to ASControlNode header
[ASImageNode] Moves tvOS category declaration to ASImageNode header
[ASControlNode+Private] Adds private category for ASControlNode to
access private selectors

* [NSParagraphStyle+ASText] Fixes typo related to testing

* [ASControlNode] Re-add helpful comment

* [ASTextKitCoreTextAdditions] Adds mappings for kCTParagraphStyleSpecifierMinimumLineSpacing, kCTParagraphStyleSpecifierMaximumLineSpacing, kCTParagraphStyleSpecifierLineSpacingAdjustment when mapping CTParagraphStyle onto NSParagraphStyle
[ASTextNode] Uses CoreText-cleansed attributed string when assigning ascender/descender to avoid crash when a CTParagraphStyle is passed as an attribute

* [AsyncDisplayKit] Update project file to include new/deleted files

* [ASControlNode+tvOS] Add missing Foundation import (whoops!)
[ASImageNode+tvOS] Add missing Foundation import (whoops!)

* Update podspec to only link AssetsLibrary framework on iOS

* [ASTextKitCoreTextAdditions] If kCTParagraphStyleAttributeName key-value
evaluates to an NSParagraphStyle, pass through to cleansed attributes. This
fixes a bug that would occur if a CTParagraphStyle was passed as an
attribute _alone_ (would not be caught by unsupported attributes
check)

* [ASMultiplexImageNode] Bump availability check to support < Xcode 9

* [ASTraitCollection] Fixes typo that was causing build to fail

* Clean up formatting to adhere to character/line limit + braces
2018-03-11 16:37:27 -07:00
Max Wang
479d40464e [ASTableNode & ASCollectionNode] Keepalive reference for node if their view is necessarily alive (has a superview). (#793)
* fix SIMULATE_WEB_RESPONSE not imported #449

* Fix to make rangeMode update in right time

* Keep collection/table node alive if view still in use.
2018-02-09 12:16:18 -08:00
appleguy
31227da577
[ASRangeController] Fix stability of "minimum" rangeMode if the app has more than one layout before scrolling. (#790)
This should result in memory savings in many apps, since errant relayouts are pretty common.
2018-02-09 11:04:00 -08:00
Adlai Holler
9b8a919a93
Revert "Faster collection operations (#748)" (#759)
This reverts commit 5c13403ef75c030adc7a4d51a7792a9c6c1c348b.
2018-01-22 11:38:09 -08:00
Adlai Holler
5c13403ef7 Faster collection operations (#748)
* Faster collection operations

* Fix a few things

* Put the stupid semicolon

* Address warning

* Cut down retain/releases during collection operations

* Update CHANGELOG.md
2018-01-22 13:22:03 +00:00
Adlai Holler
61dade6bda Raise deployment target to iOS 9 (#743)
https://github.com/TextureGroup/Texture/pull/743

Manually merged since I forgot to retarget that diff onto master before merge
2018-01-15 15:13:05 -08:00
Adlai Holler
5e73396cde
Enable collection node interactive moves (#735)
* Add support for interactive moves

* Enable drag & drop in collection view example

* Update changelog

* Change the gating logic to match UIKit

* Add a warning when we prevent interactive movement due to async layout
2018-01-09 14:34:32 -08:00
Ilya
eab7bea48d Add missing flags for ASCollectionDelegate (#718)
* Add missing flags for ASCollectionDelegate

* Update CHANGELOG.md
2017-12-19 17:13:45 +00:00
César Estébanez Tascón
8f19434788 Check for nil elements on ASTableView as well #trivial (#710) 2017-12-19 16:56:35 +00:00
Erekle
d8cda8d74a [iOS11] Update project settings and fix errors (#676)
* [iOS11] Update project settings and fix errors

* update changelog

* resolve comments
2017-11-30 12:25:06 +00:00
Adlai Holler
4fc753a458
Make it possible to map between sections even if they're empty (#660)
* Make section mapping work even for empty sections

* Unlock more cases and update changelog

* Fix complexity documentation
2017-11-03 16:24:48 -07:00
Adlai Holler
ff608c92bf
[Minor Breaking API] Make deallocation queues more reliable (#651)
* Make our async deallocation functions take a double pointer, so we can be sure we've released before the queue drains

* Make it a class property

* Fix the return type

* Use a locker

* Improve release notes
2017-11-02 10:45:34 -07:00
appleguy
63efdbde8f [ASCollectionView] Call -invalidateFlowLayoutDelegateMetrics when rotating. #trivial (#616)
* [ASCollectionView] Ensure -invalidateFlowLayoutDelegateMetrics is called for UIKit passthrough cells.

This allows rotation to work properly when rotating UIKit passthrough
cells that need to change width.

* [ASCollectionView] No need to verify node is still in model to handle view-only notifications.
2017-10-31 13:20:58 +00:00
appleguy
68f3468d91 [ASCollectionView] Improve performance and behavior of rotation / bounds changes. (#431)
* [ASCollectionView] Improve performance and behavior of rotation / bounds changes.

See #430 for details.

* Edit CHANGELOG.md

* [ASDataController] Implement -relayoutAllNodesWithInvalidationBlock:, to flush the ASMainSerialQueue before -invalidateLayout is called.

* Don't set download results if no longer in preload range. (#606)

Good catch by @djblake, if you scroll fast enough, you leave images
set on the image node because didExitPreloadRange (which would have
cleared it) was already called.

* Animated WebP support (#605)

* Updating to support animated WebP

* Fix a deadlock with display link

* Fix playhead issue.

* Fix up timing on iOS 10 and above

* Don't redraw the same frame over and over

* Clear out layer contents if we're an animated GIF on exit range

* Clear out cover image on exit of visible range

* Don't set cover image if we're no longer in display range.

* Don't clear out image if we're not an animated image

* Only set image if we're not already animating

* Get rid of changes to podfile

* Add CHANGELOG entry

* Update license

* Update PINRemoteImage

* Remove commented out lines in example

* [ASDataController] Add nullable specifier to invalidationBlock for relayout of nodes.
2017-10-24 13:12:52 +01:00
Garrett Moon
d31af734df Dispatch batch update to main #trivial (#626)
* Dispatch batch update to main

* TableView too
2017-10-20 15:01:38 -07:00
Garrett Moon
919ec8d32b Check if we need to do a batch update (#624)
* Check if we need to do a batch update

If we've changed our leading screens for batch fetching, we
may need to batch fetch.

* Add CHANGELOG entry
2017-10-20 09:23:07 -07:00
appleguy
c6e3dd7a5d [ASCollectionView] Fix index space translation of Flow Layout Delegate methods. (#467)
* [ASCollectionView] Fix index space translation of Flow Layout Delegate methods.

This includes a few other cleanups, including overflow of signed integer indices.

* [ASCollectionView] Improve code sharing of UIKit size method calls; ensure delegate invalidation re-fetches supplementary sizes too.

* [ASCollectionView] Final method ordering and doc-comment for new _sizeForUIKitCellWithKind:atIndexPath: method.
2017-10-09 17:19:46 +01:00
appleguy
ccc5786032 [ASCollectionNode] Add -isProcessingUpdates and -onDidFinishProcessingUpdates: APIs. (#522)
* [ASCollectionNode] Add -isProcessingUpdates and -onDidFinishProcessingUpdates: APIs.

Over time, there have actually been a lot of legitimate uses for an API like this.
In fact, I'm not quite sure what has held us back from adding one!

I believe that at least some portion of -wait calls (even if less than 50%) could be
replaced with -onDidFinishProcessingUpdates:, which could potentially improve the
performance of applications using -wait by a significant amount.

Please take a close look at implementation correctness. Although I'm in a bit of a
rush, I'm aiming to make this properly documented and added a basic test -- but it
could certainly use some more detailed testing as a followup.

* [ASCollectionNode] Improvements to the implementation of -isProcessingUpdates and -onDidFinishProcessingUpdates:

* Add lock to ASMainSerialQueue count method.

* [ASTableNode] Implement -isProcessingUpdates and -onDidFinishProcessingUpdates:. Rename -waitUntil to consistent naming.
2017-08-23 11:16:21 +01:00
Huy Nguyen
884a4f56f1 [Table and collection views] Consider content inset when calculating (default) element size range (#525)
* Table and collection views to consider their content inset when calculating element size range

* Update CHANGELOG

* Address comments

* -[ASPagerNode currentPageIndex] to use pageSize instead of bounds

* Update documentation in ASPagerNode

* Minor change
2017-08-22 14:14:01 -07:00
Adlai Holler
f58b0b3cd3 Rename the field again to nodeModel (#504)
* Rename the field to nodeModel

* A few more instances

* Fix method name
2017-08-10 16:11:12 -07:00
Huy Nguyen
eb5bde0791 [ASDataController ] Merge willUpdateWithChangeSet and didUpdateWithChangeSet delegate methods #trivial (#445)
* Merge willUpdateWithChangeSet and didUpdateWithChangeSet delegate methods into one
- After #420, there is no change occurs between those 2 methods. Having them separately doesn't achieve anything and can cause confusions.

* Minor change
2017-07-17 11:43:31 +00:00
appleguy
5115f660c8 [ASCollectionView] Add delegate bridging and index space translation for missing UICollectionViewLayout properties. (#440)
* [ASCollectionView] Add delegate bridging and index space translation for missing UICollectionViewLayout properties

This is a first attempt at resolving #438.

I know there is already one similar method to do indexPath conversions, and that the #define for
accessing properties on the UICollectionViewFlowLayout should probably be moved somewhere else.

Looking for feedback on the general direction here. In particular, I'm a bit surprised that so much
has changed in how these calls occur, as I believe especially constrainedSizeForNodeAtIndexPath: is
now called with inconsistent index path spaces (but was not before this PR landed in March:
https://github.com/facebookarchive/AsyncDisplayKit/pull/3136/files)

Since the impact of mixing the spaces is fairly serious (can cause crashes), I'm also wondering if
I am misinterpreting some aspects of the code, or if maybe the crashing impact wasn't noticed yet.

* [ASCollectionView] Cleanup and final changes for UIKit passthrough fixes.
2017-07-17 11:30:46 +00:00
Huy Nguyen
e78d70eec4 [ASCollectionView] Small improvements (#407)
* Minor refactors in ASCollectionView and its private cell classes
- `_ASCollectionReusableView` and `_ASCollectionViewCell` no longer expose getters for their collection element and cell node properties. This is to make sure that clients can only obtain elements from the visible map which is always the source of truth.
- Since the map can return `nil` for an element request, it's much safer to check and avoid adding/removing a nil pointer to an `NSArray`.
- Since we use a special way to check whether an object of kind of `_ASCollectionViewCell` or `_ASCollectionReusableView`, based on the assumption that these classes are subclass restricted, I added cast-or-return  macros in the header files, closer to where the restrictions are declared.

* Add ASDynamicCastStrict

* Add element and node properties back to _ASCollectionReusableView and _ASCollectionViewCell

* Assert unexpected nil elements

* Always mark an element visible even if it is backed by an UIKit / non-_ASCollection* view

* Fix typo

* Remove unnecessary changes

* Dump mistakes

* Update CHANGELOG

* Can't track visibility of elements backed by non-_AS views
2017-07-06 17:38:23 +00:00
appleguy
a68f3c5aa9 [ASCollectionElement] Add checks for nil element, prior to other PRs landing. (#421) 2017-07-05 14:14:35 -07:00
Huy Nguyen
ed9a3cc2e0 [ASDataController] Apply new visible map inside batch updates block (#420)
* ASDataController to apply new visible map inside batch updates block

* Update CHANGELOG

* Sorry, put up a PR that doesn't even build LOL
2017-07-05 19:04:17 +00:00