271 Commits
Author SHA1 Message Date
Gabriel Liévano f8d91810fb Make ASInternalHelpers public (#2114) 2024-07-31 09:21:01 -07:00
Andy Finnell e9bd484149 Update to Xcode 15 (#2107)
* Update to Xcode 15

## Summary

We want to make Texture build with recent tools like Xcode 15. Part of this is bumping the minimum supported OS to iOS 14.

I only removed the dead code (i.e. code gated on versions older than iOS 14). There are still some warnings about outdated APIs in use, but they are non-trivial changes to fix.

## Test plan

Run all the examples. Run all the unit tests and make them pass.

* Use Xcode 15.3 so we have 17.4 simulators

* Fixing an asset catalog compiler error when building against iPhone SE

* Fix a couple of file extensions for assets

A couple of PNGs were marked as JPGs
2024-05-21 13:04:39 -04:00
ricky 50426db996 Bring back ASInitializeFrameworkMainThread so we don't break the API (#2050)
In PR 2032 we added alloc/dealloc texture initialization methods for the case where texture is automatically initializing. However, in doing so we have removed the `ASInitializeFrameworkMainThread` method that clients may already be using.

This PR brings back the `ASInitializeFrameworkMainThread` to live side by side with `ASInitializeFrameworkMainThreadOnConstructor` and `ASInitializeFrameworkMainThreadOnDestructor`. This should keep the old functionality in place for any client using `ASInitializeFrameworkMainThread` directly.
2021-12-06 14:32:22 -08:00
David Ha 053688bfb2 Xcode 13 ASLoadFrameworkInitializer dead lock fix on running unit test (#2032)
* replace destructor for after main execute

* separate ASLoadFrameworkInitializer between constructor and destructor

* AS_EXTERN -> ASDK_EXTERN

* initialSetNeedsDisplayCount should be called once on iOS 15

* Loaded node of contentsScale must be 2.0 on layer backed

* initialSetNeedsDisplayCount must called once
2021-12-03 09:32:05 -08:00
ricky 18d805f523 [RTL/Batching] Make ASDisplayShouldFetchBatchForScrollView aware of flipped CV layouts (#1985)
* [RTL/Batching] Make ASDisplayShouldFetchBatchForScrollView aware of flipped CV layouts

UICollectionViewLayout has a property called `flipsHorizontallyInOppositeLayoutDirection`. If this is set to `YES` then a RTL collectionView’s contentOffset behaves like it does in LTR. In other words, the first item is at contentOffset 0. In this case, the existing logic for `ASDisplayShouldFetchBatchForScrollView` works in RTL.

If you don’t override `flipsHorizontallyInOppositeLayoutDirection` to be `YES`, then it means that in RTL languages the first item in your collectionView will actually be at x offset `collectionView.contentSize.width - collectionView.frame.size.width`. As you scroll to the right, the content offset will decrease until you reach the end of the data at a content offset of 0,0. In this case, `ASDisplayShouldFetchBatchForScrollView` needs to know that you are in RTL and the layout is not flipped. It can then use the contentOffset as the `remainingDistance` to determine when to fetch.

* fix indentation

* assert that we are on main when accessing CV layout
2021-05-03 13:32:48 -07:00
ricky 8912ff1765 [Layout] Add RTL support to LayoutSpecs (#1983)
* [Layout] Add RTL support to LayoutSpecs

This is largely a slight update for https://github.com/TextureGroup/Texture/pull/1805. If RTL is enabled, `calculateLayoutLayoutSpec:` will flip the origin of all sublayouts.

The new part of the diff is that ASBatchFetching now supports proper fetching on RTL horizontal scrollViews.

* Fix build and add RTL batch fetching tests
2021-04-14 11:20:42 -07:00
Sylvain Defresne 39ea9fe2f2 Remove trailing semicolons between method parameters and body (#1973)
Having a semi-colon between a method parameters list and a method
body is not not correct and is usually caused by a copy and paste
error while creating the method definition from its declaration.

Fixes the following compilation warnings when building with
-Wsemicolon-before-method-body (which is part of -Wextra):

  ASPINRemoteImageDownloader.mm:230:85: error: semicolon before method body is ignored [-Werror,-Wsemicolon-before-method-body]
  - (id <ASImageContainerProtocol>)synchronouslyFetchedCachedImageWithURL:(NSURL *)URL;
                                                                                      ^
  ASPINRemoteImageDownloader.mm:275:76: error: semicolon before method body is ignored [-Werror,-Wsemicolon-before-method-body]
                           completion:(ASImageDownloaderCompletion)completion;
                                                                             ^
  2 errors generated.

Fixes applied to both code, examples and samples in documentation.
2021-03-26 11:07:31 -07:00
Zev Eisenberg 9e8de03845 Fix WKWebView Accessibility (#1955)
* Return nil instead of empty array when no accessibility elements are found. Fixes #1954.

* Use nullability annotations to fix static analyzer warnings.

* Add UI test target.

* Add UI test to make sure web view stays accessible.

* Revert "Add UI test to make sure web view stays accessible."

This reverts commit 00253f49a0af329602b0d9709b58bc92dcd90147.

* Revert "Add UI test target."

This reverts commit 288b5e0f564ef3ba3fb5568baa832bc03124cdc9.

* Add unit test to make sure accessibility elements are correct when a WKWebView is wrapped in an ASDisplayNode.
2021-02-03 13:24:39 -08:00
ricky 68a1bec062 [ASTextNode2] Make some ASTextNode2 layout files public (#1939)
* Trying to make ASTextLinePositionModifier public

* d’oh

* be a little more restrictive on the files we pull into the pod

* Never mind, I guess we need all of these

* update the project file as well

* try this again

* I think this will work this time.
2020-12-14 12:30:25 -08:00
Huy Nguyen ec19b928a8 Ship ASExperimentalDispatchApply (#1924)
Closes #1850.
2020-10-06 11:42:37 -07:00
Greg Bolsinga 9ef97f4965 Remove background deallocation helper code (#1890)
* Remove background deallocation helper code

Last use removed in Texture with #1840, now PINS no longer uses it either. Less OOMs is so nice.

* remove methods from docs
2020-07-30 12:02:46 -07:00
ricky f56a4dd1dd [Accessibility] Ship ASExperimentalDoNotCacheAccessibilityElements (#1888)
We did not notice any effect on performance of the Pinterest app by not caching `accessibilityElements` in `_ASDisplayView`. By not caching the elements, we can be sure that the elements will be correct even when nodes change visibility state. There will be a performance impact when voice over is enabled, but providing the correct elements for the current state of a view is more important than performance in this case.

https://github.com/TextureGroup/Texture/issues/1853
2020-07-23 15:21:07 -07:00
Garrett Moon c5f69f0b01 Renames AS_EXTERN and ASViewController (#1876)
* Renames AS_EXTERN and ASViewController

To ASDK_EXTERN and ASDKViewController.
This is to avoid conflicting with AuthenticationServices in
Xcode 12

* Fix up examples and docs

* Add bit about updating ASViewController rename
2020-06-29 12:49:59 -07:00
Garrett Moon dbb06bf58f Fix all the warnings and re-enable on CI (#1872) 2020-06-25 11:54:00 -07:00
ricky e16fdd67e1 [ASDisplayNode] Implement accessibilityElementsHidden (#1859)
Most of this code comes from an old PR that @fruitcoder put up https://github.com/TextureGroup/Texture/pull/795 2 years ago.

When creating our array of accessibilityElements, we need to respect the value of `accessibilityElementsHidden`. If the value of this property changes, we need to invalidate the cached accessibility elements (unless we are in the experiment that doesn’t cache `accessibilityElements`).

I created a simple test app and made sure this matched UIKit’s implementation. I also added a test case that changes the value of `accessibilityElementsHidden` and makes sure the proper accessibilityElements are returned.
2020-06-03 16:16:43 -07:00
ricky 08bd6f6e3b [ASDisplayNode] Implement accessibilityViewIsModal (#1858)
* [ASDisplayNode] Implement accessibilityViewIsModal

A PR to add support for `accessibilityViewIsModal` in `CollectAccessibilityElements`.

If in a list of subnodes more than 1 subnode has `accessibilityViewIsModal` marked as `YES`, then the node with the highest index in `subnodes` will be the one that is considered modal. This behavior matches UIKit.

If the value of `accessibilityViewIsModal` changes, we need to clear all the cached `accessibilityElements` from that view up. I added this in ASDisplayNode’s `setAccessibilityViewIsModal` method. Note that if we ship `ASExperimentalDoNotCacheAccessibilityElements` then we can remove the invalidation step.

Finally, I changed all the tests to ask the view for accessibilityElements, not the node. This is a better representation of what will really happen when UIKit asks a node’s view for its accessibility elements. It also allowed me to test that clearing the accessibilityElements was working.

* add some experiment checks

* fix tests and address jon’s comment

* Fix tests

* remove debug code
2020-06-01 12:58:44 -07:00
vovasty 74fd8f3d33 deprecate ASGraphicsCreateImageWithTraitCollectionAndOptions (#1836) 2020-05-22 20:15:09 -07:00
+19 aa91df7634 [IGListKit] Extended IGListKit support for displaying delegates (#1011)
* Extended IGListKit support for node deselect, highlight and unhighlight

* Proposal of renaming willDisplayItemWithNode and didEndDisplayingItemWithNode to be similiar to UICollectionView

* Extended support for IGListDisplayDelegate

* Updated changelog with displaying delegates change

* Removed extra deprecation supression flag

* Reverted ASCollectionNode changes and implemented displaing delegate with indexPathForNode:

* Sending a real UICollectionViewCell to the delegate if not nil

* Added safety check for nil indexPaths

* Discard any CHANGELOG changes for fix Danger error

* Add an experimental flag to use native dispatch_apply (#1345)

* Add an experimental flag to use native dispatch_apply instead of our core count * 2 approach. This has shown performance wins in some profiling.

* Add in other places

* Don't return non-animated GIFs for animation (update to latest PINRemoteImage beta) (#940)

* Don't return non-animated GIFs for animation

* Update to latest PINRemoteImage beta

* Fix typos  (#1348)

* Update containers-overview.md

* Update subclassing.md

* Update node-overview.md

ASImageNode, ASNetworkImageNode and ASMultiplexImageNode are in place of UIImageView, not UIImage.

* Revert "Have node and controller share lock (#1227)" (#1347)

This reverts commit 2baa9438d7.

* Don't compile out ASExperimentalTextNode if ASTextNode is compiled out (#1353)

* 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

* Update layout-transition-api.md (#1357)

* Optimize ASTwoDimensionalArrayUtils (#1351)

* Optimize ASTwoDimensionalArrayUtils

These methods are called on the main thread during range controller updates (i.e. every frame) and so they should be as fast as possible.

* Rename

* Use vector instead of stack array to handle really big cases (e.g. photos)

* If we check for batching before content size is available we'll always fetch (#1355)

* Do not lock the nodeController if we are not locking to root. (#1360)

Doing so leaves it locked when we elsewhere explicitly unlock the node to ascend.

* Resolve root constrained size before informing delegate to resolve infinite layout loop. (#1359)

* Add `setNeedsLayout` to yoga tree changes. (#1361)

* Make ASCollectionElement Public (#1303)

* Update AsyncDisplayKit.h

* Update project.pbxproj

* Optimize _assertSubnodeState (#1352)

* Optimize _assertSubnodeState

This method is actually pretty painful in today's world. In one iPad mini trace, the first page of nodes spent 6.6ms in this call, just in time profiler.

* Clean it up, check count

* Check the right value

* _ASCollectionViewCell - The point isn't converted before to send to node, impossible to touch button into the node hierarchy (#1362)

* Revert node call, useless, the node has a ASDisplayView, and this view forward on the node in first.

* Use convertPoint to convert the given point in hittest & pointInside methods.
Keep the standard usage if the node didn't rasterized a view.

* Removed isNodeLoaded, finally it's useless in this case
In these methods, we are on the mainThread, we can create the view if the view is not created.

* 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

* Cleanup Yoga Categories (#1364)

* Add forwarding of UIAccessibilityAction methods (#1344)

* Add forwarding of UIAccessibilityAction methods

* Use OCMock for testing UIAccessibilityAction method forwarding

* Don't add extraneous truncation token during kCTLineTruncationMiddle. (#1297)

* Don't add extraneous truncation token during kCTLineTruncationMiddle

* Expand these comments a little.

* Update the FAQ to throw less shade. (#1379)

* Update the FAQ to throw less shade.

Both of these technologies have their place, no point in being assholes.

* Update faq.md

* [Updated Snapshots] Don't add extraneous truncation token during kCTLineTruncationMiddle (#1375)

* Don't add extraneous truncation token during kCTLineTruncationMiddle

* Expand these comments a little.

* Update snapshot tests with beautiful correct behavior

* Launches switching ASNetworkImageNode callbacks to global queue. (#1369)

* Launches switching ASNetworkImageNode callbacks to global queue.

* Good catch configuration tests!

* Make ASTextNode2 more forgiving when searching for links (#1374)

* Make ASTextNode2 more forgiving when searching for links by searching a 44x44 square around the touch

* Trailing whitespace

* Safely handle end-of-line

* Experiment with different strategies for image downloader priority (#1349)

Right now when an image node enters preload state, we kick off an image request with the default priority. Then when it enters display state, we change the priority to "imminent" which is mapped to the default priority as well. This means that requests from preload and display nodes have the same priority and are put to the same pool. The right behavior would be that preload requests should have a lower priority from the beginning.

Another problem is that, due to the execution order of -didEnter(Preload|Display|Visible)State calls, a node may kick off a low priority request when it enters preload state even though it knows that it's also visible. By the time -didEnterVisibleState is called, the low priority request may have already been consumed and the download/data task won't pick up the new higher priority, or some work needs to be done to move it to another queue. A better behavior would be to always use the current interface state to determine the priority. This means that visible nodes will kick off high priority requests as soon as -didEnterPreloadState is called.

The last (and smaller) issue is that a node marks its request as preload/low priority as soon as it exits visible state. I'd argue that this is too agressive. It may be reasonble for nodes in the trailing direction. Even so, we already handle this case by (almost always) have smaller trailing buffers. So this diff makes sure that nodes that exited visible state will have imminent/default priority if they remain in the display range.

All of these new behaviors are wrapped in an experiment and will be tested carefully before being rolled out.

* Add imports

* Fix build failure

* Encapsulate common logics into methods

* Address comments

* Whoops, someone forgot an else! (#1385)

Luckily it seems this didn't cause huge memory bloat because there's
a check below that keeps the display flag from being set in low memory
conditions when the node is off the screen.

* Catch invalid sizes during yoga layout (#1376)

* Correct View vs. Layer here (tho it doesn't make any difference) (#1378)

Older FBSnapshot versions, however, don't use VerifyViewOrLayer

* Expose initial constrained size before layout in case anyone is interested later during the layout on the same thread. (#1377)

Optionally, clients are expected to clean it up after usage to avoid accessing outdated data.

* Assert for context creation failure during displayBlock. (#1373)

Nothing good can possibly happen if we continue without one.

* Fix an issue where state change notifications can be sent mulitple times. (#1372)

Before the change: both - (void)setShouldInvertStrongReference:(BOOL)shouldInvertStrongReference and - (void)setNode:(ASDisplayNode *)node will call through [self setupReferencesWithNode:node]; which call the [node addInterfaceStateDelegate:self];

* Add Yoga support to ASButtonNode (#1381)

* Add Yoga support to ASButtonNode

* Drop unowned ASLayoutElementStyle parameter

* Fix access of Yoga properties

* Move ASButtonNode Yoga logic to Category

* Update header

* Fix CTLineRef leaks (#1386)

Found by Clang Static Analyzer:

~/Texture/Source/ASTextNode2.mm:663:39: warning: Potential leak of an object stored into 'truncationTokenLine'
      CTLineRef truncationTokenLine = CTLineCreateWithAttributedString((CFAttributedStringRef)_truncationAttributedText);
                                      ^
~/Texture/Source/ASTextNode2.mm:666:49: warning: Potential leak of an object stored into 'additionalTruncationTokenLine'
      CTLineRef additionalTruncationTokenLine = CTLineCreateWithAttributedString((CFAttributedStringRef)_additionalTruncationMessage);
                                                ^
2 warnings generated.

* Correct attributes lookup for supplementary elements. (#1318)

* Need some more locks for working with calculated yoga layouts (#1388)

* Adds support for using UIGraphicsImageRenderer in ASTextNode. (#1384)

* Adds support for using UIGraphicsImageRenderer in ASTextNode.

In many cases this reduces the backing store of text nodes by 1/2.

* Guard for UIGraphicsRenderer availability.

* Comma

* Add UIDataSourceModelAssociation to ASTableView and ASCollectionView (#1354)

* Add UIDataSourceModelAssociation protocol conformance to ASTableView and ASCollectionView.

* Implementing review feedback from @Adlai-Holler

* 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

* Clean up a clang analyzer cast error (#1387)

~/Texture/Source/Private/ASMutableElementMap.mm:32:24: warning: Conversion from value of type 'NSMutableArray<NSMutableArray *> *' to incompatible type 'ASMutableCollectionElementTwoDimensionalArray *'
    _sectionsOfItems = (id)ASTwoDimensionalArrayDeepMutableCopy(items);
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

* Update for 9.4.1 CI (#1392)

* Remove experimental features (exp_skip_a11y_wait && exp_new_default_cell_layout_mode) (#1383)

* Remove experimental features

* prevent blocking main thread

* remove small content all together as none is the default

* Update ASExperimentalFeatures.h

* Make experiment checks faster (#1393)

* Make experiment checks use dispatch_once when not debugging, clean up singleton

* One more

* Pull out the variable

* Make shared CA transaction queue variable extern so it's actually shared (#1397)

* Fix header typo (#1402)

* Context is a pretty general name that will cause conflicts with subclasses (#1399)

* Suppress documentation warnings when using external libraries (#1401)

Fixes 1400

* Add layer-action support to nodes (#1396)

* Add layer-action support to nodes, unify hierarchy notifications on it

* Better pending state

* Fix bool

* Skip extra copy

* Never run default actions

* Continue the search

* Avoid an unnecessary lock & unlock pair in ASMainSerialQueue (#1409)

* Add clang-format for a common source code format (#1365)

* Add clang-format

* Update format to be as close as our current style

* Fix GIF Caching (#1405)

* Add support for reverse direction to yoga layouts (#1413)

* Add support for reverse direction to yoga layouts

* #ifdef YOGA yoga-specific additions

* oops

* Only set ASLayoutElementStyle delegate if Yoga is enabled (#1417)

* Fix bug in ASRangeController that causes some cell nodes of a collection view which is about to becomes invisible to load their backing view/layer and render (#1418)

* Fix a bug with Yoga nodes whose position change and don't update. (#1408)

* Follow up on the ASRangeController fix in #1418 (#1419)

The changes in #1418 is a bit too aggressive when it comes to nodes that are in display range. It forces those nodes to not preload.

Also update the changes to avoid diluting the experiment data by triggering too broadly (i.e avoid triggering when the old and new implementations yield the same result leading to no behavior change).

* Dev docs for threading in Texture (#1319)

* Getting started on adding threading by example

* writing writing writing

* more info

* More threading

* More more more

* Threading

* self lock

* Some language fixes

* Update docs/_docs/development/threading.md

Co-Authored-By: mikezucc <mikezuccarino@gmail.com>

* fix image references

* Removed locked jekyll version (#1322)

* showcase.md updated (#1421)

* Experiment with disabling ASViewController background dealloc (#1420)

* [Experiment] Dont forget about these collection view background deallocs (#1424)

* Dont forget about these collection view background deallocs

* Also Table view for completeness

* Fix retain cycle with transaction operations (#1429)

Add unit tests that help find cycles. `-testWeakWithSingleOperation` fails without the code fix applied.

* Replace +load initializers with __attribute__((constructor)) functions (#1425)

* Replace +load initializers with __attribute__((constructor)) functions

* Updating the documentation for textureDidInitialize, per @nguyenhuy

* Fix dealloc on bg (#1410)

* 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 06e18a1059.

* Fix dealloc long gesture in background

* Add support for clipping only specific corners, add unit tests (#1415)

* Add support for clipping only specific corners, add unit tests

* Remove some cleanup to make the diff smaller

* Fix

* [ASImageNode]fix incorrect backing size calculation (#1189)

* fix backing size for image node which content mode is scaleAspectFit

* chore: update comments and naming

* add change log

* Update CHANGELOG.md

* Update CHANGELOG.md

Co-Authored-By: junjielu <348649634@qq.com>

* add unit test for backing size calculation

* correct license

* Have image nodes draw into opaque contexts automatically if possible (#1432)

* Have image nodes draw into opaque contexts if the image is opaque and it fills the context

* Call backingSize once

* Fix typo in batch-fetching-api.md (#1437)

* [ASDisplayNode] Stop infinite layout in _u_measureNodeWithBoundsIfNecessary (#1434)

We came across an infinite layout loop in `_u_measureNodeWithBoundsIfNecessary`. After requesting a layout from above, the sizes between pending and caluclated layout still do not match. We continue to prefer to use the pending layout and ask for another layout loop from above. We can’t seem to break out of this loop. The solution (thanks to Huy for the guidance) was to nil out the pending layout we get from requesting the layout from above.

I was only able to reproduce this when working with a node in a `UINavigationBarItem’s` `titleView`. I think that UIKit must be doing something sneaky with setting the frame on the view. While I was not able to create a unit test to catch this issue (I tried for a long time, and can post what I’ve come up with to see if anyone has any suggestions), I was able to create a pretty simple example project that shows the behavior:
https://github.com/rcancro/TextureLayoutLoopExample

* Add a verbose log for locking operations. Has no effect in production (#1436)

* Add a verbose log for locking operations. Has no effect in production

* Need check

* Wrap transaction operation retain cycle fix in an experiment (#1438)

* Wrap transaction operation retain cycle fix in an experiment

This is a follow on to #1429.

* fix typo in experiment name. fix copyright in tests file.

* Fix scroll node in yoga (#1435)

* 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 06e18a1059.

* Fix child not fit to full scroll node's bounds when flex_grow = 1.0 is used on child

* Fix the stub for layerActionForKey: to let CA continue the search (#1441)

* Fix the stub for layerActionForKey: to let CA continue the search

* Kick CI

* Revert "Have image nodes draw into opaque contexts automatically if possible (#1432)" (#1443)

This reverts commit 28522ce977.

* Use instance lock for ASPrimitiveTraitCollection (#1442)

* Use instance lock for ASPrimitiveTraitCollection

* Remove the atomic

* Simplify ASTraitCollection propagation in ASViewController (#1447)

* Use AS::Mutex in ASCollectionElement (#1445)

* [ASTextNode] Maintain isAccessibilityElement setting on text nodes when updating text (#1326)

* Add didEnterHierarchy/didExitHierarchy to ASNodeController. (#1444)

* Fix wrongly formatted RELEASE link (#1453)

* Only create activities during debug (#1456)

* [#1451] Add support for UIAccessibilityCustomAction (#1452)

This PR adds support for UIAccessibilityCustomAction propagation through ASPendingState so that it can be picked up by VoiceOver.

* Shut down graphics contexts experiment (#1458)

* Shut down graphics contexts experiment

* Remove dead import

* Remove gone class

* Remove lock of ASTextNodeRendererKey (#1454)

* Remove lock of ASTextNodeRendererKey

* Remove class check for isEqual

* Add const specifier to function parameter

* Fixes typo

* Fixes typo

* Disable ASAssertLocked and ASAssertUnlocked (#1412)

* Try to remove global lock when initialising TextKit components (#1455)

* Try to remove global lock when initialising TextKit components

* Adding experiment flag to dis/enable lock of textkit component

* Adding tests

* code clean

fix typo

Make remove lock optional

Keep locks

code clean

* Make ASCollectionNode's pan gesture customizable (#1457)

* changes done

* complete set of uigesturedeleagte methods

* Remove iOS 8 support from logging code. (#1462)

* Drop support for Xcode 8 and fix some compiler warnings (#1463)

* Remove ASEventLog (#1460)

* Remove ASEventLog. We'll focus on ASLog for the future, possibly making it triggerable on a per-node basis

* See ya!

* Hello semicolon

* Remove refs to gone tree methods

* Fix

* Remove irrelevant change, kick CI

* Clean up

* Cover the other background dealloc surfaces (#1464)

* Passthrough pagingEnabled for ASCollectionNode / ASTableNode (#1466)

* Passthrough pagingEnabled for ASCollectionNode and ASTableNode

* Add tvOS handling

* Fix open context bug introduced in #1458 (#1468)

* Make sure all ASDisplayNode properties have backing ivars for consistency. (#1475)

* Make sure all ASDisplayNodes have backing ivars for consistency.

Found this by enabling #pragma clang diagnostic error "-Wobjc-missing-property-synthesis" for ASDisplayNode. One property is unused, saving 8 bytes of heap space per instance on 64-bit builds. Implement setter/getters for these properties, and add appropriate locking. add the warning as error to the build for this file.

* Ensure ASControlMode properties lock before accessing their ivars (#1476)

Enable `#pragma clang diagnostic error "-Wobjc-missing-property-synthesis"` for this file.

* Add a new "global drawing" experiment to use UIGraphicsRenderer (#1469)

* Add a new "global drawing" experiment to use UIGraphicsRenderer everywhere, when available

* Fix logic

* Use preferredFormat

* Cut version 2.8.1 (#1491)

* Clean up documentation issues around periods (#1490)

There were so unnecessary `'` around periods for some reason. Just deleting those because they are distracting.

* Minor update in change log #changelog (#1492)

* Ship ASExperimentalFixRangeController (#1486)

* Shrink _ASCollectionPendingState from 144 to 128 bytes, a 12.5% reduction (#1485)

* Shrink _ASCollectionPendingState from 144 to 128 bytes, a 12.5% reduction

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* address review comments. move enums out. add comment. rename struct to _flags

* fix a missing rename

* Shrink _ASPendingState from 824 to 808 bytes, reduction of ~2% (#1483)

* Shrink _ASPendingState from 824 to 808 bytes, reduction of ~2%

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Shrink ASPendingState BOOLs. Use unsigned int for these bitfields for clarity. Separate from `_flags` as that struct is compared to `0` for testing. The `_boolFlags` struct is just storing other `BOOL`s.

* rename struct fields as suggested in garret's review.

* Shrink ASDisplayNode from 1072 to 968 bytes, reduction of 10.74% (#1484)

* Shrink ASDisplayNode from 1088 to 976 bytes, reduction of 11.48%

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* Forgot to bit-field-ify placeholderEnable; new small size is 968, old size is 1072 (measured consistentlyl on iPhoneSE simulator). 10.74% reduction.

* Shrink Button Node (#1494)

Button: 1312 to 1288 bytes, running on iPhone SE simulator. 1.9% reduction.

Shrink the enums it stores, and place them next to each other (along with a BOOL) to reduce instance size.

* Shrink TextNode(2) (#1495)

Running in iPhone SE Simulator:
- ASTextNode: 1360 to 1352 bytes .6% reduction
- ASTextNode2: 1360 to 1304 bytes 4.3% redction

Shrink stored enum sizes. Group BOOLs near these smaller enums. Override -usingExperiment to return constant instead of never set, but allocated ivar.

* Shrink Pager and Scroll Node (#1496)

Running on iPhone SE Simulator:
ASPagerNode 1240 to 1232 bytes .7% reduction
ASScrollNode 1104 to 1096 bytes .7% reduction

- make ASScrollNode smaller by shrinking ASScrollDirection, which requires a change to ASRangeController
- shrink ASPagerNode by declaring the BOOL next to the struct

* Shrink ASImageNode by .6% and ASNetworkImageNode by 2.2% (#1487)

* Shrink ASImageNode by .6% and ASNetworkImageNode by 2.2%

ASImageNode goes from 1384 to 1376. ASNetworkImageNode goes from 1496 to 1464.

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* add comments as requested in garrett's review.

* access ivar directly since already locked as suggested in review.

* Remove unused declaration, missed in #1460 (#1497)

* Keep the atomics - does not affect memory work (#1498)

Revert "Ensure ASControlMode properties lock before accessing their ivars (#1476)"
This reverts commit ce1e1956f4.

Revert "Make sure all ASDisplayNode properties have backing ivars for consistency. (#1475)"
This reverts commit d6061f4390.
- Except the unused property `interfaceStateSuspended` is still removed (this is a memory saver).

* Shrink ASCellNode by 8 bytes (#1499)

Group the BOOLs together, since there are only 4 (and there are no other auto-generated ivars that are < 64 bits) this is sufficient and keeps the properties `atomic`.

* Shrink ASEditableTextNode by 16 bytes (#1500)

Just shuffle some BOOLs around and explicitly declare an ivar so it is grouped with the others.

* ASSignpost: Add support for the os_signpost API, fixes (#1501)

* ASSignpost: Add support for the os_signpost API

- Removes support for colored intervals. These weren't really useful and they aren't part of the signpost api.
- Fixes an issue with range controller interval logging.
- Adds an interval for interface orientation changes.

* Rename

* Support Xcode 9

* Commentary

* Shrink ASLayout (#1503)

- Shrink the enum. Save 8 bytes. There are 1000s of these in the heap after running Pinterest for 10 minutes.

* Cleanup whitespace #trivial (#1507)

(It's easier to deal with these as silly oneoffs IMO than to
have them conflated with real work)

* Shrink LayoutSpec classes (#1502)

- Resize enums to make `ASStackLayoutSpec` 40 bytes smaller. This applies to the subclasses too.

Co-authored-by: Adlai Holler <adlai@icloud.com>
Co-authored-by: Garrett Moon <garrett@pinterest.com>
Co-authored-by: dirtmelon <272485887@qq.com>
Co-authored-by: Michael Schneider <maicki@users.noreply.github.com>
Co-authored-by: Kevin <kevin@wode.com>
Co-authored-by: dirtmelon <0xffdirtmelon@gmail.com>
Co-authored-by: Jonathan Downing <jd@jonathandowning.uk>
Co-authored-by: Xavier Deloge <Idefix60@users.noreply.github.com>
Co-authored-by: Eric Scheers <smeis@users.noreply.github.com>
Co-authored-by: Huy Nguyen <allforone1511@gmail.com>
Co-authored-by: Greg Bolsinga <bolsinga@mac.com>
Co-authored-by: Jacob Farkas <farktronix@users.noreply.github.com>
Co-authored-by: ernestmama <43187788+ernestmama@users.noreply.github.com>
Co-authored-by: Andrew Yates <contact@andydev.co.uk>
Co-authored-by: Tim Norman <tim@normsoft.com>
Co-authored-by: Michael Zuccarino <mikezuccarino@gmail.com>
Co-authored-by: Dmitry Gridnev <dmitr.gridnev@gmail.com>
Co-authored-by: Max Wang <max.wang.cs@gmail.com>
Co-authored-by: Ballad <348649634@qq.com>
Co-authored-by: ricky <rickycancro@gmail.com>
Co-authored-by: Patrick Balestra <me@patrickbalestra.com>
Co-authored-by: Harry Shamansky <harry.shamansky@gmail.com>
Co-authored-by: Wu Zhong <zhongwuzw@qq.com>
Co-authored-by: Oskar Zhang <i@oskarzhang.me>
Co-authored-by: Adlai Holler <adlai@google.com>
Co-authored-by: Greg Bolsinga <gbolsinga@pinterest.com>
Co-authored-by: Huy Nguyen <huy@pinterest.com>
Co-authored-by: Andrew Monshizadeh <amonshiz+github@gmail.com>
2020-05-21 10:18:48 -07:00
Huy Nguyen cfaa55cdb4 Link to IGListDiffKit in our IGListKit subspec (#1756)
- In IGListDiff is no longer part of IGListKit as of 4.0. It has its own podspec now. After bumping our IGListKit dependency of our subspec, we got an "Undefined symbol: _IGListDiff" error which breaks podspec linting CI job (as well as some of our clients as reported in #1749).
- To fix it, we can either remove the IGListDiff dependency since it's used once in the entire project, or link to IGListDiffKit. I opt for the latter because I imagine many IGListKit users would have IGListDiffKit anyway so we can still take advantage of it (it's faster than our built in diffing algorithm). Plus, it's not a big dependency.
2020-01-03 11:55:11 -08:00
Craig Howarth b59c6d07e1 [ASCollectionLayout] Fix element lookup for supplementary attributes (#1707) 2019-12-23 16:17:14 -08:00
Hanton Yang 37e28300de Add copy sematic to userInfo in ASTextRunDelegate for avoiding mutation (#1719) 2019-11-12 10:42:05 -08:00
Hanton Yang 0ec2bece8f AS::Map function improvement (#1642)
* Prefer `reserve` rather than `fill constructor` in AS::map()

`fill constructor` constructs the vector with n elements and initializes each element with its default constructor. Instead, `reserve` just allocates memory, no element is initialized and put into the vector, so it's more effeicent. For example, after running the `result_type res(iterable.size());` statement, the `res` vector's size is equal to `iterable.size()`, but after running the `res.reserve(iterable.size());` statement, the `res` vector's size is 0.

* Add tests for ASLayoutSpecUtilities
2019-10-23 11:23:13 -07:00
vovasty 18fa714c3f deprecate ASGraphicsCreateImageWithOptions (#1704) 2019-10-16 13:20:39 -07:00
Hanton Yang 4c9000c0db Remove build warnings (#1681) 2019-10-10 11:21:29 -07:00
vovasty 6baf29a8a0 fix a node background color in non layer baked mode. (#1693) 2019-10-08 15:50:58 -07:00
Hanton Yang 06ab67a3aa Using emplace_back, it avoids the move operation requires when using push_back (#1658) 2019-09-18 00:07:03 -07:00
Rahul Malik 618f21e28a Fix main thread assertion for tint color on text nodes, re-render tint-able nodes on hierarchy changes (#1670)
- Address various issues with tint color on text nodes
- Avoid accessing `self.tintColor` off-main since this will trigger an
assertion and might be undefined behavior
- Trigger setNeedsDisplay in cases of hierarchy change and
tintColorDidChange in ASButtonNode, ASTextNode{1,2}
- Fix bug in _ASTableViewCell where we were overwriting the tint color
instead of inheriting the correct value
- Add tests for new logic in changing hierarchy
2019-09-16 14:38:50 -07:00
Greg Bolsinga 492da8a95b Node TintColor Tweaks (#1666)
* Node TintColor Tweaks

- If the tint color changes, be sure to call -setNeedsDisplay on the view.
- Explictly declare tintColor ivar and getter method.
- If the tintColor is the same as the existing one, early-exit.
- Use the ivar and not the property when setting the tintColor, just as is done for background color.
- Add tests (for non iOS13 and iOS13) that the tintColor will call -setNeedsDisplay
- Backfill tests to document/verify the tintColor behavior on a node.
2019-09-11 14:22:39 -07:00
Hanton Yang c99bcb02f8 Use CAEdgeAntialiasingMask instead of unsigned int (#1667) 2019-09-11 10:38:06 -07:00
Michael Zuccarino 5e7fbf2ff9 Defer image asset regeneration to draw loop (#1663)
There is a potential dealloc race condition that can occur when attempting to perform work with image asset out of the main thread. Moving that work into the image node draw loop if necessary
2019-09-07 03:37:43 -07:00
Rahul Malik bda0a5b22b Track backgroundColor in ASDisplayNode (#1640)
To preserve dynamic color capabilities for layer-backed
nodes, we need to track backgroundColor as a UIColor. In layer backed nodes we lose the dynamic color logic since we
extract a CGColor from the UIColor applied to ASDisplayNode. With this
change we can respond to changes in UITraitCollection.userInterfaceStyle
for backgroundColor.
2019-08-26 17:58:53 -07:00
Hanton Yang 762c8e8bff Keep using unowned macro (#1626) 2019-08-22 17:02:50 -07:00
Hanton Yang 1467319ec3 Minor code improvements (#1622)
* Simplify code logic

* Keep using user-defined type
2019-08-20 22:14:15 -07:00
Huy Nguyen ab0a14c8ab Minor changes to tint color support (#1620) 2019-08-15 12:59:10 -07:00
Rahul Malik b9903a4155 Add support for tinting layer-backed ASDisplayNode (#1617)
* Add support for tinting layer-backed ASImageNode's

* Move tint color support ASDisplayNode

* Address comments, unlock before calling "tintColorDidChange" on
subclasses

* Address comments
2019-08-15 10:03:15 -07:00
Hanton Yang ad1ed9f6b6 Remove unused headers (#1615)
* Improve compilation time by reducing unnecessary compilation dependencies
* More clean code
2019-08-15 05:42:26 -07:00
Rahul Malik 540f1344ab Add support for tintColor on ASImageNode and ASButtonNode (#1603)
- Add the ability to specify a tintColor for images / buttons that behave similarly to how they would under UIKit.
- Add flag to control if tint color is applied to ASTextNode to match how
UIKit controls if it is .applied to UILabel.
- Update tests for not-tinting automatic render mode for UIImage.
- Add property on ASTextNode2.
- Add tint color support to ASTextNode2.
2019-08-12 09:14:54 -07:00
Hanton b933f661b9 Use AS_ARRAY_SIZE for array counting (#1600) 2019-07-28 13:07:54 -07:00
Rahul Malik 4ebd38c316 Update ASPendingState type for backgroundColor to UIColor
Given that UIColor is now a dynamic provider we can no longer rely on the fact that there is a 1:1 mapping between UIColor <-> CGColorRef.

I've updated the UIViewBridge and ASPendingState accordingly to use UIColor and translate to CGColorRef only when interacting with layers. This should preserve any dynamic capabilities we might need in the future when trying to re-render layer backed nodes.
2019-07-20 18:53:37 -07:00
Rahul Malik d4d6897a97 Set background color directly to view if not layer backed (#1588)
* Set background color directly to view or layer depending on if the node
is layerBacked.

Summary:
UIColor can now be a dynamic color provider to support capabilities like Dark Mode in applications. UIKit is able to re-render views when a user enters dark mode but this dynamic capabilities is not handled at the layer level.

Currently this takes the recommendation in facebookarchive/AsyncDisplayKit#1537 (comment) to set background color on the view directly or layer depending on if the node is layer backed. This change allows UIKit to track these colors and update the UI when the UITraitCollection.userInterfaceStyle changes.

* Updates to UIViewBridge to fix tests

* Remove opaque

* Test fixes

* Revert change to test checker method

* Fix strange issue where setting UIView backgroundColor sets the layer to
opaque to false

* Address Huy comments

* Address last comment
2019-07-19 19:17:01 -07:00
Huy Nguyen e274e5dac5 Remove ivar of ASCellNode.owningNode (#1559) 2019-06-25 10:58:43 -07:00
Adlai Holler 731db8c9ee In text measurement, don't eagerly create arrays for attachments since we don't usually have attachments. (#1535)
PRESUBMIT=passed
R=mcudich,wiseoldduck
CC=maxwang,yt-elements-eng+cl
APPROVED=mcudich
REQUIRED_REVIEW=1
DELTA=25 (11 added, 8 deleted, 6 changed)
DELTA_BY_EXTENSION=mm=17
OCL=242501658
NO_SQ=Test failures are unrelated.


P4 change: 242514626
2019-06-06 07:50:19 -07:00
Michael Schneider 19fb1240ad Fix multiple issues around accessibility handlinig (#1537)
* Improve Accessibility Implementation

- Fixes calculations for accessibilityFrame of ASAccessibilityCustomAction and ASAccessibilityElement
- Fix crash for accessibility elements within layer backed nodes
- Fix accessibility action label updating after other actions change the accessibility label of the corresponding node

* Address comments
2019-06-05 13:51:25 -07:00
Michael Schneider ab8ea069ea Add support for basic ASTextNode2 link highlighting (#1518)
* Add support for basic ASTextNode2 link highlighting

* Add approach to fix line highlighting

* Enable proper highlighting for first row

* Fix snapshot highlighting test for ASTextNode2

* Update screenshot again

* Address comments
2019-06-03 08:57:31 -07:00
Michael Schneider 62e5a8e86c Use flag for responder chain methods between view and node dispatching (#1522)
* Use flag for responder chain methods between view and node dispatching

* Use bitfields
2019-05-30 07:18:07 -07:00
Adlai Holler 27fe219d14 Reclaim CALayer asyncTransactions set, use NSMutableSet instead of heavy/slow NSHashTable (#1510) 2019-05-10 16:31:24 -07:00
Adlai Holler 4cd8e82996 ASSignpost: Add support for the os_signpost API, fixes (#1501)
* ASSignpost: Add support for the os_signpost API

- Removes support for colored intervals. These weren't really useful and they aren't part of the signpost api.
- Fixes an issue with range controller interval logging.
- Adds an interval for interface orientation changes.

* Rename

* Support Xcode 9

* Commentary
2019-05-08 19:59:13 -07:00
Greg Bolsinga 87335d8dc5 Keep the atomics - does not affect memory work (#1498)
Revert "Ensure ASControlMode properties lock before accessing their ivars (#1476)"
This reverts commit ce1e1956f4.

Revert "Make sure all ASDisplayNode properties have backing ivars for consistency. (#1475)"
This reverts commit d6061f4390.
- Except the unused property `interfaceStateSuspended` is still removed (this is a memory saver).
2019-05-07 20:14:19 -07:00
Greg Bolsinga 7470052f55 Remove unused declaration, missed in #1460 (#1497) 2019-05-07 13:42:22 -07:00
Greg Bolsinga 4d1176be4d Shrink ASImageNode by .6% and ASNetworkImageNode by 2.2% (#1487)
* Shrink ASImageNode by .6% and ASNetworkImageNode by 2.2%

ASImageNode goes from 1384 to 1376. ASNetworkImageNode goes from 1496 to 1464.

These objects accumulate in the heap, so reducing their size will allow more to accumulate before memory warnings.

Group the `BOOL`s into a struct. Shrink the various stored `enum`s to fit the size of their contents. Move the ivars around so that the smaller `enum` are near eachother and the bitfield struct.

* add comments as requested in garrett's review.

* access ivar directly since already locked as suggested in review.
2019-05-07 11:17:59 -07:00