Skip to content

Conversation

@jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented May 14, 2022

AbstractNode isn't a free abstraction, because we can't do template style specialization in Dart. Many places in the framework that would otherwise have a free access or null check have to do a cast due to how AbstractNode is implemented.

Why not change to AbstractNode<T extends AbstractNode<T>>? In short, because it would still require casting in several places to prove that your instance of T is actually an AbstractNode<T>

I've also not found any code that attempts to abstract over an AbstractNode, usually code is written for one of RenderObject, Layer, or SemanticsNode and casts as necessary

@flutter-dashboard flutter-dashboard bot added f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. labels May 14, 2022
@flutter-dashboard flutter-dashboard bot added the a: tests "flutter test", flutter_test, or one of our tests label May 14, 2022
@jonahwilliams jonahwilliams marked this pull request as ready for review May 16, 2022 23:07
@jonahwilliams
Copy link
Contributor Author

From tests on customer:money's app, I was not able to make any measurable performance improvements. That said, if this change isn't breaking to google3 we might consider it since I think removing casts is also beneficial from an ease-of-understanding perspective.

final AnimationController opacityAnimation = AnimationController(value: 1, vsync: FakeTickerProvider());
final RenderSliverAnimatedOpacity opacity = RenderSliverAnimatedOpacity(opacity: opacityAnimation, sliver: sliver);
// ignore: invalid_use_of_protected_member
parent.adoptChild(opacity);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dnfield this one is the problem. if you use the child setter its a type error

assert(!debugNeedsLayout);
assert(() {
final RenderObject? parent = this.parent as RenderObject?;
final RenderObject? parent = this.parent;
Copy link
Contributor

Choose a reason for hiding this comment

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

this might in fact be unnecessary now, the getter should just get inlined right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is used in the asset on L2154 that asserts that the parent getter is stable

child.markNeedsLayout();
root.layout();
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

*respectful minute of silence*

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🖖

Copy link
Contributor Author

Choose a reason for hiding this comment

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

or maybe 🎺

Copy link
Contributor

@Hixie Hixie left a comment

Choose a reason for hiding this comment

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

LGTM

@Hixie
Copy link
Contributor

Hixie commented May 16, 2022

(cc @goderbauer)

test('AnimatedOpacity sets paint matrix to zero when alpha == 0 (sliver)', () {
final RenderSliver sliver = RenderSliverToBoxAdapter(child: RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 20)));
final RenderBox parent = RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 20));
final RenderSliverPadding parent = RenderSliverPadding(padding: const EdgeInsets.all(4));
Copy link
Contributor

Choose a reason for hiding this comment

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

This change is fine, the test only needed to be sure to have a child, doesn't really matter what the type is.

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@jonahwilliams
Copy link
Contributor Author

Marking as a draft until we figure out how to land this in a non-breaking manner

@jonahwilliams jonahwilliams marked this pull request as draft May 18, 2022 21:58
@jonahwilliams jonahwilliams marked this pull request as ready for review May 19, 2022 17:56
@jonahwilliams
Copy link
Contributor Author

Google changes were not as bad as expected due to this PR getting bundled with some other breaking PRs. Will apply g3fix and then attempt to land

@jonahwilliams
Copy link
Contributor Author

I ran a globla presubmit and bundled the changes into a g3fix. It doesn't seem like that is getting applied to the PR so I've marked as passing so we can land it.

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

Labels

a: tests "flutter test", flutter_test, or one of our tests f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants