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
* [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.
* fix SIMULATE_WEB_RESPONSE not imported #449
* Fix to make rangeMode update in right time
* remove uncessary assert
* add api to allow delegated calls in background.
* fix typo
* 1. Add class property to decide whether to send delegate callbacks on
main or background.
2. remove non-info api.
* Refactor.
* add ivar for class property.
* Donot use extra api.
* Refactor
* refactor
* revert to use let
* refactor
* make class property atomic.
* kick of new ci test.
* kick off new ci
- 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.
* 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
* Fix capturing self in the block while loading image in ASNetworkImageNode
* Restore re-strongify while switching on the main thread
* Update CHANGELOG.md
* Add support for piping arbitrary user info from ASImageDownloader to the ASNetworkImageNodeDelegate
* s/source/sourceType
* Fix stuff and take Michael's advice
* Revert "Adds support for specifying a quality indexed array of URLs (#557)"
This reverts commit 3c77d4a5da44c46c7b80b2a627c95389b7d6352d.
* Add CHANGELOG entry
Good catch by @djblake, if you scroll fast enough, you leave images
set on the image node because didExitPreloadRange (which would have
cleared it) was already called.
* Add support for downloading a set of URLs on ASNetworkImageNode
* Should be building now;
* Remove old unused code
* Add a changelog message
* Bump PINRemoteImage
* Huy's comments
* Be more aggressive at invalidating layouts during transitions, add a debug method, fix some build errors when verbose logging
* Add a changelog entry
We need this in case someone is setting the URL to nil before setting
the image directly. I.e. they have a node which has been used as a network
node or an image node but now they want it to be an image node.
They should then set the URL to nil and then set the image.
*if* it was used as a network node previously, this would work.
If it was previously used as an image node it would historically assert.
This addresses that.
* Need to check availability before use of macros.
* Get rid of PCH and enforce macro definition.
* Remove prefix
* Switch to global warning instead, much better.
* Adds support for resuming downloads that were canceled due to exiting preload range.
* Update to latest PINRemoteImage
* Fix warnings
* Address comments. Thanks @nguyenhuy!
_setImage is intended to call the super version of the method,
however with the adoption of the new _locked_ prefix, ASImageNode's
implementation would call back into ASNetworkImageNode's implementation.
This restore the intent of the _setImage method.
* [ASMultiplex/NetworkImageNode] Ensure ASImageProtocols are not called with nil arguments.
* [ASBasic/PINRemoteImageDownloader] Do not check for nil downloadIdentifier needlessly.
* [ASImageCacheProtocol] Make synchronouslyFetchedCachedImageWithURL URL nonnull.