-
-
Notifications
You must be signed in to change notification settings - Fork 444
Closed
Labels
Milestone
Description
Summary
When realizing multiple windows using the GLFW backend the application will crash in Silk.NET.GLFW.Glfw.PollEvents() after exercising the windows (change focus, resize, mouse over, etc.) with a callstack similar to the following:
Process terminated. A callback was made on a garbage collected delegate of type 'Silk.NET.GLFW!Silk.NET.GLFW.GlfwCallbacks+CursorEnterCallback::Invoke'.
at Silk.NET.GLFW.Glfw.PollEvents()
at Silk.NET.Windowing.Internals.ViewImplementationBase.Silk.NET.Windowing.IView.DoEvents()
The crash timing is random but consistently happens. I am not able to reproduce this with the SDL backend.
Steps to reproduce
- Platform: Desktop
- Framework Version: .NET Core 6, .NET Core 7
- API: OpenGL, GLFW
- API Version: OpenGL 4.5
- Instantiates two or more Silk windows
- Instantiate an InputContext (window.CreateInput()) for each window
- Run the render loop
- Allow the mouse to traverse between windows to allow for the mouse enter message to event through
- Observe crashing exception (note: likely will not happen immediately)
Comments
I've been able to reproduce this on two separate workstations with different hardware profiles in different code bases. I have seen other garbage collected delegate exceptions but most involve some sort of mouse input delegate attached to Glfw.PollEvent().
Minimal example:
using Silk.NET.Windowing;
using Silk.NET.Windowing.Extensions;
using Silk.NET.Input;
using Silk.NET.OpenGL;
namespace ogl;
public class OpenGL
{
private WindowManager windowManager;
private List<IInputContext> inputContexts = new List<IInputContext>();
public OpenGL()
{
windowManager = new WindowManager();
for (int i = 0; i < 4; i++)
windowManager.CreateWindow(WindowOptions.Default);
}
public void Start()
{
foreach(var window in windowManager.Windows)
{
window.Load += () =>
{
var inputContext = window.CreateInput();
inputContexts.Add(inputContext);
};
window.Render += (time) =>
{
var context = GL.GetApi(window.GLContext);
context.Enable(EnableCap.DepthTest);
context.ClearColor(0f, .2f, .2f, 1f);
context.Clear(ClearBufferMask.DepthBufferBit | ClearBufferMask.ColorBufferBit);
};
}
windowManager.Run();
}
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done