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

3.5.1: reintroduced a suspend mode in WaitForNextFrame() #1292

Conversation

ivan-mogilko
Copy link
Contributor

The problem is briefly mentioned here: #1287 (comment)

Previously the engine was using allegro timers that were suspended by default when the player switched away from the game. That stopped game from updating and redrawing itself.

The commits f2ab428 and 15489ff broke that behavior. Here we reintroduce it, now implementing the timer lock mechanic directly in the engine. This is a bit naive implementation but somewhat in line with the older code (e.g. see https://github.com/adventuregamestudio/ags/blob/release-3.5.0/Engine/ac/timer.cpp#L40).

@ivan-mogilko ivan-mogilko added this to the 3.5.1 milestone May 23, 2021
Previously the engine was using allegro timers that were suspended by default when the player switched away from the game.
The commits f2ab428 and 15489ff  broke that behavior. Here we reintroduce it, now implementing the timer lock mechanic directly in the engine.
@ivan-mogilko ivan-mogilko force-pushed the release-3.5.1--fix-multitask branch from 6d89bc2 to abd03a8 Compare May 23, 2021 12:27
@ivan-mogilko ivan-mogilko changed the title Engine: reintroduced a suspend mode in WaitForNextFrame() 3.5.1: reintroduced a suspend mode in WaitForNextFrame() May 23, 2021
@ivan-mogilko
Copy link
Contributor Author

ivan-mogilko commented May 23, 2021

In regards to 3.6.0 (SDL2-based), unfortunately this fix is not enough is not suitable.

In allegro version the "switch out" callback is run on a separate thread, and therefore can intercept a game update thread at the moment between two updates (frames). It then allows to suspend and continue game update thread as necessary.

In its current state in 3.6.0 all sdl events are processed on the same thread as game update, which means that if "switch out" event is handled the process will still be inside a game frame function. Therefore we cannot suspend there - it will simply never recover.

To fix this we need to have at least relevant sdl events processed on a separate thread. Perhaps, ideally the events are processed on main thread and the game update has its own. In any case a larger rewrite is necessary.

@ivan-mogilko ivan-mogilko merged commit afb4f8c into adventuregamestudio:release-3.5.1 May 24, 2021
@ivan-mogilko ivan-mogilko deleted the release-3.5.1--fix-multitask branch May 24, 2021 11:06
@ivan-mogilko
Copy link
Contributor Author

In regards to my above comment, I found it's actually possible to solve this in 3.6.0 with a minimal addition, which hopefully will work for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant