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

Workaround for freeze on fullscreen under macOS #819

Closed

Conversation

ayuusweetfish
Copy link
Contributor

Hi all ^ ^

On macOS 10.13.5, the TIC-80 window freezes when fullscreen mode is toggled. Reproducible with both official release and binary built from source.

Only the SDL backend has the problem, and I've traced down the issue to be an upstream issue reported in SDL bugzilla. In short, the Cocoa implementation of SDL_PumpEvents() has a weird behaviour — it may report "no events" during one call and find an event in the next (called in a row without any delay). This would result in some events not processed and thus freezing the SDL window.

I suppose it's better to research a bit more and report it to SDL, but I have come up with a workaround for now. It's very simple, but it's inconvenient for me to confirm it doesn't break on other platforms, so please help with that. Thanks in advance!

Copy link
Owner

@nesbox nesbox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
I suspect SDL GPU library we are using to render the screen, not pure SDL2 lib.
Maybe we have the bug in sdlgpu, I'll check.
Thank you for the fix.

@ayuusweetfish
Copy link
Contributor Author

FYI, the bug can be triggered by changing the event loop as follows:

for (int x = 0; x < 3; ++x) {
    while (SDL_PollEvent(&event)) {
    // ...
    case ...:
        printf("round #%d\n", x + 1);
    }
}

Ideally the output should all be "round 1", but actually there are occasionally "round 2" lines.

@nesbox
Copy link
Owner

nesbox commented Apr 15, 2020

@kawa-yoiko could you please reproduce it on the latest build, because all is ok on my MacBook?
Thank you.

@nesbox nesbox closed this Apr 15, 2020
@ayuusweetfish
Copy link
Contributor Author

Apologies for the late response!

I'm on macOS 10.13.6 and the problem persists with the latest revision 225b67a. The SDL issue mentioned in the original comment has been recently marked as resolved, and after manually upgrading SDL to 2.0.12 it gets way better but still occasionally happens (window does not refresh until a keypress or focus loss). With this workaround patch applied everything goes well. I can provide a screencast if needed; or if it's deemed a minor issue it might as well be fine to leave it as is.

@nesbox nesbox reopened this May 8, 2020
@nesbox
Copy link
Owner

nesbox commented May 8, 2020

I updated SDL to 2.0.12 here d0d961e
and merged your PR here 2fe6166
Thank you.

@nesbox nesbox closed this May 8, 2020
@nesbox nesbox added the bug label May 8, 2020
@nesbox nesbox added this to the 0.80.0 milestone May 8, 2020
@ayuusweetfish
Copy link
Contributor Author

Thanks for the effort 🎉 🚀

I've done a fresh rebuild and the freeze is gone here now.

@nesbox nesbox removed this from the 0.80.0 milestone Jul 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants