stride: Infinite loop in Stride.Core.Threading.Dispatcher.ForBatched

Release Type: Official Release Nuget

Version: 4.2.0.2293

Platform: Windows

Describe the bug I have encountered an issue in the Stride.Core.Threading.Dispatcher class, specifically in the method ForBatched<TJob>. After 5-10 seconds of normal operation, the method enters an infinite loop executing the following code:

while (Volatile.Read(ref batch.ItemsDone) < batch.Total && batch.Finished.WaitOne(0) == false)  
    ThreadPool.Instance.TryCooperate();  

Job queue is empty and TryCooperate returns false. Should result value be ignored?

To Reproduce Unfortunately, due to the size of my project, I cannot easily isolate a minimal code snippet to reproduce the issue. However, I have observed the following conditions when the problem occurs:

  • batch.ExceptionThrown = null
  • batch.Index = 11
  • batch.ItemsDone = 5
  • batch.Total = 6

Environment Details:

  • I use Stride in a “code-only” mode to display static scenes.
  • The issue started appearing after migrating the main project to .NET Core 9.

Expected Behavior: The ForBatched<TJob> method should not enter an infinite loop and should exit gracefully once all items in the batch are processed.

Actual Behavior: The method gets stuck in the loop indefinitely, making the application unresponsive.

Additional Notes: I am not sure if the migration to .NET Core 9 is directly related, but it might be worth investigating as a potential factor.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 22 (1 by maintainers)

Most upvoted comments

I’ll try to find the time to fix it this week end, no promises though

Would be really nice to have -nightly packages automatically built from master branch every day… Having to wait for manually built packages by Stride team is slowing the adoption/fix/update/testing rate.

I built the project from the current github sources and it looks like the demo project works fine. I also checked on my main project and didn’t notice any problems either. It seems to have worked.

Do you plan to put the corrected packages on nuget.org soon?

Ok, thank you, so I should use BodyComponent instead, right? In summary,

  1. I will open a issue for StaticComponent hanging
  2. I will try to swap di BodyComponent in my proj, ant let’s see what happens…

I’ll try to invest some time to create a demo project. It’ll probably take me at least a few days.

Hey, thanks for the report ! I rewrote most of that stuff years ago now and it’s used all over the engine, so having this one pop up now is kind of unexpected I must admit. But still, I tried to repro your issue by moving a larger project to net9 and it hasn’t manifested itself. I understand that you may not be able to isolate it, can you share the whole project with instructions to repro then ? You can do so privately by sending it to contact at eideren .com