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

perf(anim): Don't refresh triggers and transitions during parsing #19228

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions src/Uno.UI/UI/Xaml/VisualStateGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public sealed partial class VisualStateGroup : DependencyObject
private readonly SerialDisposable _parentLoadedDisposable = new();

private (VisualState state, VisualTransition transition) _current;
private bool _pendingOnOwnerElementChanged;

public event VisualStateChangedEventHandler CurrentStateChanging;

Expand Down Expand Up @@ -159,11 +160,28 @@ private void OnParentChanged(object instance, object key, DependencyObjectParent
}
}

private void OnOwnerElementChanged() =>
private void OnOwnerElementChanged()
{
if (this.GetParent() is IFrameworkElement fe
&& fe.IsParsing)
jeromelaban marked this conversation as resolved.
Show resolved Hide resolved
{
_pendingOnOwnerElementChanged = true;
return;
}

ExecuteOnTriggers(t => t.OnOwnerElementChanged());
}

private void OnOwnerElementLoaded(object sender, RoutedEventArgs args)
{
if (_pendingOnOwnerElementChanged)
{
_pendingOnOwnerElementChanged = false;
OnOwnerElementChanged();
}

private void OnOwnerElementLoaded(object sender, RoutedEventArgs args) =>
ExecuteOnTriggers(t => t.OnOwnerElementLoaded());
}

private void OnOwnerElementUnloaded(object sender, RoutedEventArgs args) =>
ExecuteOnTriggers(t => t.OnOwnerElementUnloaded());
Expand Down Expand Up @@ -500,6 +518,12 @@ static bool Match(VisualTransition transition, string from, string to)

internal void RefreshStateTriggers(bool force = false)
{
if (this.GetParent() is IFrameworkElement fe
&& fe.IsParsing)
jeromelaban marked this conversation as resolved.
Show resolved Hide resolved
{
return;
}

var newState = GetActiveTrigger();
var oldState = CurrentState;
if (newState == oldState)
Expand Down
Loading