Silk.NET icon indicating copy to clipboard operation
Silk.NET copied to clipboard

Silk.Net 2.21 window is stuck after minimizing

Open Arugin opened this issue 1 year ago • 6 comments

Summary

Window is stuck right after minimizing. Everything works as expected in 2.20

Steps to reproduce

  • Platform: Windows
  • Framework Version: .NET 7
  • API: Vulkan
  1. Get the sample https://github.com/dotnet/Silk.NET/tree/main/src/Lab/Experiments/ImGuiVulkan
  2. Update to SIlk.Net 2.21
  3. Run the sample
  4. Minimize the window
  5. Now it stuck and won't expand back

Comments

If you set the version of Silk.Net and all other libraries to 2.20 everything works as expected.

Probably releated to recent changes of resize?

Arugin avatar Jul 02 '24 08:07 Arugin

I have encountered this problem before, where I got stuck in an infinite loop while refactoring the swap chain. This may be related to thread scheduling.

qian-o avatar Jul 04 '24 03:07 qian-o

I am not sure about thread scheduling, this issue is reproduced on a simple vulkan imgui sample from Silk.NET repo which is single threaded.

Arugin avatar Jul 09 '24 07:07 Arugin

Is there a minimal repro for this?

Perksey avatar Jul 27 '24 17:07 Perksey

Yes, as I mentioned in the issue description, it reproduces on Imgui Vulkan sample from this repo: https://github.com/dotnet/Silk.NET/tree/main/src/Lab/Experiments/ImGuiVulkan

Arugin avatar Jul 27 '24 19:07 Arugin

@Perksey hey, did you reproduce this issue? I can prepare reproducable project, if this will help.

Arugin avatar Sep 05 '24 19:09 Arugin

My Windows PC isn't built atm, I can give it a go soon.

Perksey avatar Sep 05 '24 19:09 Perksey

Reproduced, will investigate now.

Perksey avatar Nov 01 '24 13:11 Perksey

I've identified this to be specific to the way our application is written (namely, calling DoEvents within an event callback).

Will investigate why we originally added this safeguard.

Perksey avatar Nov 01 '24 13:11 Perksey

Ok looking at this, this logic was added for the Refresh callback (specifically, it calls the game loop which will call DoEvents which will call the game loop on refresh etc etc)

I'm not quite sure how I want to tackle this. I do want to make it so we can't infinitely recurse, but at the same time it's causing issues and really is just a safeguard. I think I'll just reduce this to just the refresh callback specifically (as that's the most likely cause of recursion, anything else and the user should deal with the consequences of their actions, if any).

Personally I'd love to make this sort of recursion an exception, but this issue is evidence that we have actual code out in the wild using this pattern and therefore that would be irresponsible.

References:

  • https://github.com/dotnet/Silk.NET/pull/1979#discussion_r1529554595
  • https://discord.com/channels/521092042781229087/587346162802229298/1219682023698989067

Perksey avatar Nov 01 '24 13:11 Perksey

Sounds great, thanks!

Arugin avatar Nov 01 '24 14:11 Arugin