Xcode 10 (and CLion) -> black screen

I use CLion for the development of my game and today I received XCode 10. I use macOS Mojave Beta (18A384a) and everything compiles fine. But the screen is black (desktop build). I tested it with a new created project and see the same behavior. If I switch back to Xcode 9 everything works fine.

The same effect is directly in the XCode build, so I hope it’s not a cmake/CLion problem in the first place.

Has someone the same issue or should I wait for the Golden Master of Mojava arrives? iOS is working fine with Xcode 10. :frowning:

Edit: I use the latest github sources.

I think I was able to fix hack around this issue following other’s advice that the context needs to be updated.
If you haven’t already got it working, let me know if this works for you and if you have any thoughts.
[MacMini, Mojave 12.0, XCode 10]

CCApplication-mac.mm

int Application::run() 
{
//...
    unsigned int ctx_updated_count = 0;
//...
    while (!glview->windowShouldClose())
    {
        //...
        // STEVE: look into doing this outside loop to get rid of condition test per frame
        if(ctx_updated_count < 2) {
            ctx_updated_count++;
            NSOpenGLContext* ctx = (NSOpenGLContext*)glview->getNSGLContext();
            [ctx update];
        }

        director->mainLoop();
        glview->pollEvents();
        //...
    }

CCGLViewImpl-Desktop.h

//...approx. Line 128
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
    id getCocoaWindow() override { return glfwGetCocoaWindow(_mainWindow); }
    id getNSGLContext() override { return glfwGetNSGLContext(_mainWindow); } // STEVE: added
#endif // #if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
//...

CCGLView.h

//...approx. Line 428
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
    virtual id getCocoaWindow() = 0;
    virtual id getNSGLContext() = 0; // STEVE: added
#endif /* (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) */
//...
1 Like

@drelaptop please review this fix?

This is probably a pretty poor hack/workaround. We may want to just leave this as a discussion and wait for Mojave 12.0.1 … or consider working with GLFW community to confirm an appropriate solution.

If anyone in the cocos2d community is running into this issue they should either download XCode 9 and use that for now, or if they already modify engine code then they can use this hack for now.

I probably wouldn’t merge this in just yet.

Yup just asking @drelaptop for his thoughts on this.

This workaround is working for me, but it really looks like a hack.

1 Like

I’d take that as a compliment @stevetranby.

1 Like

I’m further convinced this is an Apple bug … seems like a strange regression. Probably their way of secretly forcing everyone onto using Metal ;-]

I installed today Mojave 10.14.2 Developer Beta (and XCode 10.1) and the issue is gone, without hacking around. So we don’t need any cocos changes.

4 Likes