Skip to content

Tighten Rasterization API, Undeprecate It#82

Merged
Adlai-Holler merged 6 commits into
masterfrom
AHRasterizationIsBack
May 1, 2017
Merged

Tighten Rasterization API, Undeprecate It#82
Adlai-Holler merged 6 commits into
masterfrom
AHRasterizationIsBack

Conversation

@Adlai-Holler

@Adlai-Holler Adlai-Holler commented Apr 28, 2017

Copy link
Copy Markdown
Member

After playing with Pinterest for a little bit, there are some views that would majorly benefit from rasterization if we could get it going. Not that I'm addicted to it! But here's what this diff does:

  • Replaces the @property (readwrite) shouldRasterizeDescendants with a one-way method -[node setShouldRasterizeDescendants]. So once it's enabled on a node, there's no disabling it. This is breaking deprecated API but nobody will care.
  • Adds assertions against triggering rasterization on nodes that are already loaded.
  • Adds assertions against triggering rasterization on nodes whose subnodes are already loaded.
  • Adds assertions against adding a loaded subnode into a rasterized tree.

So the rasterization feature remains in the Beta header, and we're not going out of our way to support it, but if we can get rid of some old code, and tamp down the API, let's keep it around. Thoughts @maicki @nguyenhuy @appleguy ?

@ghost

ghost commented Apr 28, 2017

Copy link
Copy Markdown

🚫 CI failed with log

@appleguy

Copy link
Copy Markdown
Member

@Adlai-Holler :-D I never thought I'd see the day, but what an awesome surprise! Definitely planning on making use of this. Let me know if I can help, will review this weekend.

Comment thread Source/ASDisplayNode+Beta.h Outdated
* Note: You cannot call this method after the receiver's layer/view is loaded.
*/
@property (nonatomic, assign) BOOL shouldRasterizeDescendants ASDISPLAYNODE_DEPRECATED_MSG("Deprecated in version 2.2");
- (void)setShouldRasterizeDescendants;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Adlai-Holler I think it's a good idea to make this an enable-only method. However, this name seems kinda sucky because it sounds exactly like a property that expects an argument.

How about something like -enableSubtreeRasterization, -enableRasterizingDescendants, etc? I think coming up with the right term for a subtree of subnodes could help here. .automaticallyManagesSubnodes is one reference point, but it does not apply recursively to all levels below, so Subtree might be better.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm OK! I'll change it to enableSubtreeRasterization.

Comment thread Source/ASDisplayNode.mm Outdated
}

// Ensure no loaded subnodes
for (ASDisplayNode *subnode in _subnodes) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this loop enough to check all subnodes' subnodes? Should we use ASPerformBlockOnEverySubnode, or otherwise recursively call _enableRasterizingToParent or something on each?

Comment thread Source/ASDisplayNode.mm
// If this subnode will be rasterized, enter hierarchy if needed
// TODO: Move this into _setSupernode: ?
if (isRasterized) {
if (self.inHierarchy) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it may have been important for the original code to enter the Rasterized hierarchy state before __enterHierarchy is called, because it may have invoked delegate methods that check this. I haven't looked closely though, this might not be true - just something to take a close look at.

@appleguy appleguy assigned appleguy and Adlai-Holler and unassigned appleguy Apr 29, 2017

@appleguy appleguy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor cleanup / naming considerations to do, but overall this looks like a nice step forward :).

There will continue to be a reduced footprint from this feature once the isInHierarchy system is properly merged with interfacestate, and we could also factor out the AsyncDisplay code into a separate category to reduce complexity of the core files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants