-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Android] Changes to reduce unnecessary layout requests #4229
Conversation
Caching Frame in VisualElement and with some local variables and comparisons to check if Frame (size andposition) has changed slightly improves Measure ticks. To avoid having a too complex PR I have decided to splitit into two blocks where the one that provides the most perf benefits would be this one. |
Need to review but could have an impact in #4149 |
Made more changes using https://github.com/jsuarezruiz/netmaui-chat-app-challenge as reference. Really many more Layout invalidations are made than necessary. With this PR we pass from: Affecting the scrolling of listings, navigation, etc. To: Where the performance is more similar to Xamarin.Forms. However, we have a Measure loop located in the ScrollViewHandler. I leave those changes for another PR, although they are necessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm worried that the caching of the ScrollView size (and not measuring the content) will cause weird problems later.
Everything else looks good.
public override Size GetDesiredSize(double widthConstraint, double heightConstraint) | ||
{ | ||
var result = base.GetDesiredSize(widthConstraint, heightConstraint); | ||
|
||
if (FindInsetPanel(this) == null) | ||
if (result != _previousDesiredSize && FindInsetPanel(this) == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the measure/layout pass has been triggered by something in the ScrollView content, not measuring it here could mean that it doesn't get updated/redrawn properly. I think we should avoid adding this caching here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, this have a small impact, but let me review alternatives. If not, we can remove this, merge and continue improving in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hartez Could you review it again?. Thanks.
Description of Change
Changes to RequestLayout in Layouts only when needed.
Testing with:
PerfTests.zip
Before:
After:
Notice that the onLayout and onMeasure time (green light color) has been greatly reduced.
NOTE: the gifs have been optimized to have a small size, the quality is low.
@hartez Could we take a look to this together?
PR Checklist
Does this PR touch anything that might affect accessibility?