ppy / osu

rhythm is just a *click* away!
https://osu.ppy.sh
MIT License
15.35k stars 2.28k forks source link

Repeatedly entering Player can crash the game #1758

Closed smoogipoo closed 6 years ago

smoogipoo commented 6 years ago
  1. Select a map
  2. Press enter
  3. Escape to song select while loading
  4. Press enter
  5. Repeat from (2) until crash.

Possible framework fix required.

I have experienced multiple stacktraces here, so I'll try to post all the different ones that I get. The following is by far the most common:

FATAL UNHANDLED EXCEPTION: System.ArgumentException: An item with the same key has already been added. Key: Position
  at System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x000b1] in /Users/builder/data/lanes/5533/mono-mac-sdk/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Collections/Generic/Dictionary.cs:411 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in /Users/builder/data/lanes/5533/mono-mac-sdk/external/bockbuild/builds/mono-x64/external/corert/src/System.Private.CoreLib/src/System/Collections/Generic/Dictionary.cs:234 
  at osu.Framework.Graphics.Transforms.TransformCustom`2[TValue,T].getAccessor (System.String propertyOrFieldName) [0x00027] in /Users/smoogipoo/Repos/Temp/temp-osu/osu-framework/osu.Framework/Graphics/Transforms/TransformCustom.cs:132 
  at osu.Framework.Graphics.Transforms.TransformCustom`2[TValue,T]..ctor (System.String propertyOrFieldName, osu.Framework.Graphics.Transforms.InterpolationFunc`1[TValue] interpolationFunc) [0x0000f] in /Users/smoogipoo/Repos/Temp/temp-osu/osu-framework/osu.Framework/Graphics/Transforms/TransformCustom.cs:161 
  at osu.Framework.Graphics.TransformableExtensions.MakeTransform[TThis,TValue] (TThis t, System.String propertyOrFieldName, TValue newValue, System.Double duration, osu.Framework.Graphics.Easing easing) [0x00000] in /Users/smoogipoo/Repos/Temp/temp-osu/osu-framework/osu.Framework/Graphics/TransformableExtensions.cs:63 
  at osu.Framework.Graphics.TransformableExtensions.TransformTo[TThis,TValue] (TThis t, System.String propertyOrFieldName, TValue newValue, System.Double duration, osu.Framework.Graphics.Easing easing) [0x00000] in /Users/smoogipoo/Repos/Temp/temp-osu/osu-framework/osu.Framework/Graphics/TransformableExtensions.cs:30 
  at osu.Framework.Graphics.TransformableExtensions.MoveTo[T] (T drawable, OpenTK.Vector2 newPosition, System.Double duration, osu.Framework.Graphics.Easing easing) [0x00000] in /Users/smoogipoo/Repos/Temp/temp-osu/osu-framework/osu.Framework/Graphics/TransformableExtensions.cs:307 
  at osu.Game.Rulesets.Osu.Objects.Drawables.Connections.FollowPointRenderer.update () [0x0019f] in /Users/smoogipoo/Repos/Temp/temp-osu/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs:102 
  at osu.Game.Rulesets.Osu.Objects.Drawables.Connections.FollowPointRenderer.set_HitObjects (System.Collections.Generic.IEnumerable`1[T] value) [0x00008] in /Users/smoogipoo/Repos/Temp/temp-osu/osu.Game.Rulesets.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs:51 
  at osu.Game.Rulesets.Osu.UI.OsuPlayfield.PostProcess () [0x00001] in /Users/smoogipoo/Repos/Temp/temp-osu/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs:95 
  at osu.Game.Rulesets.UI.RulesetContainer`1[TObject].loadObjects () [0x0007e] in /Users/smoogipoo/Repos/Temp/temp-osu/osu.Game/Rulesets/UI/RulesetContainer.cs:262 
  at osu.Game.Rulesets.UI.RulesetContainer`1[TObject].load () [0x00042] in /Users/smoogipoo/Repos/Temp/temp-osu/osu.Game/Rulesets/UI/RulesetContainer.cs:211 
  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in /Users/builder/data/lanes/5533/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.Reflection/MonoMethod.cs:305 
  at osu.Game.Screens.Play.Player.load ()
FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: Cannot push to an already exited screen.
  at osu.Framework.Screens.Screen.Push (osu.Framework.Screens.Screen screen) [0x0000b] in /Users/smoogipoo/Repos/Temp/temp-osu/osu-framework/osu.Framework/Screens/Screen.cs:133 
  at osu.Game.Screens.Select.PlaySongSelect.<Start>b__11_1 (osu.Game.Screens.OsuScreen l) [0x00000] in /Users/smoogipoo/Repos/Temp/temp-osu/osu.Game/Screens/Select/PlaySongSelect.cs:139 
  at osu.Framework.Graphics.Containers.CompositeDrawable+<>c__DisplayClass2_0`1[TLoadable].<LoadComponentAsync>b__0 () [0x00000] in /Users/smoogipoo/Repos/Temp/temp-osu/osu-framework/osu.Framework/Graphics/Containers/CompositeDrawable.cs:64 
  at osu.Framework.Graphics.Drawable+<>c__DisplayClass15_1.<LoadAsync>b__2 () [0x00017] in /Users/smoogipoo/Repos/Temp/temp-osu/osu-framework/osu.Framework/Graphics/Drawable.cs:149 
  at osu.Framework.Threading.ScheduledDelegate.RunTask () [0x0000e] in /Users/smoogipoo/Repos/Temp/temp-osu/osu-framework/osu.Framework/Threading/Scheduler.cs:293 
  at osu.Framework.Threading.Scheduler.Update () [0x0023c] in /Users/smoogipoo/Repos/Temp/temp-osu/osu-framework/osu.Framework/Threading/Scheduler.cs:148 
  at osu.Framework.Graphics.Drawable.UpdateSubTree () [0x000a1] in /Users/smoogipoo/Repos/Temp/temp-osu/osu-framework/osu.Framework/Graphics/Drawable.cs:348 
  at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree () [0x00001] in /Users/smoogipoo/Repos/Temp/temp-osu/osu-framework/osu.Framework/Graphics/Containers/CompositeDrawable.cs:469 
  at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree () [0x00061] in /Users/smoogipoo/Repos/Temp/temp-osu/osu-framework/osu.Framework/Graphics/Containers/CompositeDrawable.cs:486 
  at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree () [0x00061] in /Users/smoogipoo/Repos/Temp/temp-osu/osu-framework/osu.Framework/Graphics/Containers/CompositeDrawable.cs:486 
  at osu.Framework.Graphics.Containers.CompositeDrawable.UpdateSubTree () [0x00061] in /Users/smoogipoo/Repos/Temp/temp-osu/osu-framework/osu.Framework/Graphics/Containers/CompositeDrawable.cs:486 
  at osu.Framework.Platform.GameHost.UpdateFrame () [0x000b2] in /Users/smoogipoo/Repos/Temp/temp-osu/osu-framework/osu.Framework/Platform/GameHost.cs:250 
  at osu.Framework.Threading.GameThread.ProcessFrame () [0x00040] in /Users/smoogipoo/Repos/Temp/temp-osu/osu-framework/osu.Framework/Threading/GameThread.cs:115 
  at osu.Framework.Threading.GameThread.runWork () [0x0002d] in /Users/smoogipoo/Repos/Temp/temp-osu/osu-framework/osu.Framework/Threading/GameThread.cs:104 
  at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00014] in /Users/builder/data/lanes/5533/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/thread.cs:68 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00071] in /Users/builder/data/lanes/5533/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:957 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in /Users/builder/data/lanes/5533/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:904 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x0002b] in /Users/builder/data/lanes/5533/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:893 
  at System.Threading.ThreadHelper.ThreadStart () [0x00008] in /Users/builder/data/lanes/5533/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/thread.cs:105 
FreezyLemon commented 6 years ago

Ok, so what's happening here is that the SongSelect starts an async load for the PlayerLoader (and pushes it when done) which in turn loads the Player (and pushes it when done), so the second exception would be explainable like this:

  1. The game pushes the PlayerLoader and starts loading the Player.
  2. The user exits back to the SongSelect and starts another map.
  3. The game pushes a different PlayerLoader and starts loading a different Player.
  4. Now the first Player finishes loading and tries to push itself to the first PlayerLoader which is not current anymore and throws this.

The first exception is a little less clear to me.. This is the code in question that throws the exception:

private static Accessor getAccessor(string propertyOrFieldName)
{
    Accessor result;
    if (accessors.TryGetValue(propertyOrFieldName, out result))
        return result;

    result = findAccessor(typeof(T), propertyOrFieldName);
    accessors.Add(propertyOrFieldName, result);
    return result;
}

So what happens here, apparently, is that TryGetValue returns false, then findAccessor is called (and supposedly finds something), and when it tries to add it to the Dictionary<Accessor> accessors, the exception is thrown with the error "An item with the same key already exists" (the key is 'Position' btw, so this comes from a .MoveTo call).

The key propertyOrFieldName is not changed anywhere in this (and not in findAccessor), so this is probably a threading issue..?

FreezyLemon commented 6 years ago

The cannot push to an already exited screen exception will most likely be fixed by this. Haven't tested it yet though.

The other one is probably coming from inside PlayerLoader.LogoArriving.. not completely sure yet

smoogipoo commented 6 years ago

@peppy Is this fixed?

peppy commented 6 years ago

no idea

peppy commented 6 years ago

Can't reproduce this any more.