OpenNeighborhood icon indicating copy to clipboard operation
OpenNeighborhood copied to clipboard

MacOS Cocoa Error: "Regular windows do not have icons on macOS"

Open anorderh opened this issue 6 months ago • 5 comments

Hello,

I cloned this project recursively. After compiling and building, I am unable to open the app. I produced this error output when running from the terminal. I am on a Macbook 2019 15-inch with Intel chip, macOS Ventura 13.6.1

[Error]: GLFW error code: (65548) | Cocoa: Regular windows do not have icons on macOS
Failed to initialize OpenGL loader!
Assertion failed: (bd != nullptr && "Did you call ImGui_ImplOpenGL3_Init()?"), function ImGui_ImplOpenGL3_NewFrame, file imgui_impl_opengl3.cpp, line 352.
Abort trap: 6

While there is an ImGuI failed assertion, I believe GLFW may be the primary culprit. I found a thread for a seperate project going more into depth into this macOS Cocoa error. https://github.com/LWJGL/lwjgl3/issues/695

anorderh avatar Dec 08 '23 06:12 anorderh

Hi! Thanks for the bug report! I unfortunately don't have a macOS machine so I could never test anything on that platform besides the automatic builds in github actions. I know it says the error occurred in ImGui but can you try to wrap line 72 to line 82 in Window.cpp with an #ifdef PLATFORM_MACOS guard to see if the problem still occurs? If you find a sustainable solution, I would love to get a PR for it!

ClementDreptin avatar Dec 09 '23 12:12 ClementDreptin

Ahh seems it was 2 separate errors. Skipping the icon setting for PLATFORM_MACOS removed the GLFW error but the ImGui error remains.

Failed to initialize OpenGL loader!
Assertion failed: (bd != nullptr && "Did you call ImGui_ImplOpenGL3_Init()?"), function ImGui_ImplOpenGL3_NewFrame, file imgui_impl_opengl3.cpp, line 352.
Abort trap: 6

This is the referenced function in the ImGui dependency, in imgui_impl_opengl3.cpp. I'd be happy to do a PR.

void    ImGui_ImplOpenGL3_NewFrame()
{
    ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData();
    IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplOpenGL3_Init()?");

    if (!bd->ShaderHandle)
        ImGui_ImplOpenGL3_CreateDeviceObjects();
}

anorderh avatar Dec 09 '23 17:12 anorderh

I found this issue which indicates macOS has stricter requirements for the OpenGL context version. This example from ImGui uses a different OpenGL version and sets different GLFW window hints on macOS. You could try something similar to see if it fixes the problem.

ClementDreptin avatar Dec 09 '23 18:12 ClementDreptin

Update. I put the mentioned GLFW window hints into UI:Init for OpenGL version 4.1, which is Mac's last supported version since they dropped it a while ago for Vulkan/Metal. Still ran into the same error.

Failed to initialize OpenGL loader! is getting printed because ImGui_ImplOpenGL3_Init() is failing. Crawling through that, I found this block in ImGui for loading OpenGL on Mac devices

static int open_libgl(void)
{
    libgl = dlopen("/System/Library/Frameworks/OpenGL.framework/OpenGL", RTLD_LAZY | RTLD_LOCAL);
    if (!libgl)
        return GL3W_ERROR_LIBRARY_OPEN;
    return GL3W_OK;
}

Turns out I don't have this filepath. Newer macOS seems to have shifted OpenGLs location around and even maybe require XCode as a dependency...? Might be a solution here. I tried just plugging in paths where I do have a framework folder, but no luck and I'm not really sure if the folder's contents have changed since, with regards to "OpenGL.framework/...".

anorderh avatar Dec 23 '23 20:12 anorderh

I don't understand how you even come to execute this code, this project uses glad to load OpenGL, so ImGui should not try to use its built-in OpenGL loader. I'm very confused. It might be worth running the app in a debugger to see if glad is actually used or not.

ClementDreptin avatar Dec 25 '23 23:12 ClementDreptin