Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
anorderh opened this issue Dec 8, 2023 · 5 comments
Open

Comments

@anorderh
Copy link

anorderh commented Dec 8, 2023

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. LWJGL/lwjgl3#695

@ClementDreptin
Copy link
Owner

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!

@anorderh
Copy link
Author

anorderh commented Dec 9, 2023

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();
}

@ClementDreptin
Copy link
Owner

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.

@anorderh
Copy link
Author

anorderh commented Dec 23, 2023

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/...".

@ClementDreptin
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants