wait on threads to join in engine shutdown
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-08-28 11:18:11 -04:00
parent ff59891c39
commit ab00782e93
7 changed files with 17 additions and 5 deletions

View File

@ -635,6 +635,9 @@ Quitting to main menu
Server utilities provided to scripting engine Server utilities provided to scripting engine
Spawn player character with weapon when testing levels Spawn player character with weapon when testing levels
(08/26/2024)
Automated testing fixes
# TODO # TODO

View File

@ -432,10 +432,10 @@ public class Main {
if(!Globals.HEADLESS && Globals.RUN_CLIENT){ if(!Globals.HEADLESS && Globals.RUN_CLIENT){
glfwTerminate(); glfwTerminate();
} }
//reset globals
Globals.resetGlobals();
//used to signal threads to stop //used to signal threads to stop
Globals.threadManager.close(); Globals.threadManager.close();
//reset globals for good measure (making sure no long-running threads can re-inject entities into scenes)
Globals.resetGlobals();
//shut down audio engine //shut down audio engine
if(!Globals.HEADLESS && Globals.RUN_CLIENT && Globals.RUN_AUDIO && Globals.audioEngine != null && Globals.audioEngine.initialized()){ if(!Globals.HEADLESS && Globals.RUN_CLIENT && Globals.RUN_AUDIO && Globals.audioEngine != null && Globals.audioEngine.initialized()){
Globals.audioEngine.shutdown(); Globals.audioEngine.shutdown();

View File

@ -99,6 +99,14 @@ public class ThreadManager {
for(int i = 0; i < 3; i++){ for(int i = 0; i < 3; i++){
for(LabeledThread thread : activeThreads){ for(LabeledThread thread : activeThreads){
thread.getThread().interrupt(); thread.getThread().interrupt();
try {
thread.getThread().join(10);
if(thread.getThread().isAlive()){
throw new IllegalStateException("Failed to interrupt thread! " + thread.getLabel());
}
} catch (InterruptedException e) {
CodeUtils.todo(e, "Think about how to handle this");
}
} }
try { try {
TimeUnit.MILLISECONDS.sleep(3); TimeUnit.MILLISECONDS.sleep(3);

View File

@ -173,7 +173,7 @@ public class Server implements Runnable {
for(ServerConnectionHandler connection : this.connectionsToCleanup){ for(ServerConnectionHandler connection : this.connectionsToCleanup){
//tell all clients to destroy the entity //tell all clients to destroy the entity
Player player = connection.getPlayer(); Player player = connection.getPlayer();
if(player != null){ if(player != null && player.getPlayerEntity() != null){
ServerEntityUtils.destroyEntity(player.getPlayerEntity()); ServerEntityUtils.destroyEntity(player.getPlayerEntity());
} }
this.activeConnections.remove(connection); this.activeConnections.remove(connection);

View File

@ -655,7 +655,7 @@ public class RenderingEngine {
public void checkError(){ public void checkError(){
int error = this.getError(); int error = this.getError();
if(error != GL11.GL_NO_ERROR){ if(error != GL11.GL_NO_ERROR){
// LoggerInterface.loggerRenderer.ERROR("checkError - " + getErrorInEnglish(error), new IllegalStateException("OpenGL Error")); LoggerInterface.loggerRenderer.ERROR("checkError - " + getErrorInEnglish(error), new IllegalStateException("OpenGL Error"));
} }
} }

View File

@ -17,6 +17,7 @@ public class RenderingExtension implements BeforeEachCallback, AfterEachCallback
public void beforeEach(ExtensionContext context) throws Exception { public void beforeEach(ExtensionContext context) throws Exception {
Globals.WINDOW_DECORATED = false; Globals.WINDOW_DECORATED = false;
Globals.WINDOW_FULLSCREEN = true; Globals.WINDOW_FULLSCREEN = true;
Globals.RUN_AUDIO = false;
Globals.WINDOW_WIDTH = 1920; Globals.WINDOW_WIDTH = 1920;
Globals.WINDOW_HEIGHT = 1080; Globals.WINDOW_HEIGHT = 1080;
TestEngineUtils.initGraphicalEngine(); TestEngineUtils.initGraphicalEngine();

View File

@ -29,7 +29,7 @@ public class TestEngineUtils {
public static void initGraphicalEngine(){ public static void initGraphicalEngine(){
Globals.RUN_CLIENT = true; Globals.RUN_CLIENT = true;
Globals.RUN_SERVER = true; Globals.RUN_SERVER = true;
Globals.RUN_AUDIO = true; Globals.RUN_AUDIO = false;
Globals.HEADLESS = false; Globals.HEADLESS = false;
Profiler.PROFILE = false; Profiler.PROFILE = false;
NetUtils.setPort(0); NetUtils.setPort(0);