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

Dragging (selecting) with the mouse while holding down a key in a text box can crash the game #29041

Closed
Gabixel opened this issue Jul 24, 2024 · 2 comments · Fixed by ppy/osu-framework#6485
Labels
osu!framework issue Can't resolve this without changes to osu!framework. priority:1 Very important. Feels bad without fix. Affects the majority of users. type:reliability

Comments

@Gabixel
Copy link
Contributor

Gabixel commented Jul 24, 2024

Type

Crash to desktop

Bug description

The video should easily describe the issue.
It's not a common thing to do, but it's possible to replace a string in a text box while holding down a letter and dragging with the mouse cursor. This seems to cause a crash in some cases. Not sure of the correct scenario to reproduce this 100%, but it seems easy to do (see the video).

I just tried it in the settings and in the collections dropdown (in the carousel) for now. The video shows the former.

Screenshots or videos

2024-07-24.20-05-50.-.Trim.mp4

Version

2024.718.1

Logs

1721844249.runtime.log

Relevant portion:

2024-07-24 18:16:55 [error]: An unhandled error has occurred.
2024-07-24 18:16:55 [error]: System.ArgumentOutOfRangeException: Index and length must refer to a location within the string. (Parameter 'length')
2024-07-24 18:16:55 [error]: at System.String.ThrowSubstringArgumentOutOfRange(Int32 startIndex, Int32 length)
2024-07-24 18:16:55 [error]: at System.String.Substring(Int32 startIndex, Int32 length)
2024-07-24 18:16:55 [error]: at osu.Framework.Graphics.UserInterface.TextBox.get_SelectedText()
2024-07-24 18:16:55 [error]: at osu.Game.Graphics.UserInterface.OsuTextBox.<>c__DisplayClass35_0.<PlayFeedbackSample>b__0()
2024-07-24 18:16:55 [error]: at osu.Framework.Threading.ScheduledDelegate.RunTaskInternal()
2024-07-24 18:16:55 [error]: at osu.Framework.Threading.Scheduler.Update()
2024-07-24 18:16:55 [error]: at osu.Framework.Graphics.Drawable.UpdateSubTree()
2024-07-24 18:16:55 [error]: at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree()
@Gabixel
Copy link
Contributor Author

Gabixel commented Jul 24, 2024

I forgot to point out that I have a custom ruleset, as you can see from the video. I just tried without it - just in case - and the problem persists.

@frenzibyte frenzibyte added type:cosmetic type:reliability osu!framework issue Can't resolve this without changes to osu!framework. labels Jul 24, 2024
@peppy peppy added priority:1 Very important. Feels bad without fix. Affects the majority of users. and removed type:cosmetic labels Sep 5, 2024
@424ever
Copy link
Contributor

424ever commented Jan 4, 2025

Here's a test case for the crash. Note that InputManager.PressKey() did not work for me, so a key needs to be held down while running the test.

diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuTextBox.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuTextBox.cs
index abad7e775c..8d76d671f3 100644
--- a/osu.Game.Tests/Visual/UserInterface/TestSceneOsuTextBox.cs
+++ b/osu.Game.Tests/Visual/UserInterface/TestSceneOsuTextBox.cs
@@ -96,6 +96,31 @@ public void TestSelectAllOnFocus()
             AddAssert("half text selected", () => numberBoxes.First().SelectedText == "54321");
         }
 
+        [Test]
+        public void TestSelectionCrash()
+        {
+            AddStep("create themed content", () => CreateThemedContent(OverlayColourScheme.Red));
+
+            OsuTextBox textBox = null!;
+
+            AddStep("click on normal box", () =>
+            {
+                textBox = this.ChildrenOfType<OsuTextBox>().First();
+                InputManager.MoveMouseTo(textBox);
+                InputManager.Click(MouseButton.Left);
+            });
+
+            AddStep("set text", () =>
+            {
+                textBox.Text = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
+            });
+
+            AddStep("1", () => InputManager.Click(MouseButton.Left));
+            AddStep("2", () => InputManager.PressButton(MouseButton.Left));
+            AddStep("3", () => InputManager.MoveMouseTo(textBox.ScreenSpaceDrawQuad.Centre - new Vector2(200, 0)));
+            AddStep("4", () => InputManager.ReleaseButton(MouseButton.Left));
+        }
+
         private void clearTextboxes(IEnumerable<OsuTextBox> textBoxes) => AddStep("clear textbox", () => textBoxes.ForEach(textBox => textBox.Text = null));
         private void expectedValue(IEnumerable<OsuTextBox> textBoxes, string value) => AddAssert("expected textbox value", () => textBoxes.All(textBox => textBox.Text == value));
     }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
osu!framework issue Can't resolve this without changes to osu!framework. priority:1 Very important. Feels bad without fix. Affects the majority of users. type:reliability
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants