Skip to content
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

[Windows] Optimize WrapperView #24281

Conversation

MartyIX
Copy link
Contributor

@MartyIX MartyIX commented Aug 16, 2024

Description of Change

This PR attempts to optimize WrapperView class on Windows. Not every WrapperView has a border or a shadow set, so it can be set up when it's really needed.

Performance impact

image

-> 93% improvement for the execution of the constructor.

Issues Fixed

@MartyIX MartyIX requested a review from a team as a code owner August 16, 2024 15:12
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Aug 16, 2024
Copy link
Contributor

Hey there @MartyIX! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@@ -68,6 +65,8 @@ public void Dispose()
DisposeClip();
DisposeShadow();
DisposeBorder();

GC.SuppressFinalize(this);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested by MSVS.

Copy link
Member

Choose a reason for hiding this comment

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

@jonathanpeppers is this the correct thing to do? Do we trust the AI?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's suggested by a dotnet analyzer FTR

Copy link
Member

Choose a reason for hiding this comment

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

  1. I think to finish out this pattern we need to add a finalizer as well https://learn.microsoft.com/en-us/dotnet/api/system.idisposable?view=net-8.0#examples

  2. I'm not really a fan of this implementing IDisposable at all, but I don't think we can really do anything about that now

Copy link
Contributor Author

@MartyIX MartyIX Aug 18, 2024

Choose a reason for hiding this comment

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

I removed that change in be1ecb2 to avoid increasing scope of this PR.

Comment on lines 131 to 135
if (_borderPath is null)
{
_borderPath = new();
Children.Add(_borderPath);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If not initialized, initialize now. A part of the main change.

Comment on lines 219 to 223
if (_shadowCanvas is null)
{
_shadowCanvas = new();
Children.Add(_shadowCanvas);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A part of the main change.

@@ -20,22 +20,17 @@ namespace Microsoft.Maui.Platform
{
public partial class WrapperView : Grid, IDisposable
{
readonly Canvas _shadowCanvas;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: It was readonly but then _shadowCanvas was checked if it is null or not.

Foda
Foda previously approved these changes Aug 16, 2024
@PureWeen
Copy link
Member

PureWeen commented Aug 16, 2024

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jfversluis
Copy link
Member

A bunch of tests failed, I retried them now but if they still fail that might be something to look into

@MartyIX
Copy link
Contributor Author

MartyIX commented Aug 18, 2024

A bunch of tests failed, I retried them now but if they still fail that might be something to look into

Yes, the PR changes the behavior, it can be seen with Microsoft.Maui.TestCases.Tests.Issues.Issue16094(Windows).ShadowsDontRespectControlShape test:

MAIN PR
image image

Working on fixing that.

@MartyIX
Copy link
Contributor Author

MartyIX commented Aug 18, 2024

With 65ddf79 and 674ec0d, I can see ShadowsDontRespectControlShape and WhenTapButtonThenListViewsChangesVisibility tests to pass.

Edit: Thanks @PureWeen for the idea.

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jfversluis jfversluis merged commit 639fcb0 into dotnet:main Aug 20, 2024
97 checks passed
@samhouts samhouts added fixed-in-net9.0-nightly This may be available in a nightly release! fixed-in-net8.0-nightly This may be available in a nightly release! labels Aug 27, 2024
@MartyIX MartyIX deleted the feature/2024-08-16-Windows-WrapperView-optimize-FINAL branch September 10, 2024 18:38
@github-actions github-actions bot locked and limited conversation to collaborators Nov 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
community ✨ Community Contribution fixed-in-net8.0-nightly This may be available in a nightly release! fixed-in-net9.0-nightly This may be available in a nightly release!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants