Window size is incorrect if a game is restarted in the same JVM process
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 25.4k
- Forks
- 6.5k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 5
Description
Issue details
When restarting a game in the same JVM process, the window size is not set correctly. By restarting a game, I mean that I click the X in the top right corner, and then create a new instance of my LwjglApplication. The window size is not the same the second time. The third time, it's back to the correct size, and it keeps cycling between the correct size and the incorrect size if I keep restarting the game. Here is a video demonstrating the behavior: https://pix.asidik.com/tomski-W4Ucru.mp4
If the window size is set in the LwjglApplicationConfig passed to LwjglApplication, then the second time the game starts, the window is as large as the monitor.
Reproduction steps/code
I'm programming in Clojure (that is the reason I want to be able to restart the game in the same JVM), and I don't have a development environment set up for Java. However, the program below is equivalent to my Clojure program. But I have not tested it.
Setting the static variables in Gdx to null is needed to be able to restart the game at all.
import com.badlogic.gdx.*;
import com.badlogic.gdx.backends.lwjgl.*;
import com.badlogic.gdx.graphics.*;
class LibGDXTest
{
static void main(String[] args)
{
runOnce();
runOnce();
runOnce();
runOnce();
}
static void runOnce()
{
Gdx.app = null;
Gdx.audio = null;
Gdx.files = null;
Gdx.gl = null;
Gdx.gl20 = null;
Gdx.gl30 = null;
Gdx.graphics = null;
Gdx.input = null;
Gdx.net = null;
ApplicationListener game = new ApplicationListener()
{
public void create()
{
}
public void render()
{
Gdx.gl.glClearColor(0, 0, 0, 0);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
}
public void dispose()
{
}
public void pause()
{
}
public void resize(int w, int h)
{
}
public void resume()
{
}
};
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.width = 100;
config.height = 100;
config.forceExit = false;
LwjglApplication app = new LwjglApplication(game, config);
Thread.sleep(1000);
app.exit();
Thread.sleep(1000);
}
}
Version of LibGDX and/or relevant dependencies
LibGDX version 1.9.6. I was using the following dependencies:
com.badlogicgames.gdx/gdx "1.9.6"
com.badlogicgames.gdx/gdx-backend-lwjgl "1.9.6"
com.badlogicgames.gdx/gdx-platform "1.9.6"
Please select the affected platforms
I have only tried it on a Linux Mint desktop.
- Android
- iOS (robovm)
- iOS (MOE)
- HTML/GWT
- Windows
- Linux
- MacOS
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with LwjglApplication and LwjglApplicationConfiguration, then reproduce the repeated app.exit and restart sequence from the issue on Linux using LibGDX 1.9.6. Trace how the window dimensions are applied across successive instances. Done means the configured 100x100 window size remains consistent through repeated restarts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- desktop-dev, game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100