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

Current logic to quit Game causes simharness vectorized environment setup to crash #27

Closed
afennelly-mitre opened this issue May 15, 2024 · 0 comments · Fixed by #28
Closed
Assignees
Labels
bug Something isn't working

Comments

@afennelly-mitre
Copy link
Contributor

Summary

From the perspective of simharness, we need to be able to leverage environment vectorization, which is provided by rllib. The crux of the issue is as follows:

If one sub-environment calls pygame.quit(), then it messes with all other sub-environments in the same process who aren’t yet “ready” to quit, causing the program to crash. This happens primarily by setting the rendering property to False:

sim = FireSimulation(...)
sim.rendering = True

...

sim.rendering = False

The final line in the above pseudo code will call self._game.quit() (see this line in simulation.py).

Fix

To resolve this issue, we simply need to add a class variable to the simfire.game.Game class, something like num_active_games that can be incremented when a new Game object is initialized, and decremented when we call Game.quit(). When we try to quit, if num_active_games == 0, only then can we call pygame.quit() with confidence.

@afennelly-mitre afennelly-mitre self-assigned this May 15, 2024
@afennelly-mitre afennelly-mitre changed the title Current logic in Game.quit() causes simharness vectorized environment setup to crash Current logic to quit Game causes simharness vectorized environment setup to crash May 15, 2024
@afennelly-mitre afennelly-mitre added the bug Something isn't working label May 15, 2024
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
None yet
1 participant