osu icon indicating copy to clipboard operation
osu copied to clipboard

Error on right click on a taiko hit object

Open namooTH opened this issue 2 years ago • 2 comments

Type

Game behaviour

Bug description

In the Taiko editor, when placing 2 objects, after right-clicking the first placed object, the game would error.

Screenshots or videos

https://github.com/user-attachments/assets/53663f57-0b1f-4b05-9ffc-da2f2b84f323

Version

2024.1009.1-lazer

Logs

compressed-logs.zip

namooTH avatar Oct 17 '24 15:10 namooTH

Exception is

2024-10-17 15:15:45 [error]: An unhandled error has occurred.
2024-10-17 15:15:45 [error]: System.InvalidOperationException: Can not change depth of drawable which is not contained within this CompositeDrawable.
2024-10-17 15:15:45 [error]: at osu.Framework.Graphics.Containers.CompositeDrawable.ChangeInternalChildDepth(Drawable child, Single newDepth)
2024-10-17 15:15:45 [error]: at osu.Framework.Graphics.Containers.Container`1.ChangeChildDepth(T child, Single newDepth)
2024-10-17 15:15:45 [error]: at osu.Framework.Graphics.Containers.Container`1.ChangeChildDepth(T child, Single newDepth)
2024-10-17 15:15:45 [error]: at osu.Game.Screens.Edit.Compose.Components.BlueprintContainer`1.OnBlueprintSelected(SelectionBlueprint`1 blueprint)
2024-10-17 15:15:45 [error]: at osu.Game.Screens.Edit.Compose.Components.EditorBlueprintContainer.OnBlueprintSelected(SelectionBlueprint`1 blueprint)
2024-10-17 15:15:45 [error]: at osu.Game.Rulesets.Edit.SelectionBlueprint`1.updateState()
2024-10-17 15:15:45 [error]: at osu.Game.Rulesets.Edit.SelectionBlueprint`1.set_State(SelectionState value)
2024-10-17 15:15:45 [error]: at osu.Game.Rulesets.Edit.SelectionBlueprint`1.Select()

which suggests Yet Another Custom Comparer Fail. Previously: https://github.com/ppy/osu/issues/13473#issuecomment-860104067.

Notably this is the timeline causing the crash, not the composer. This is likely related to the timeline jamming the current placement object into itself and hitting comparer issues because the current placement object is very mutable and breaks the sorted order. That said, I tried a few things, which didn't work, after which I tried forcibly sorting the list before taking the index, which also didn't work, which is quite worrying.

diff --git a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs
index 30c1258f93..ee1231c820 100644
--- a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs
+++ b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs
@@ -32,7 +32,12 @@ public abstract partial class BlueprintContainer<T> : CompositeDrawable, IKeyBin
     {
         protected DragBox DragBox { get; private set; }
 
-        public Container<SelectionBlueprint<T>> SelectionBlueprints { get; private set; }
+        public SelectionBlueprintContainer SelectionBlueprints { get; private set; }
+
+        public partial class SelectionBlueprintContainer : Container<SelectionBlueprint<T>>
+        {
+            internal void Sort() => SortInternal();
+        }
 
         public SelectionHandler<T> SelectionHandler { get; private set; }
 
@@ -95,7 +100,7 @@ private void load()
             });
         }
 
-        protected virtual Container<SelectionBlueprint<T>> CreateSelectionBlueprintContainer() => new Container<SelectionBlueprint<T>> { RelativeSizeAxes = Axes.Both };
+        protected virtual SelectionBlueprintContainer CreateSelectionBlueprintContainer() => new SelectionBlueprintContainer { RelativeSizeAxes = Axes.Both };
 
         /// <summary>
         /// Creates a <see cref="Components.SelectionHandler{T}"/> which outlines items and handles movement of selections.
@@ -513,6 +518,7 @@ protected virtual void UpdateSelectionFromDragBox(HashSet<T> selectionBeforeDrag
         protected virtual void OnBlueprintSelected(SelectionBlueprint<T> blueprint)
         {
             SelectionHandler.HandleSelected(blueprint);
+            SelectionBlueprints.Sort();
             SelectionBlueprints.ChangeChildDepth(blueprint, 1);
         }
 
diff --git a/osu.Game/Screens/Edit/Compose/Components/EditorBlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/EditorBlueprintContainer.cs
index 378d378be3..7b046251e0 100644
--- a/osu.Game/Screens/Edit/Compose/Components/EditorBlueprintContainer.cs
+++ b/osu.Game/Screens/Edit/Compose/Components/EditorBlueprintContainer.cs
@@ -9,7 +9,6 @@
 using System.Linq;
 using osu.Framework.Allocation;
 using osu.Framework.Graphics;
-using osu.Framework.Graphics.Containers;
 using osu.Framework.Input;
 using osu.Framework.Input.Events;
 using osu.Game.Rulesets.Edit;
@@ -136,7 +135,7 @@ protected override bool OnDoubleClick(DoubleClickEvent e)
             base.ApplySelectionOrder(blueprints)
                 .OrderBy(b => Math.Min(Math.Abs(EditorClock.CurrentTime - b.Item.GetEndTime()), Math.Abs(EditorClock.CurrentTime - b.Item.StartTime)));
 
-        protected override Container<SelectionBlueprint<HitObject>> CreateSelectionBlueprintContainer() => new HitObjectOrderedSelectionContainer { RelativeSizeAxes = Axes.Both };
+        protected override SelectionBlueprintContainer CreateSelectionBlueprintContainer() => new HitObjectOrderedSelectionContainer { RelativeSizeAxes = Axes.Both };
 
         protected override SelectionHandler<HitObject> CreateSelectionHandler() => new EditorSelectionHandler();
 
diff --git a/osu.Game/Screens/Edit/Compose/Components/HitObjectOrderedSelectionContainer.cs b/osu.Game/Screens/Edit/Compose/Components/HitObjectOrderedSelectionContainer.cs
index 8f54d55d5d..49106436b2 100644
--- a/osu.Game/Screens/Edit/Compose/Components/HitObjectOrderedSelectionContainer.cs
+++ b/osu.Game/Screens/Edit/Compose/Components/HitObjectOrderedSelectionContainer.cs
@@ -4,7 +4,6 @@
 using osu.Framework.Allocation;
 using osu.Framework.Extensions.ObjectExtensions;
 using osu.Framework.Graphics;
-using osu.Framework.Graphics.Containers;
 using osu.Game.Rulesets.Edit;
 using osu.Game.Rulesets.Objects;
 using osu.Game.Rulesets.Objects.Types;
@@ -14,7 +13,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
     /// <summary>
     /// A container for <see cref="SelectionBlueprint{HitObject}"/> ordered by their <see cref="HitObject"/> start times.
     /// </summary>
-    public sealed partial class HitObjectOrderedSelectionContainer : Container<SelectionBlueprint<HitObject>>
+    public sealed partial class HitObjectOrderedSelectionContainer : BlueprintContainer<HitObject>.SelectionBlueprintContainer
     {
         [Resolved]
         private EditorBeatmap editorBeatmap { get; set; } = null!;
diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs
index a6af83d268..c63219569d 100644
--- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs
+++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs
@@ -91,7 +91,7 @@ private void placementChanged(ValueChangedEvent<HitObject> obj)
             }
         }
 
-        protected override Container<SelectionBlueprint<HitObject>> CreateSelectionBlueprintContainer() => new TimelineSelectionBlueprintContainer { RelativeSizeAxes = Axes.Both };
+        protected override SelectionBlueprintContainer CreateSelectionBlueprintContainer() => new TimelineSelectionBlueprintContainer { RelativeSizeAxes = Axes.Both };
 
         protected override bool OnDragStart(DragStartEvent e)
         {
@@ -287,7 +287,7 @@ protected override void OnHoverLost(HoverLostEvent e)
             }
         }
 
-        protected partial class TimelineSelectionBlueprintContainer : Container<SelectionBlueprint<HitObject>>
+        protected partial class TimelineSelectionBlueprintContainer : SelectionBlueprintContainer
         {
             protected override Container<SelectionBlueprint<HitObject>> Content { get; }
 

bdach avatar Oct 18 '24 13:10 bdach

Sentry issue: OSU-11TG

ppy-sentryintegration avatar Oct 18 '24 13:10 ppy-sentryintegration