579 Commits

Author SHA1 Message Date
Garrett Moon
d70ab3e43c
[#trivial] I don't think we need this extra locked method. (#824) 2018-03-08 16:19:49 -08:00
Garrett Moon
63e1f4e9d9
Hopefully made this a bit more readabl. (#823) 2018-03-08 14:00:17 -08: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
Adlai Holler
8b431733d3
Avoid triggering main thread assertions in collection/table dealloc #trivial (#803)
* Avoid triggering main thread assertions in ASCollectionNode/ASTableNode dealloc

* Put it back
2018-02-13 12:02:30 -08:00
Huy Nguyen
e2478fc799
[ASDisplayNode layout] Fix an issue that sometimes causes a node's pending layout to not be applied (#792)
* [ASDisplayNode layout] Fix an issue that causes a node's pending layout to not be applied

- Since the implementation of layout version (#428), if a node's pending and calculated layouts have the same current version as well as the same constrained size, the 2 layouts are considered equal and can be used interchangeably. A layout version check between the 2 layouts was added in #695. This PR adds a missing constrained size check.
- If the pending layout has the same version but a different constrained size compare to the calculated layout's, we can assume that the pending layout is newer and should be preferred over the calculated one. That is because layout operations always register their new layout as pending, which then (immediately or eventually) get applied to the node as calculated layout.
2018-02-12 21:04:58 +00:00
Kevin Bui
f0f3f9acfe Add missing scrollViewWillEndDragging passthrough delegate (#796)
* Add scrollViewWillEndDragging delegate

* Make sure delegate can respond to scrollViewWillEndDragging

* Add changes to CHANGELOG.md
2018-02-12 11:38:20 -08: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
Huy Nguyen
b4a269aabf
[ASDisplayNode] Always return the thread-safe cornerRadius property, even in slow CALayer rounding mode (#749)
- Failing to do so will introduce race conditions in which the property was updated on a background thread but main thread has not executed the block that updates the property of the node's layer. During that window, the layer's property is out-of-date and can't be used.
- After this change, ASDisplayNode's cornerRadius is the only source of truth and users must always use it instead of CALayer's.
2018-02-08 17:08:04 +00:00
Michael Schneider
600b6cb76d
Fix ASTextNode2 is accessing backgroundColor off main while sizing / layout is happening (#794) 2018-02-08 08:28:14 -08:00
Adlai Holler
c6454214ac
Retain the reference color space (#784) 2018-02-02 10:36:17 -08:00
Michael Schneider
38b76e0eb2
Improve nullable annotations for _ASDisplayLayer and _ASDisplayView (#780) 2018-02-01 08:44:47 -08:00
Vladyslav Chapaev
0f061b401e node tint color fix (#764) 2018-02-01 06:43:46 -08:00
Adlai Holler
0c4ccc5253
Improve ASNetworkImageNode delegate callout behavior (#778)
* Improve ASNetworkImageNode delegate callout behavior

* no message
2018-01-31 12:18:04 -08:00
Alex Hill
0bb53552b0 [ASCellNode] focusStyle mapping (#727)
* [ASCellNode] Adds mapping for UITableViewCell focusStyle

* Update CHANGELOG.md
2018-01-31 10:07:08 -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
Denis Morozov
511bec63a2 Fix capturing self in the block while loading image in ASNetworkImageNode (#777)
* Fix capturing self in the block while loading image in ASNetworkImageNode

* Restore re-strongify while switching on the main thread

* Update CHANGELOG.md
2018-01-31 10:20:00 -05: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
fef965f78e
Add support for providing additional info to network image node delegate (#775)
* Add support for piping arbitrary user info from ASImageDownloader to the ASNetworkImageNodeDelegate

* s/source/sourceType

* Fix stuff and take Michael's advice
2018-01-30 17:50:38 -05:00
Michael Schneider
196d76d82d
Expose asyncdisplaykit_node in _ASDisplayView same as in _ASDisplayLayer #trivial (#773)
* Expose asyncdisplaykit_node in _ASDisplayView same as in _ASDisplayLayer

* Change comment
2018-01-30 14:24:46 -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
Adlai Holler
c3ae4474d0
NoCopyRendering experiment: Fix possible memory leak if image node rendering is canceled #trivial (#765)
* Fix memory leak if image node rendering is canceled

* Update comment
2018-01-23 10:45:34 -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
Huy Nguyen
2e98588372
[ASDisplayNode] Don't force a layout pass on a visible node that enters preload state (#751)
- After #706, a layout pass is forced on an ASM-enabled node that enters preload state to make sure that its subnodes can start preloading as well. However, when the node is visible, a (coalesced, thus more efficient) layout pass will be triggered by CA soon anyways, so rely on it instead.
2018-01-17 15:35:02 +00:00
Yevgen Pogribnyi
a3136b0225 [ASTraitCollection] Add missing properties to ASTraitCollection (#625)
* [ASTraitCollection] Add missing properties to ASTraitCollection

* ASTraitCollection now completely reflects UITraitCollection

* Add ASContentSizeCategory enum that corresponds to
  UIContentSizeCategory and can be used inside a struct.

* * Remove enum ASContentSizeCategory.
* Use __unsafe_unretained UIContentSizeCategory instead of the enum.

* Added ASPrimitiveTraitCollection lifetime test

* Changes requested at code review:
* Restore one of the ASTraitCollection constructors with a deprecation notice.
* Clean up API by the separation of tvOS-specific interfaces.
* Use [NSString -isEqualToString:] for ASPrimitiveContentSizeCategory equality tests for better readability.
* Encapsulate fallback logic for UIContentSizeCategoryUnspecified.

* Fix failing test
2018-01-16 18:08:29 +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
1d105c2056
Add an experimental "no-copy" renderer (#741)
* Add "ASGraphicsContext" to skip copying our rendered images

* Zero the buffer before making a context

* Update license header

* Update dangerfile

* Make it a runtime flag

* Restore GState for good measure

* Free buffer if end without image

* Enable the experiment, and cut out the middle-man

* Fix typo
2018-01-13 19:19:08 -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
appleguy
131619de96
Reimplement ASRectTable using unordered_map to avoid obscure NSMapTable exception. (#719)
* Reimplement ASRectTable using unordered_map to avoid obscure NSMapTable exception.

The new class is called ASRectMap, which patterns alongside ASIntegerMap in both name and implementation.

After some pretty detailed investigation, including study of open-source reimplementations
of Foundation, the best lead I've found on the NSMapTable exception is that
some NSPointerFunction types are not fully supported. Strangely, the ones being used
do seem to work fine almost all of the time.

The main concern is the Struct memory type, which is not officially re-declared in
NSMapTable, and as such the documentation claims that there may exist some
combinations of NSPointerFunction that are not supported.

Because the exception is occurring frequently enough to be a concern (in the hundreds
to low thousands, though only 50 a day) - I decided to replace NSMapTable entirely
in order to ensure full correctness.

"*** -[NSMapTable initWithKeyPointerFunctions:valuePointerFunctions:capacity:] Requested configuration not supported."

* Fix Xcode project
2017-12-21 16:17:25 -08:00
John T McIntosh
fff5aae0a5 Add support for toggling logs off and back on at runtime #trivial (#714) 2017-12-20 12:49:09 +00: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
Garrett Moon
46d46fdf12
#trivial Fixes image nodes being stuck not being able to download image (#720)
* #trivial Fixes image nodes being stuck not being able to download image

* Clear out the _cacheUUID too even though this is not strictly necessary.
2017-12-18 15:15:29 -08:00
Huy Nguyen
5a4d569c56
Ensure an ASM enabled node applies its pending layout when enters preload state (#706)
This makes sure subnodes are inserted and start preloading right away, instead of waiting until the next layout pass of the supernode. Fixes #693.
2017-12-08 18:30:26 +00:00
Garrett Moon
008a1ce208
Revert Adds support for specifying a quality indexed array of URLs (#699)
* Revert "Adds support for specifying a quality indexed array of URLs (#557)"

This reverts commit 3c77d4a5da44c46c7b80b2a627c95389b7d6352d.

* Add CHANGELOG entry
2017-12-05 13:55:19 -08:00
Garrett Moon
0b6d41f872
A couple performance tweaks for animated images #trivial (#634)
* A couple performance tweaks for animated images

* @nguyenhuy's comments

* Avoid calling animatedImageData twice. Thanks @maicki.

* Fix call to background deallocation

* Good catch by @Adlai-Holler
2017-12-04 14:56:04 -08:00
Adlai Holler
0dc7002f0b Add unit tests for the layout engine (#424)
* Build testing platform & tests for the layout engine

* Add our license header to debugbreak.

* Remove thing

* Address review comments

* Beef up the logging

* Update -[ASLayout isEqual:]

* testLayoutTransitionWithAsyncMeasurement passes now

* Disable testASetNeedsLayoutInterferingWithTheCurrentTransition

* Fix build errors
2017-12-01 17:05:47 +00:00
Huy Nguyen
bccde6cf0f
[ASScrollNode] Fix small bugs and add unit tests (#637)
* Add unit tests for ASScrollNode

* Make sure ASScrollNode's size is clamped against its size range

* Invalidate ASScrollNode's calculated layout if its scrollable directions changed

* Update comment

* Update CHANGELOG

* Address Adlai's comments
2017-12-01 15:41:06 +00:00
Huy Nguyen
b01fac35b6
[ASDisplayNode+Layout] Ensure a pending layout is applied once (#695)
Before:
  - Even if a pending layout was applied before, it'll be unnecessarily applied again in next layout passes and cause `-calculatedLayoutDidChange` being called multiple times.

After:
  - If a pending layout was applied, the calculated layout will not be ignored but reused, if possible, in next layout passes.

Test plan: testSetNeedsLayoutAndNormalLayoutPass in #424.
2017-12-01 13:11:17 +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
huang-kun
e4b2c05c21 [ASCornerLayoutSpec] New layout spec class for declarative corner element layout. (#657)
* Add new layout spec class with snapshot testing. Update examples and CHANGELOG.md

* Code review updates.

* Open curly bracket in a new line.
2017-11-24 13:45:59 +00:00
Max Wang
b2539d3531 Bugfix/fix yoga logging aligning api changes (#668)
* fix SIMULATE_WEB_RESPONSE not imported #449

* Fix logging message for new api
2017-11-21 13:34:21 +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
Adlai Holler
944cad6ed6
Make the framework backwards compatible with Xcode 8 (#650)
* Make the framework backwards compatible with Xcode < 9

* Update changelog
2017-10-31 16:11:57 -07:00
Garrett Moon
255682da3d Fix a layout deadlock caused by holding the lock and going up the tree. (#638)
* Fix a layout deadlock caused by holding the lock and going up the tree.

* Add CHANGELOG message

* Huy's comments
2017-10-31 15:36:01 +00:00