Comments (4)
The bindable dictionary being bound to is updated from network requests: https://github.com/ppy/osu/blob/41c33f74f27822889290aea330ade6654eb6f5a3/osu.Game/Online/Metadata/OnlineMetadataClient.cs#L188-L199.
The underlying issue is very likely a race condition when adding new items to the bindable dictionary during the BindTo()
call.
Locking on them
before BindTo()
will probably resolves the osu! issue.
Isolated repro (100% rate in Release
configuration, Debug
takes a few tries):
[Test]
public void TestThreading()
{
var d = new BindableDictionary<int, string>();
var underTest = new BindableDictionary<int, string>();
var startExecution = new ManualResetEventSlim();
Task.Factory.StartNew(() =>
{
startExecution.Wait(TimeSpan.FromSeconds(10));
for (int i = 0; i < 1000; i++)
d.Add(i, $"test {i}");
});
var t = Task.Factory.StartNew(() =>
{
startExecution.Wait(TimeSpan.FromSeconds(10));
underTest.BindTo(d);
});
startExecution.Set();
t.Wait(TimeSpan.FromSeconds(10));
}
Stack trace from test matches the sentry report:
osu.Framework.Tests.Bindables.BindableDictionaryTest.TestThreading
System.AggregateException : One or more errors occurred. (Destination array is not long enough to copy all the items in the collection. Check array index and length.)
----> System.ArgumentException : Destination array is not long enough to copy all the items in the collection. Check array index and length.
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait(TimeSpan timeout)
at osu.Framework.Tests.Bindables.BindableDictionaryTest.TestThreading() in C:\...\osu-framework\osu.Framework.Tests\Bindables\BindableDictionaryTest.cs:line 1050
--ArgumentException
at System.Collections.Generic.Dictionary`2.CopyTo(KeyValuePair`2[] array, Int32 index)
at System.Collections.Generic.Dictionary`2.System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>.CopyTo(KeyValuePair`2[] array, Int32 index)
at osu.Framework.Bindables.BindableDictionary`2.System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>.CopyTo(KeyValuePair`2[] array, Int32 arrayIndex) in C:\...\osu-framework\osu.Framework\Bindables\BindableDictionary.cs:line 249
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at osu.Framework.Bindables.BindableDictionary`2.Parse(Object input, IFormatProvider provider) in C:\...\osu-framework\osu.Framework\Bindables\BindableDictionary.cs:line 291
at osu.Framework.Bindables.BindableDictionary`2.BindTo(BindableDictionary`2 them) in C:\...\osu-framework\osu.Framework\Bindables\BindableDictionary.cs:line 465
at osu.Framework.Tests.Bindables.BindableDictionaryTest.<>c__DisplayClass64_0.<TestThreading>b__1() in C:\...\osu-framework\osu.Framework.Tests\Bindables\BindableDictionaryTest.cs:line 1045
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__272_0(Object obj)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
from osu-framework.
Bindables aren't thread safe, so I'd say this is up to us to fix osu! side..
from osu-framework.
#5635 is related
from osu-framework.
#5635 is related
I'd argue it's best to just cover this in that thread, and fix the issue osu! side for this one (I'll look into it).
from osu-framework.
Related Issues (20)
- Investigate receiving input without using window event flow HOT 2
- Tablet input should have a property to allow adjusting the mapping target area
- `CancellationToken` should probably always be present in BDL calls
- Input thread blocking causes mouse handling stutters on windows HOT 5
- Game window sometimes does not respond to window size changes
- Periodic AccessViolation somewhere in BASS HOT 1
- Allow custom clear color for the window background HOT 5
- Crash on startup with Wayland fractional scaling
- Implement `CADisplayLink` on macOS for potentially better frame timing HOT 1
- Masking sub-tree creation can be avoided with relative ease HOT 3
- Consider using `WS_EX_NOREDIRECTIONBITMAP` HOT 1
- Flickering on fullscreen Vulkan (AMD gpu, Windows)
- SDL3: Segfault on wayland backend HOT 5
- System.AccessViolationException when reloading `TestSceneTextureUploadPerformance` on vulkan HOT 1
- Platforms other than Windows crash when last windowed mode is borderless in latest master HOT 1
- AddFont() Method can't find my font. HOT 5
- Border smoothness is lost on Android devices HOT 1
- Vulkan renderer causes the game to crash after getting to results screen HOT 2
- Fixing windows ink tablet events on SDL3 HOT 1
- Hard crash on Android due to conflicting linux and android SDL3 libs HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from osu-framework.