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] LabelHandler - remove extra (?) line #23346

Conversation

MartyIX
Copy link
Contributor

@MartyIX MartyIX commented Jun 28, 2024

Description of Change

I noticed that this line does not seem to be necessary. It also causes significant performance slowdown.

image

Speedscopes:

-> ~%95 improvement

However, I'm not sure if the change is correct or not. I would expect that MapContainerView from ViewHandler.cs makes sure that a container is mapped properly. But perhaps mapper chaining works differently than I think.

Issues Fixed

Contributes to #21787

@MartyIX MartyIX requested a review from a team as a code owner June 28, 2024 18:00
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jun 28, 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.

@mattleibow
Copy link
Member

I think it is needed still if the background changes:

https://github.com/dotnet/maui/blob/main/src/Core/src/Handlers/Label/LabelHandler.Windows.cs#L11

If it goes from null to non-null, then we need to insert a container view. It may be a coincidence that it already has a background from some other property:

public override bool NeedsContainer =>
	VirtualView?.Background != null ||
	(VirtualView != null && VirtualView.VerticalTextAlignment != TextAlignment.Start) ||
	base.NeedsContainer;

OR

internal static bool NeedsContainer(this IView? view)
{
	if (view?.Clip != null || view?.Shadow != null)
		return true;

	if (view is IBorderView border)
		return border?.Shape != null || border?.Stroke != null;

	return false;
}

So, it may have a container view already from the VerticalTextAlignment, Clip or Shadow.

You can check to see that when background is null, the Handler.ContainerView should also be null. Then you can see if adding a background after your change still adds the correct container.

It also is very likely that we did not need to trigger the container logic via the mappers.... We probably should have some feature in the handler and maybe we can still do that for net9.0.

@mattleibow
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Member

PureWeen commented Jul 2, 2024

MapContainerView is going to be slow if it's the first time that the Containerview is being created. IT's newing up the WrapperView and then adding the PlatformView to it. So, it makes sense that not doing that is going to be a lot faster.

if HasContainer hasn't changed then it doesn't do anything

		public bool HasContainer
		{
			get => _hasContainer;
			set
			{
				if (_hasContainer == value)
					return;

				_hasContainer = value;

				if (value)
					SetupContainer();
				else
					RemoveContainer();
			}
		}

We fire it through the mapper so that things can weave into the mapper flow and react if the container has been added or removed

image

@PureWeen PureWeen closed this Jul 2, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
community ✨ Community Contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants