Introduces ASLayoutRangeModeVisibleOnly, allowing the preservation of decoded backing stores without any extra padding to
strictly minimize memory usage while supporting immediate re-display of content. Set visible range controllers to this mode
upon app suspend / memory warning, while more aggressively clearing others to the ASLayoutRangeModeLowMemory mode.
By default, when the app is running and recieves a memory warning, we set the range mode for non-visible controllers to
ASLayoutRangeModeVisibleOnly. This is because, unlike in the app suspend case where on app resume we can restore controllers
from LowMemory to VisibleOnly, the memory warning doesn't provide a good opportunity to do this.
A new +Beta API to control this behavior is called +setRangeModeForMemoryWarnings:, as some apps may prefer to use LowMemory
in the memory warning scenario. For these apps, optimal user experience will require manually setting the range mode back
to some larger value as the user navigates the app, or they will encounter controllers that are temporarily blank and need
a moment to re-display their contents as they start to become visible.
- shows a red text label overlay on bottom right hand corner of ASImageNodes with pixel scaling factor
- import AsyncDisplayKit+Debug.h and enable using [ASImageNode setEnableImageDebugOverlay]
This patch switches to instance methods of draw and display for
ASTextNode and ASImageNode to attempt to increase their performance.
It also fixes some thread safety issues in ASImageNode which appear
to have been regressions (though probably not hit very often).
And it sets up work for allowing modification of CGContexts before
and after a node's contents are drawn.
This is a workaround necessary due to an iOS 9 bug. I'm not gating it to iOS 9 only so as to
not exaggerate iOS version-specific behavior differences in the framework, since a majority are
on iOS 9 anyway. If we can confirm the bug is fixed in a later iOS version, then it will be gated.
Issue tracked in greater detail here: https://github.com/facebook/AsyncDisplayKit/issues/1068
ASNetworkImageNode defers to ASImageNode to return its calculatedSize. ASImageNode returns the size of its image. There is a good chance that ASNetworkImageNode hasn't downloaded its image yet when calculatedSize is called, so it returns a size of CGSizeZero.
On top of that, it is possible that the size of the image is not actually the size that we wish to display in our node.
I've added an "expectedImageSize" property that can be used to determine the calculatedSize of an ASNetworkImageNode.
- Both ASDisplayNode and ASLayoutNode conforms to this protocol.
- ASDisplayNode can be embeded directly into layout graph.
- Eliminate ASCompositeNode.
- Fix ASStaticSizeDisplayNode not recpect min constrained size.
- Updated tests.
- Introduce ASLayoutNode and its subclasses.
- ASDisplayNode measures its ASLayoutNode and cache the result (ASLayout). Calculated size and position of each subnode can be retrieved from the calculated layout.
- Custom nodes need to override -layoutNodeThatFits:(CGSize) instead of -calculateSizeThatFits:(CGSize).
- Custom nodes do not need to layout its subnodes (in -layout:) anymore. ASDisplayNode can handle the job most of the time, by walking through its layout tree.
- ASCompositeNode is used to embed (display) subnodes to a node's layout. That way, each subnode will also be measured while the parent node is measuring. And the parent node knows where its subnodes are within its layout.
Speculative fix for #380. Calling `-[ASImageNode setImage:]` on a
background queue will take the image lock, then trampoline to the main
queue to invalidate calculatedSize and set needsDisplay without
releasing the lock. Any other method call that takes the image lock on
the main queue can block on the trampoline completing -- deadlock.
Note that the trampoline is itself a clowny workaround for thread
affinity (#134) and should be removed. With this patch applied,
ASImageNode's `-setImage:` and `-calculateSizeThatFits:` can still race:
1. -setImage changes _image, then trampolines to main
2. -calculateSizeThatFits measures _image
3. trampoline completes, invalidates calculated size
4. ???
5. ~~profit!~~ 💥
ASImageNodeTint is inflexible (your options are "no tint" and "use
`[UIColor grayColor]`") and needlessly complicates the ASImageNode
implementation. Use ASImageNodeTintColorModificationBlock() instead.
Closes#383.
ASDisplayNodes now have an overidable method -placeholderImage that lets you provide a custom UIImage to display while a node is displaying asyncronously. The default implementation of this method returns nil and thus does nothing. A provided example project also demonstrates using the placeholder API.
Rename the ASDisplayNode property to match its _ASDisplayLayer
counterpart -- `displaySuspended` is more succinct and is a more
plausible name for a Cocoa BOOL property.
ASImageNode and ASHighlightOverlayLayer were both using
[[UIScreen mainScreen] scale] directly. Bad. No cookie. Use
ASDisplayNodeScreenScale() instead.
(Also, regenerate Xcode project with Xcode 6 and current CocoaPods.)