Skip to content

Adjust search container logic to address game-side issues with hiding its children#5530

Merged
peppy merged 8 commits intoppy:masterfrom
bdach:filterable-alternative-poc
Nov 29, 2022
Merged

Adjust search container logic to address game-side issues with hiding its children#5530
peppy merged 8 commits intoppy:masterfrom
bdach:filterable-alternative-poc

Conversation

@bdach
Copy link
Collaborator

@bdach bdach commented Nov 20, 2022

This is an RFC.

Contents

IHasFilterableChildren is removed; hierarchical lookups now leverage IContainerEnumerable<T>

This is the same as in the original PR. Rather than rely on IHasFilterableChildren to descend down complex hierarchies for filtering purposes, IContainerEnumerable<T>.Children is used, which results in less boilerplate as you don't need to remember to implement it whenever needed.

IConditionalFilterable (?) is introduced

At first I tried to resurrect the aforementioned PR rather than rewrite, but the invalidation issues pointed out therein ended up being caused by a fatal contradiction in its logic that I describe in more detail here. As a result, this PR takes a different, explicit approach of introducing a new IConditionalFilterable interface.

The name is bad, I know (suggestions welcome), but the gist of it is that upon implementing IConditionalFilterable, you get one extra bindable to play with. If the value of said bindable is true, then the item is included in textual search as usual. If it is false, however, it - and its entire subtree - is excluded from further search on the premise that the item does not meet external criteria. In practical terms, you would set it to false when you want to hide some items inside a SearchContainer because they're unavailable due to other settings, which is precisely the use case that needs fixing game-side.


A branch for game-side adjustments for this framework change, that end up fixing ppy/osu#18003, is available for preview at https://github.com/ppy/osu/compare/master...bdach:filtering-framework-change-adjustments?expand=1.

I also recommend examining the commit messages of d0d90e9 and b790cd3.

A notable exception is `TestGroupButton`, which no longer inherits from
`IHasFilterableChildren`, but its `FilterableChildren` member has not
been deleted. This is because `TestBrowser` relies on it.
The test was previously checking that all the `HeaderContainer`s are not
present. This however breaks if one of them is caught early as
`CanBeShown = false`, as then the search algorithm will not descend into
that subtree at all, and *technically* leave some `HeaderContainer`s
present - but the ones we actually care about, i.e. the topmost-level
ones, will be hidden correctly.
@peppy peppy self-requested a review November 29, 2022 03:18

if (drawable is IConditionalFilterable conditionalFilterable)
{
var canBeShownBindable = conditionalFilterable.CanBeShown.GetBoundCopy();
Copy link
Member

Choose a reason for hiding this comment

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

I'm a touch worried about the bindable overhead here if many filter operations happen over a short period (there will be a lot of bindable churn). Probably okay, but here's a quick comparison of loading SettingsOverlay and performing 10 filters + unfilters:

Before:

JetBrains Rider-EAP 2022-11-29 at 05 03 58

After:

JetBrains Rider-EAP 2022-11-29 at 05 00 53

The overhead is definitely visible, but maybe fine to eat? We can probably further optimise this at a later point (ie. avoiding clearing the list altogether and reusing existing bindings) if required.

@peppy
Copy link
Member

peppy commented Nov 29, 2022

Let's go with this and see how things play out.

@peppy peppy merged commit 1c06466 into ppy:master Nov 29, 2022
@bdach bdach deleted the filterable-alternative-poc branch November 30, 2022 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants