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

SDL.pumpEvents seems to be required in mainLoop for Windows 10 #66

Closed
JD95 opened this issue Jan 17, 2022 · 5 comments
Closed

SDL.pumpEvents seems to be required in mainLoop for Windows 10 #66

JD95 opened this issue Jan 17, 2022 · 5 comments
Labels
bug Something isn't working correctly

Comments

@JD95
Copy link

JD95 commented Jan 17, 2022

I can't say exactly what changed on my system to cause this, but my monomer projects suddenly started hanging immediately after launch. Even reverting to older commits which I know worked or cloning monomer and building the example projects had the same behavior.

I did a bit of digging and realized that SDL.pollEvents wasn't returning anything after the first frame.

The fix ended up being a call to SDL.pumpEvents before starting the new frame in Monomer.Main.Core.mainLoop

unless shouldQuit (SDL.pumpEvents *> mainLoop window fontManager config newLoopArgs)

I'm hesitant to make a PR given that I'm not sure what exactly changed to cause this, but it is consistently reproducible.

One thought I had was the SDL2 version which is mingw-w64-x86_64-SDL2 2.0.20-1, but I'm at a bit of a loss otherwise.

@fjvallarino
Copy link
Owner

Hi! This is interesting. I'm also leaning on this being an issue with SDL2, or maybe the bindings.

I noticed a new version of the Haskell package was released about a week ago. If you are not using the old Stack LTS (i.e., using Cabal), maybe it's worth trying to fix the sdl2 version to 2.5.3.0, which was released more than a year ago.

I took a quick look, and switching to a previous version of the SDL2 binary with Pacman does not seem to be easy (in case this is the source of the problem).

My Windows box is currently in a bad state; I'll take a look as soon as I get it back to working properly.

@fjvallarino fjvallarino added the bug Something isn't working correctly label Jan 17, 2022
@fjvallarino
Copy link
Owner

It seems you can manually download a specific version of a library from here and install it with:

stack exec -- pacman -U mingw-w64-x86_64-SDL2-2.0.14-2-any.pkg.tar.zst

Removing the current version can be done with:

stack exec -- pacman -R mingw-w64-x86_64-SDL2

@fjvallarino
Copy link
Owner

I upgraded to SDL2 2.0.20, released eight days ago, and I'm having the same issue on macOS. I think it's related to this PR, where it's also discussed that calling SDL_PollEvent in a loop is not a good idea (which is what pollEvents does internally).

I'll take a look to see the recommended way of polling events and implement it.

Thanks for reporting!

@fjvallarino
Copy link
Owner

I went ahead and followed your proposed solution. I looked into implementing the idea suggested here, but I'm not sure it's worth it. If the need arises in the future, it can be reviewed.

This is already merged to main.

Thanks for the diagnostic and the solution!

@fjvallarino
Copy link
Owner

I'll close this issue, since the fix has already been merged to main. It will be included in the 1.3 release (to be released soon). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly
Projects
None yet
Development

No branches or pull requests

2 participants