120 Commits

Author SHA1 Message Date
ricky
9cf54e8e8b [ASDisplayNode] Propagate traits before loading a subnode (#1234)
https://github.com/TextureGroup/Texture/pull/886 enforces that some nodes are loaded before they are sent a visiblity event, but it was not propagating the trait collection before forcing the load.

We are propagating traits in `_setSupernode:` (which was happening after the forced load). I moved the possible forced load to `_setSupernode:`, after propagating traits but before any visibility states are changed.
2018-11-19 17:53:00 -08:00
Michael Schneider
53368a5cb6
Remove CHECK_LOCKING_SAFETY check (#1225)
Locking assertions are always active now
2018-11-09 07:31:28 -08:00
Adlai Holler
5c9815f46d
ASThread: Remove Locker, Unlocker, and SharedMutex (#1213)
* ASThread: Remove Locker, Unlocker, and SharedMutex

* Remove extra line

* Kick the CI

* Move C++ down

* Fix thing
2018-11-05 13:26:36 -08:00
Michael Schneider
a34f45355e Revert #1023 (#1204)
We will revert #1023. The current solution introduces problems if we are unlocking before calling _completePendingLayoutTransition. _completePendingLayoutTransition needs to be happening in one transaction if called from _u_measureNodeWithBoundsIfNecessary.
2018-11-03 12:32:15 -07:00
Michael Schneider
ecfc7835da
Add experiment flag to skip layoutIfNeeded in enterPreloadState for ASM nodes (#1201) 2018-11-03 09:44:42 -07:00
Michael Schneider
8822bae0d5
Follow up cleanup #trivial (#1203)
* Remove whitespace at the end of the line

* Fix indentation

* Wrap if check for assertion in ASDISPLAYNODE_ASSERTIONS_ENABLED

* Add testTextNodeSwitchWorksInMultiThreadEnvironment tests
2018-11-02 07:54:15 -07:00
Max Wang
14681c00c4 Assert node did load before did enter visible way 1 (#886)
* fix SIMULATE_WEB_RESPONSE not imported #449

* Fix to make rangeMode update in right time

* access layer to load node before enter visible

* revert space
2018-10-24 12:58:57 -07:00
Jia Wern Lim
e6964d1ade [ASDisplayNode] Expose default Texture-set accessibility values as properties (#1170)
* Expose default Texture-set accessibility values as properties in ASDisplayNode.

Added relevant overrides and tests.

* Quick style fixes & add default a11y overrides to ASTextNode too.
2018-10-19 07:39:21 -07:00
Michael Schneider
b11ce52e9c
Add way to suppress invalid CollectionUpdateExceptions (#1173) 2018-10-18 09:35:36 -07:00
Michael Zuccarino
9588692361 Clean up timing of layout tree flattening/ copying of unflattened tree for Weaver (#1157)
* Simpler Huy fix for more efficient delayed flattening of the layout tree

* Nit

* Remove pbx changes

* Update CHANGELOG.md

* Add note about change in timing of _flattenedLayout capture
2018-10-03 14:49:15 -07:00
Eric Jensen
696f344301 Fix compilation warnings #trivial (#1132)
* Apply recommended warnings

* Squelch designated initializer warning in ASViewController

* Remove unused compiler flag

clang: warning: argument unused during compilation: '-fno-objc-arc-exceptions' [-Wunused-command-line-argument]

* Fix warning about overriding an instance variable within a category

Instance method 'methodOverrides' in category from _ASDisplayView.o overrides method from class in ASDisplayNode.o
2018-09-20 07:54:10 -07:00
Adlai Holler
ceed2d2008 Remove reliance on shared_ptr for ASDisplayNodeLayouts (#1131)
* Remove reliance on shared_ptr for ASDisplayNodeLayouts

* Fix up

* Fix in yoga

* Back to let

* Returns inner pointer

* Trivial change to kick the CI
2018-09-19 11:23:19 -07:00
Adlai Holler
9bcafefa33
Remove use of NSHashTable for interface state delegates #trivial (#1122)
* Remove use of NSHashTable for interface state delegates #trivial

* Stray line

* One more case

* Add code to let people have more delegates

* Do it more
2018-09-17 14:29:22 -07:00
Adlai Holler
fa8da15e69
Don't copy onDidLoadBlocks #trivial (#1123) 2018-09-17 12:40:18 -07:00
Max Wang
bf8d268573 Interface state not update correctly during layer thrash. (#1111)
* 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

* Revert "Fix collection cell editing bug for iOS 9 & 10"

This reverts commit 06e18a10596622ff8a68835c95a23986d7bf61ea.

* Fix interface state not update correctly during layer thrash

* add change log
2018-09-17 10:11:04 -07:00
Max Wang
1f0a213fe9 Fix layer backed nodes not update properly (#1110)
* 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

* Do not cancel on exit, interface state update should handle it.

* Revert "Fix collection cell editing bug for iOS 9 & 10"

This reverts commit 06e18a10596622ff8a68835c95a23986d7bf61ea.

* add space to trigger ci

* add change log
2018-09-14 15:25:27 -07:00
Michael Schneider
f759d5cc7d
Improve locking around clearContents (#1107)
* Improve locking around clearContents

* Add changelog
2018-09-14 08:48:19 -07:00
Max Wang
69ab24bc00 Make interface state delegate non optional (#1112)
* 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

* Revert "Fix collection cell editing bug for iOS 9 & 10"

This reverts commit 06e18a10596622ff8a68835c95a23986d7bf61ea.

* Make interface state delegate protocol non-optional.

* add change log

* add missing removal

* add required method to ASNodeController

* fix indentation

* Update CHANGELOG.md
2018-09-12 09:48:39 -07:00
Adlai Holler
395fbd1302 Reuse interface state delegates when calling out #trivial (#1099)
* Reuse interface state delegates when calling out instead of always copying
2018-09-05 22:52:41 -07:00
Max Wang
eba4e290a5 Allow to add interface state delegate in background. (#1090)
* fix SIMULATE_WEB_RESPONSE not imported #449

* Fix to make rangeMode update in right time

* remove uncessary assert

* Allow to add interface state delegate in background threads.

* Allow to add interface state delegate in background threads.

* lock around _interfaceStateDelegates

* lock _interfaceStateDelegates to local variable

* Fix comments

* remove extra spaces
2018-08-31 13:16:55 -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
Adlai Holler
c5b1d09b49
Remove direct ivar access on non-self object to fix mocking case #trivial (#1066)
* Remove direct ivar access on non-self object to prevent issues when the object is actually a mock

* Comment

* Remove lock to avoid deadlock risk
2018-08-03 16:35:24 -07:00
Michael Schneider
9e2947e7fb
Revert "Optimize drawing code + add examples how to round corners (#996)" (#1055)
This reverts commit eb4c21c54540d2c1c0b63a6b0665a77fea810e6c.
2018-07-31 04:40:18 -07:00
Michael Schneider
eb4c21c545 Optimize drawing code + add examples how to round corners (#996)
* Use CoreGraphics for drawing and cropping of node content

* Smaller fixes
2018-07-26 09:44:10 -07:00
Michael Schneider
b1f6030e86 Create and set delegate for clip corner layers within ASDisplayNode (#1029)
* Create and use ASDisplayNodeCornerLayerDelegate

* Return kCFNull for actionForLayer:forKey:
2018-07-18 02:56:37 -07:00
Huy Nguyen
0dc97fbb2f
Stricter locking assertions (#1024)
- Rename `ASDisplayNodeAssertLockUnownedByCurrentThread` to `ASAssertUnlocked`, and `ASDisplayNodeAssertLockOwnedByCurrentThread` to `ASAssertLocked` -> shorter and hopefully easier to distinguish between the two.
- Add assertions to `_locked_` and `_u_` (i.e "unlocked") methods.
- Turn `CHECK_LOCKING_SAFETY` flag on by default. After #1022 and #1023, we're in a good shape to actually enforce locked/unlocked requirements of internal methods. Our test suite passed, and we'll test more at Pinterest after the sync this week.
- Fix ASVideoNode to avoid calling `play` while holding the lock. That method inserts a subnode and must be called lock free.
- Simplify `_loaded(node)` to only nil-check `_layer` because regardless of whether the node is view or layer backed, the layer should always be set if loaded. Use it throughout.
- Other minor changes.
2018-07-13 14:58:16 -07:00
Adlai Holler
af7f71f92d
Address warnings in Xcode >= 9.3 about using %zd for NSInteger (#1026) 2018-07-13 11:56:54 -07:00
Adlai Holler
7c1aee7315
Fix i386 build by providing fallbacks to thread_local variables (#1025) 2018-07-12 21:09:24 -07:00
Huy Nguyen
5ffcd405c6
Fix misleading/scary stack trace shown when an assertion occurs during node measurement (#1022)
- Currently, there is a pair of mutex unlock and unlock that wraps around `-_u_measureNodeWithBoundsIfNecessary:` in `__layout`. That is because this method must be called without the lock.
- When an assertion occurs within that method, the runtime bails early without reacquire the lock (so the lock is free now). However, the runtime then hits the end of the outmost mutex locker scope and tries to release the lock that it no longer holds, causing another assertion in ASThread to be shown to user (#932). This makes it extremely hard to idenfity the root assertion.
- Fix by replacing the unlock/lock pair with a mutex unlocker.
2018-07-12 11:25:35 -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
Michael Schneider
6c487dd26c
Properly consider node for responder methods (#1008)
* Properly consider node for responder methods

* Add changelog
2018-07-06 08:32:03 -07:00
Garrett Moon
a4f78ad3e0
Adds support for having multiple interface state delegates. (#979)
* Adds support for having multiple interface state delegates.

Hopefully in a performant way.

* Switch to respondsToSelector for int del instead of separate object

* Add CHANGELOG

* Make ASDisplayNode+InterfaceState.h public

* Huy's comments

* Don't even bother removing since it's a weak hash table.
2018-06-27 16:52:40 -07:00
Adlai Holler
f6c5dc31e2
Generalize the main thread ivar dealloc stuff (#959) 2018-06-07 09:41:58 -07:00
Adlai Holler
35d59acd83
Add support for acquiring multiple locks at once (#958)
* Add ASLocking which supports -tryLock and taking multiple locks safely

* Better multi locking

* Assert about lock set capacity
2018-06-05 12:31:30 -07:00
Max Wang
06358d8662 Fix pager node for interface coalescing (#877)
* fix SIMULATE_WEB_RESPONSE not imported #449

* Fix to make rangeMode update in right time

* Fix pager node for interface coalescing

* Fix typo

* change log
2018-05-19 13:52:30 -07:00
Huy Nguyen
970ebd987e
Improve thread-safety of ASDisplayNode's didExitHierarchy #trivial (#916)
Since `didExitHierarchy` is called without the node's instance lock being held, the lock must be acquired before accessing `pendingInterfaceState`.
2018-05-11 17:26:00 +01:00
Max Wang
41473844f4 access view first before checking canBecome/Resign responder in becomeResponder methods (#829)
* fix SIMULATE_WEB_RESPONSE not imported #449

* Fix to make rangeMode update in right time

* Access view first before check canBecomeFirstResponder.
2018-03-29 10:01:11 -07:00
Max Wang
df7d2a5737 Disable interface coalescing (#862)
* fix SIMULATE_WEB_RESPONSE not imported #449

* Fix to make rangeMode update in right time

* disable interface coalescing and fix tests

* Revert to before coalescing for ease of reading

* refactor, make min change

* refactor

* add comments

* Add change log
2018-03-28 18:29:05 -07:00
Yevgen Pogribnyi
7f01b89ddc [ASDisplayNode] Provide safeAreaInsets and layoutMargins bridge (#685)
* [ASDisplayNode] Add safeAreaInsets, layoutMargins and related properties to ASDisplayNode

* Add layoutMargins bridged to the underlying view

* Add safeAreaInsets bridged to the underlying view

* Add fallback calculation of safeAreaInsets for old iOS versions

* Add automaticallyRelayoutOnSafeAreaChanges and automaticallyRelayoutOnLayoutMarginsChanges properties

* Add additionalSafeAreaInsets property to ASViewController for compatibility with old iOS versions

* Provide safeAreaInsets for layer-backed nodes.

This also fixes tests.

* Fix crash when insetsLayoutMarginsFromSafeArea is set from a background thread

* Changes requested at code review:
* Update documentation for layoutMargins and safeAreaInsets properties. Suggest that users set the automaticallyRelayout* flags to ensure that their layout is synchronized to the margin's values.
* Fix accessing ASDisplayNode internal structures without a lock.
* Add shortcut in -[ASDisplayNode _fallbackUpdateSafeAreaOnChildren] to skip a child when possible.
* Add shortcut in ASViewController to avoid fallback safe area insets recalculation in iOS 11. Fix fallback safe area insets recalculation when the additionalSafeAreaInsets are set.
* Add debug check that a view controller's node is never reused without its view controller, so the viewControllerRoot flag value is always consistent.
* Use getters instead of reading ivars directly in -layoutMarginsDidChange and -safeAreaInsetsDidChange.

* Minor change in CHANGELOG

* Minor change in ASDisplayNodeTests.mm
2018-03-27 14:29:17 +01:00
Adlai Holler
27fac9f586
Create a centralized configuration API (#747)
* Update the dangerfile

* Make a trivial change to test new dangerfile

* Try out the new value with another trivial change

* Add a configuration API to make a unified place for pulling config from clients safely

* Specify properties for delegate

* Finish removing text experiment global enable

* Generate the config file

* Clean up configuration to fix tests

* Work on making it serializable

* Finish it up

* Fix example code

* Update sample project

* Clean up a few things

* Align with new project order

* Make it faster and update license header

* Add an option to specify your config at compile time

* Update another license header

* Add a version field, and bring interface state coalescing into configuration

* Update CA queue code

* Update CATransactionQueue tests

* Turn transaction queue on by default (for now, see comment)

* Update the tests

* Update the tests AGAIN

* Remove unused ordered set
2018-03-25 12:52:57 -07:00
Adlai Holler
0f9b1e6789
Make objects conform to NSLocking (#851)
* Make display node, layout spec, and style conform to NSLocking so that users/subclasses can access their locks

* Update the changelog

* Align slashes

* Put it back, when we're in ASDisplayNode

* Go a little further

* Put back the changes I didn't mean to commit

* Kick the CI

* Fix yoga build

* Put back non-locking change

* Address comments from Scott
2018-03-25 10:46:04 -07:00
Adlai Holler
2b12654810
Use NS_RETURNS_RETAINED macro to save time (#843)
* Use NS_RETURNS_RETAINED macro to save time

* Update changelog and do the thing with the license headers
2018-03-21 08:13:09 -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
Adlai Holler
a1055254f7
Replace pthread specifics with C11 thread-local variables (#811)
* Replace pthread specifics with C11 thread-local variables for speed and safety

* Increment changelog
2018-02-28 12:42:30 -08:00
appleguy
223f1c9a36 [ASDisplayNode] Consolidate main thread initialization and allow apps to invoke it manually instead of +load. (#798)
* - [ASDisplayNode] Consolidate main thread initialization and allow apps to invoke it manually instead of +load.

Additionally this has a few minor fixes for Yoga support, and adds some basic
but universally valuable callbacks like -nodeDidLoad to ASNodeController.

* Small fix for handling _layoutVersion.

* Remove poking the scale accessor
2018-02-25 22:15:40 -08:00
Michael Schneider
236cdd799c
Fix UIResponder handling with view backing ASDisplayNode (#789)
* Add failing tests

* Fix responder chain handling in Texture

* Add mores tests that horrible fail

* Add Changelog.md entry

* Some fixes

* Update logic

* Add tests that prevents infinite loops if a custom view is overwriting UIResponder methods

* Add macro to forward methods in ASDisplayNode

* Add macro for forwarding responder methods in _ASDisplayView

* Remove junk

* Address first comments

* Update _ASDisplayView to cache responder forwarding methods

* Use XCTAssertEqual
2018-02-23 09:10:09 -08:00
Max Wang
2618c50073 New runloop queue to coalesce Interface state update calls. (#788)
* fix SIMULATE_WEB_RESPONSE not imported #449

* Coalesce interface state updates to ASCATransactionQueue before CATransaction commit.

This will avoid duplicate interface state delegate calls caused by view repeatly added/removed to/from hierarchy during controller animation transition.

* fix tests for new run loop queue

* Support for disabling ASCATransactionQueue

* Fix didExitHierarchy to use ASCATransactionQueue.

* merge range managed and none range managed for didExitHierarchy

* Revert "merge range managed and none range managed for didExitHierarchy"

This reverts commit f807efaa65ed5dbdb6622d06da542e01a53715fa.

* merge range managed and none range managed for didExitHierarchy

* remove metadata

* abstract queue to impl class methods

* Add tests

* Fix test fail because of shared object.

* guard _pendingInterfaceState access with lock

* name refactor

* Refactor from comments https://github.com/TextureGroup/Texture/pull/788/\#pullrequestreview-94849919

* Apply InterfaceState immediately after ASCATranactionQueue is processed and before next runloop started.

* refactor

* no op to start CI build

* remove unused var and kick off tests

* change lisence

* remove code for weak ref

* add change log and adjust license
2018-02-13 12:10:20 -08:00
Huy Nguyen
ea547270f2
[ASDisplayNode] Force a layout pass on a visible node as soon as it enters preload state (#779)
This reverts commit 2e9858837251cf16c9ffd19ba2eaeaa1012c8977 (#751).

The reason we can't wait for the coming CA's layout pass is that cell node visibility events occur before the pass, at which time the cell's subnodes don't have correct frames for impression tracking.

The root cause of this problem is that, right now, cell node visible states are set by ASRangeController well before the layout pass of the hosting collection/table view. That means we're "jumping the gun". The more I think about this, the more I agree with @Adlai-Holler that we need to treat visible state differently. That is, a node should only be visible (and thus get visibility events) after it's fully loaded, it's view/layer attached to the hierarchy and laid out by a CA transaction. In other words, at the end of the CA layout pass. Such change needs time and effort to be thoroughly reviewed and tested. Until then, let's roll with this fix.
2018-01-31 15:35:14 +00:00
Michael Schneider
20e31f7d70
Fix synchronous state of node if +viewClass or +layerClass is overwritten #trivial (#776)
* Fix synchronous state of node if +viewClass is overwritten

* Also check for _layerClass overwrite for synchronous flag

* Update some code style
2018-01-31 07:07:38 -08:00
Adlai Holler
2e94bb8120
Improve no-copy rendering experiment, remove +load method (#771)
* Improve graphics contexts experiment

* Update changelog

* Remove extra space

* Add a unit test for screen scale

* Fix typo and use unique value
2018-01-30 14:18:37 -05:00