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

Improve game entry/exit with more hooks for disposal + docs #1296

Open
Cervator opened this issue Oct 18, 2014 · 3 comments
Open

Improve game entry/exit with more hooks for disposal + docs #1296

Cervator opened this issue Oct 18, 2014 · 3 comments
Assignees
Labels
Category: Doc Requests, Issues and Changes targeting javadoc and module documentation Topic: Architecture Requests, Issues and Changes related to software architecture, programming patterns, etc.

Comments

@Cervator
Copy link
Member

Cervator commented Oct 18, 2014

This is in response to recent disposal issues (mainly #1266) and the idea of including System.exit to be sure to not leaving ghost processes around (#1292)

I'm reluctant to just dive in with plain System.exit to avoid dead processes when we don't have a more solid way to catch disposal issues. We're in much better shape now than a couple weeks ago, but might still have some issues floating around with more that could pop up later and hide behind a System.exit

I'd like to make sure we catch all (few) entry and exit points and make them work consistently. For instance the recent activity with the PC facade hasn't been tested with the Applet facade to my knowledge (and the AWT facade which @mkienenb was close to fixing). Probably the browser is hard-killing the applet, but anyway.

To go with this I think we should document entry and exit points as an engine feature with its own forum thread and wiki page. Along with what the few exit codes indicate. Maybe we can somehow log the state of disposal immediately before System.exit (new utility method?) so if there is still something left we have a chance to find out. Keeping in mind the game may be unstable (out of memory, etc). Maybe there are other good metrics we can write on shutdown?

Not in a big rush to get this done (thus target beta or sooner) as there are several things I'd like to wait on / take into account:

@Cervator Cervator added Category: Doc Requests, Issues and Changes targeting javadoc and module documentation Topic: Architecture Requests, Issues and Changes related to software architecture, programming patterns, etc. labels Oct 18, 2014
@Cervator Cervator added this to the Beta milestone Oct 18, 2014
@Cervator
Copy link
Member Author

Cervator commented Mar 1, 2015

Just to make a note of it - a few disposal issues have been sneaking back in slowly. I don't have a lot of details I just notice occasionally when crashing the game during testing.

@msteiger also mentioned an invalid port scenario over in #1622

@TheFlash98
Copy link
Member

I think more shutdownhooks are needed which will initiate threads to take care of the issue. A thread will be called for every System.exit, this will improve logging and help make all the exits work consistently. Maybe this - https://javapapers.com/core-java/jvm-shutdown-hook/ They will help to check the state of disposal as well.

@TheFlash98
Copy link
Member

There are three exit points which use System.exit(code); to shutdown:

  • One occurs when there is an issue finding the path to the static libraries, uses exit code: 1.
  • Another occurs when there is an exception in getting the homepath for the game, use exit code: 0.
  • When the user asks for help or uses any other usage flags. The program prints the usage uses exit code: 0.

Note: System.exit(0) is generally used to indicate successful termination. System.exit(1) or System.exit(-1) or any other non-zero value generally indicates unsuccessful termination. However this is only a convention.

Exit points created using shutdown() method of GameEngine:

  • When the window's "close" button is clicked, LWJGL's isCloseRequested gives a true value and the shutdown is initiated.
  • command shutdownserver triggers a engine shutdown.
  • command exit does the same as above
  • exit terasology button on death screen
  • exit terasology button on the main menu screen
  • exit terasology button on the pause menu screen
  • HeadlessStateChangeListener: This listener checks whether the engine goes back to the main menu, which for a headless server signals the server should be shut down. This happens mainly in cases where the loading process was not successful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Doc Requests, Issues and Changes targeting javadoc and module documentation Topic: Architecture Requests, Issues and Changes related to software architecture, programming patterns, etc.
Projects
None yet
Development

No branches or pull requests

3 participants