SOLVED - Minimize Window LJWGL3 - DIVIDE BY 0

I’m getting an error inside “WINDOWED” environment. When you click on “MINIMIZE”, the function below gets a divide my zero error.
The context return width = 0 and height = 0, because it is minimized.

The last part is dealing with SCALING, it does the divide by 0 error.

    private void updateSizes() {
        // framebuffer size (resolution) may differ from window size (e.g. HiDPI)

        glfwGetWindowSize(window, width, height);
        int windowWidth = width[0];
        int windowHeight = height[0];
        if (settings.getWindowWidth() != windowWidth
                || settings.getWindowHeight() != windowHeight) {
            settings.setWindowSize(windowWidth, windowHeight);
            for (WindowSizeListener wsListener : windowSizeListeners.getArray()) {
                wsListener.onWindowSizeChanged(windowWidth, windowHeight);

        glfwGetFramebufferSize(window, width, height);
        int framebufferWidth = width[0];
        int framebufferHeight = height[0];
        if (framebufferWidth != oldFramebufferWidth
                || framebufferHeight != oldFramebufferHeight) {
            settings.setResolution(framebufferWidth, framebufferHeight);
            listener.reshape(framebufferWidth, framebufferHeight);

            oldFramebufferWidth = framebufferWidth;
            oldFramebufferHeight = framebufferHeight;

        float xScale = framebufferWidth / windowWidth;
        float yScale = framebufferHeight / windowHeight;
        if (oldScale.x != xScale || oldScale.y != yScale) {
            listener.rescale(xScale, yScale);

            oldScale.set(xScale, yScale);


Sounds like a bug in “jme3-lwjgl3”. However, I tried to reproduce it with JME 3.5.2 on Linux and was unsuccessful.

Which version of the library are you using? On which platform(s) have you seen the issue?

I can see this happening in some desktop environments, especially in linux where we have so many of them. I’ve applied a quick fix

Other possible fixes are :

  • ignoring the resize if windows size < 0
  • force scale to 0 if windows size < 0

But i think the one i’ve chosen is the less likely to cause issues.

If you can test it, let me know if this solves your problem @kevinba99 and thanks for the detailed report

1 Like

SO I got the latest 3.6.0 and compiled it.
It prevents the crash on my machine, and the minimize works good for me.
I was using a 3.5 ish, Been a couple of months since I got a pull from github, but it was based on 3.5. Using LWJGL3, Windows 10.

1 Like