128 Commits

Author SHA1 Message Date
Adlai Holler
9cd0d58373
Rename ASDN C++ namespace to AS (#1366)
* Rename ASDN C++ namespace to "AS." Referring to the framework as ASDisplayNode is pretty out-dated and verbose. See CoreAnimation which usees CA for their internal namespace.

More using

* More cases
2019-03-09 12:14:58 -08:00
Adlai Holler
dd4359db7b
Optimize ASCATransactionQueue (#1350)
* Optimize ASCATransactionQueue. This queue is very busy, and it runs on the main thread so it's important for it to be fast.

Avoid waking up the run loop for every single node.
Avoid a ton of NSPointerArray overhead that we don't need.
Avoid retain/release traffic on the singleton by using an inline function. I confirmed that in release mode, the static __strong is correctly inlined and no ARC traffic is incurred.

* Comment

* Unlock right

* Remove magic number
2019-03-05 18:20:17 -08:00
Kevin
1410b29b63 Lock up to yogaRoot during layout to avoid deadlocks. (#1356)
* Lock up to yogaRoot during layout to avoid dead lock.

1) lock to root for tree
2) lock self to change parent (& consequently root)
3) Implement ASLocking (tryLock) on ASNodeController
4) add lockPair to try-lock node & controller together
5) lock controllers if they exist in lockToRoot...

Disable some asserts due to lock to root. :(

LL# No commands remaining.

* Add macro so non-Yoga still builds :)

* wut
2019-03-03 08:05:01 -08:00
Adlai Holler
6e7cdea797
Add extension points for global node behaviors, potentially replacing interface state delegates (#1229)
* Add extension points for global node behaviors via categories and a public ivar

* Update documentation on context ivar
2019-02-14 14:17:03 -08:00
Michael Schneider
d4efe95ec5
Improve separation of code for layout method types (#1305)
* Improve separation of code for layout method types

* Address PR comments

- Delegate to layout spec engine if the node is a layout spec node but yoga engine was asked for calculate the layout
- Change ASLayoutType to ASLayoutEngineType
- Improve layout engine fall through code
2019-01-28 07:41:49 -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
dmaclach
e59eff8aa0 Reduce startup time. (#1292)
Move file scope constant that is initialized at startup to function scope to avoid startup hit.
2019-01-15 08:56:43 -08:00
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