46 Commits

Author SHA1 Message Date
Huy Nguyen
d102ec81ee
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
2019-03-08 08:11:03 -08:00
Garrett Moon
fce6f23b97
Launches switching ASNetworkImageNode callbacks to global queue. (#1369)
* Launches switching ASNetworkImageNode callbacks to global queue.

* Good catch configuration tests!
2019-03-07 09:47:56 -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
ernestmama
4d1ffcc2d0 Add more delegate methods for monitoring network image node progress (#1247) 2018-11-27 09:48:57 -08:00
Kevin
771c068ad6 Correct block self references to strongSelf (#1231) 2018-11-13 08:20:20 -08:00
Adlai Holler
0380b270bb
Address Xcode warnings about unguarded availability and implicit self retains (#1207) 2018-11-01 19:40:16 -07:00
Michael Schneider
7ee2092dc3
Use interface state to manage image loading. (#1172) 2018-10-18 09:34:54 -07:00
Huy Nguyen
7cdfacca4a
Update documentation of ASNetworkImageNodeDelegate #trivial (#1163)
`-imageNodeDidStartFetchingData:` and `-imageNodeDidFinishDecoding:` are always called on main thread, and the documentation should reflect that.
2018-10-14 09:16:47 -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
Max Wang
905c582497 Background image load api (#1007)
* 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
2018-07-24 15:57:59 -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
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
Adlai Holler
a11506564a
Reduce usage of autorelease pools (#968)
* Reduce reliance on the autorelease pool

* changelog

* A few more places

* Use it in another place
2018-06-15 10:15:25 -07:00
Adlai Holler
cac14e0bce
Standardize Property Declaration Style in Core Classes (#870)
* Audit property attributes for core classes

* Update style guide

* Go crazy

* Update changelog
2018-05-24 14:42:43 -07:00
Garrett Moon
3677e290aa
Issue ASNetworkImageNode callbacks off main thread (#908)
* The main thread is under a bunch of contention on startup, let's avoid using it.

* Update CHANGELOG
2018-05-04 12:21:42 -07:00
Adlai Holler
bd24015691
[ASNetworkImageNode] Replace NSUUID sentinel with integer #trivial (#852)
* Replace NSUUID sentinel with an integer

* Update ASNetworkImageNode.mm
2018-03-25 12:31:32 -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
Garrett Moon
f99dd68a9f
[#trivial] fixes rendered image quality on networked image nodes which have their image directly set. (#826) 2018-03-08 16:21:54 -08:00
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
0c4ccc5253
Improve ASNetworkImageNode delegate callout behavior (#778)
* Improve ASNetworkImageNode delegate callout behavior

* no message
2018-01-31 12:18:04 -08: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
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
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
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
af99ff5ef2 Have ASNetworkImageNode report whether images were cached or not (#639)
* Have ASNetworkImageNode report whether images were cached or not.

* Update changelog

* Add fileURL case
2017-10-25 15:57:30 -07:00
Garrett Moon
1705ec0140 Don't set download results if no longer in preload range. (#606)
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.
2017-10-09 10:13:28 -07:00
Huy Nguyen
9df6909d71 [ASImageNode] Always dealloc images in a background queue (#561)
* ASImageNode to always dealloc its images in a background queue

* Update CHANGELOG
2017-09-11 13:33:30 -07:00
Garrett Moon
3c77d4a5da Adds support for specifying a quality indexed array of URLs (#557)
* 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
2017-09-11 11:12:45 -07:00
Huy Nguyen
786963c6a9 [ASDisplayNode] Deprecate -displayWillStart in favor of -displayWillStartAsynchronously: (#536)
* Deprecate -[ASDisplayNode displayWillStart] in favor of -displayWillStartAsynchronously:

* Minor change

* Fix CHANGELOG

* Update CHANGELOG.md

* Update CHANGELOG.md
2017-09-08 18:04:43 +01:00
Adlai Holler
01c14f0fc2 Invalidate layouts more aggressively when transitioning with animation (#476)
* Be more aggressive at invalidating layouts during transitions, add a debug method, fix some build errors when verbose logging

* Add a changelog entry
2017-07-26 22:27:58 -07:00
Adlai Holler
8ec4b312cf Overhaul our logging, add activity tracing support. (#399)
* Improve the os_log and os_activity integration

* Address feedback from Scott and Huy
2017-07-03 19:03:26 -07:00
Garrett Moon
d5f10652c6 Fixes an issue with GIFs that would always be covered by their placeholder (#326)
Also adds a subclass override for when the animated image is set.
2017-06-02 16:13:36 -07:00
Garrett Moon
850aeb442c Assert only once we know URL has changed (#247)
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.
2017-05-05 16:32:54 -07:00
Garrett Moon
8013e25524 Update license v2 (#67)
* Fixed license

* Update all licenses

* Update Dangerfile for new license

* Update already updated licenses

* Closer…

* Closer…

* Closer…

* Closer…

* Closer…

* Closer…

* Closer…

* Closer…

* Closer…

* Closer…

* Closer…
2017-04-24 16:59:57 -07:00
Adlai Holler
fdb54a02d9 Fix case where we forget to unlock in ASNetworkImagenode (#17) 2017-04-17 11:38:07 -07:00
Garrett Moon
8c3775f5e2 Need to check availability before use of macros. (#3254)
* 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.
2017-04-10 15:06:40 -07:00
Garrett Moon
68a8d5f468 Add download resume support (#3246)
* Adds support for resuming downloads that were canceled due to exiting preload range.

* Update to latest PINRemoteImage

* Fix warnings

* Address comments. Thanks @nguyenhuy!
2017-04-10 11:18:05 -07:00
Garrett Moon
30ad10da3c _setImage wasn't calling correct implementation (#3243)
_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.
2017-04-04 15:13:10 -07:00
Michael Schneider
1f042e960d [ASNetworkImageNode] Improve locking (#3187)
* Locking improvements for ASNetworkImageNode

* Fix typo

* Address comments

* Address comments

* Change comment to kick build
2017-03-28 10:42:59 +01:00
Flo
d5a84bf7b1 [ASImageProtocols] Fix nullables to avoid bridging crashes (#3190)
* [ASMultiplex/NetworkImageNode] Ensure ASImageProtocols are not called with nil arguments.

* [ASBasic/PINRemoteImageDownloader] Do not check for nil downloadIdentifier needlessly.

* [ASImageCacheProtocol] Make synchronouslyFetchedCachedImageWithURL URL nonnull.
2017-03-17 11:46:10 -07:00
Adlai Holler
0de270fdfb Revert "Improve designated initializer usage (#3132)"
This reverts commit eaa875c7f2e08afa8b597c653be6b7c45cfff66d.
2017-03-03 15:31:28 -08:00
Michael Schneider
eaa875c7f2 Improve designated initializer usage (#3132)
* Improve designated initializer usage

* Some more changes

* Add some whitespace

* Fix some warning
2017-03-03 14:49:34 -08:00
Garrett Moon
40d3a1de7a Trying to set the progress block with a nil identifire doesn't make sense. (#3117) 2017-03-01 19:51:16 -08:00
Adlai Holler
73ca6ab514 Shuffle & Cleanup Stuff (#3080) 2017-02-26 18:14:13 -08:00