From 8ff63e158c3e549573714b5677e32e85bbd9dd3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 31 Mar 2025 11:54:22 +0200 Subject: [PATCH] Async load panels to avoid update thread hitching --- osu.Game/Screens/Ranking/UserTagControl.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Ranking/UserTagControl.cs b/osu.Game/Screens/Ranking/UserTagControl.cs index 506b34fe85..cd5d2486fd 100644 --- a/osu.Game/Screens/Ranking/UserTagControl.cs +++ b/osu.Game/Screens/Ranking/UserTagControl.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; +using System.Threading; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Caching; @@ -452,6 +453,8 @@ namespace osu.Game.Screens.Ranking public Action? OnSelected { get; set; } + private CancellationTokenSource? loadCancellationTokenSource; + [BackgroundDependencyLoader] private void load(OsuColour colours) { @@ -502,8 +505,14 @@ namespace osu.Game.Screens.Ranking AvailableTags.BindCollectionChanged((_, _) => { - searchContainer.Clear(); - searchContainer.ChildrenEnumerable = createItems(AvailableTags.Values); + loadCancellationTokenSource?.Cancel(); + loadCancellationTokenSource = new CancellationTokenSource(); + + LoadComponentsAsync(createItems(AvailableTags.Values), loaded => + { + searchContainer.Clear(); + searchContainer.AddRange(loaded); + }, loadCancellationTokenSource.Token); }, true); searchBox.Current.BindValueChanged(_ => searchContainer.SearchTerm = searchBox.Current.Value, true); }