Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input related callbacks in GLFW cause an AccessViolationException #2026

Closed
vlOd2 opened this issue Apr 10, 2024 · 2 comments · Fixed by #2115
Closed

Input related callbacks in GLFW cause an AccessViolationException #2026

vlOd2 opened this issue Apr 10, 2024 · 2 comments · Fixed by #2115
Labels
bug Something isn't working

Comments

@vlOd2
Copy link

vlOd2 commented Apr 10, 2024

Summary

When setting any input related callbacks in GLFW, PollEvents causes an AccessViolationException

Steps to reproduce

  • Platform: Desktop
  • Framework Version: .NET 4.7.2
  • API: OpenGL
  • API Version: Legacy/OpenGL 1.1 (I mostly use Silk.NET to port legacy games)
  1. Properly initialize a GLFW context and a window
  2. Use either SetKeyCallback, SetMouseButtonCallback or SetCursorPosCallback (probably others too)
  3. Call PollEvents

Comments

Oddly enough, SetWindowSizeCallback and other non-input related callbacks do not cause an access violation

// Leaving on this callback is fine
glfw.SetWindowSizeCallback(window, (WindowHandle* window, int width, int height) => 
{
	// Code is executed
	// ...
});
// But uncommenting this line, causes an AccessViolationException when polling the events
glfw.SetKeyCallback(window, (WindowHandle * window, Keys key, 
    int scanCode, InputAction action, KeyModifiers mods) =>
{
	// Code is not executed, game crashes
	// ...
});
@Perksey
Copy link
Member

Perksey commented Apr 12, 2024

Does the problem reproduce on .NET 6 or later?

Perksey added a commit that referenced this issue Apr 15, 2024
@vlOd2
Copy link
Author

vlOd2 commented Apr 15, 2024

Does the problem reproduce on .NET 6 or later?

This issue only happens on .NET Framework, not .NET 6+

Perksey added a commit that referenced this issue Apr 23, 2024
* Fix #2026

* Fix #2000, closes #2005

* Fix #2010

* Fix added AL bug (good thing we had tests!)

* Fix #1500

* Undo any unintentional changes

* Add nint overloads for things like VertexAttribPointer

* Fix build errors

* Add more standard cursor shapes

* Upversion natives where necessary

* Patch notes for 2.21

* Reorder literally a single line

* Incorporate #2143/#2066/#2090 in patch notes

* Implement IsExtensionPresent for WGL

* nit

* OpenXR updates?

* Fix flawed constant parsing for Vk/XR

* Add openxr to patch notes

* Update patch notes for 2.21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants