glfw: GLFW window leaves stuck process after closing on MacOS

I’ll copy here a comment from @dcabecinhas from issue https://github.com/glfw/glfw/issues/1412 which @elmindreda asked be put into a new issue.

For me, this problem also causes weird behavior when opening new GLFW windows after closing old ones. Each new window appears slightly moved to the right and down, which is the OS trying not to overlap multiple windows (even though the old ones aren’t there anymore). So clearly MacOS still thinks that a closed window is still around, which must be because GLFW is not removing it correctly.

I really hope this can be fixed as it reduces the usability of Makie.jl on Macs quite a bit. I think graphics resources are also not released correctly because of this which reduces battery capacity quickly.

Original comment below:


A window artefact remains in the macOS dock and a hung process shows in the Activity Monitor.app until the main program exists.

The call to GLFW.Terminate() should finalize all GLFW code and windows but that is not happening. The Makie linked issues are precisely because people close the GLFW window, the window disappears from the screen but remain in the dock and as a hung process until the julia process exits.

Having to exit julia to completely finish GLFW is especially troublesome as it clears JIT compiled code and is generally avoided.

System version information:

GLFW version: 3.3.2 Cocoa NSGL EGL OSMesa dynamic macOS 10.15.6

To reproduce:

#include <stdio.h>
#include <unistd.h>
#include <GLFW/glfw3.h>

int main() {
        glfwInit();
        GLFWwindow* win = glfwCreateWindow(400, 400, "Window", NULL, NULL);
        while (!glfwWindowShouldClose(win)) {
                glfwPollEvents();
        }
        glfwDestroyWindow(win);
        printf("window closed\n");

        glfwTerminate();

        printf("After glfwTerminate()\n");
        sleep(20);
}

Notice that a dock icon and a hung process still remain even after After glfwTerminate() is printed to the screen. Further calls to glfwPollEvents() after glfwTerminate() have no effect.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 3
  • Comments: 16

Most upvoted comments

I would like to bump this issue again. Is there anything we can do to help resolve it as end users? I understand if the developers maybe don’t have access to Apple hardware, I’d be willing to assist in trying debugging steps on my machine. In our data visualization software Makie.jl, this specific issue sadly decreases usability a lot because we’re opening GLFW windows in a live REPL session which ideally shouldn’t be closed at all (to avoid startup latency). So having these dead unresponsive windows stick around after trying to close them can only be fixed by killing the main julia process right now.