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

Stuttering movement and black screen on macOS 10.14 & Xcode 10 #19080

Closed
drelaptop opened this issue Sep 29, 2018 · 24 comments
Closed

Stuttering movement and black screen on macOS 10.14 & Xcode 10 #19080

drelaptop opened this issue Sep 29, 2018 · 24 comments
Assignees
Milestone

Comments

@drelaptop
Copy link
Contributor

  • cocos2d-x version: 3.17

https://discuss.cocos2d-x.org/t/stuttering-movement-and-black-screen-on-macos-10-14-mojave-and-cocos2d-x-3-17/43860

https://discuss.cocos2d-x.org/t/xcode-10-and-clion-black-screen/43780

I think newer issues on Xcode 10 or macOS 10.14 should be solved before next release.

@drelaptop drelaptop added this to the 3.18 milestone Sep 29, 2018
@drelaptop drelaptop self-assigned this Sep 29, 2018
@Volodymyr-13
Copy link

Volodymyr-13 commented Sep 29, 2018

Interesting, same issue happened for me for cocos2d-iphone, because I'm using SpriteBuilderX.
When launching it - no OpenGL view seen, nothing drawn.

I have no idea why it's happening. Tried to change OpenGL view settings, but nothing helps..

@Volodymyr-13
Copy link

Volodymyr-13 commented Sep 29, 2018

@drelaptop @minggo I think I found whats the problem glfw/glfw#1334
also hajimehoshi/ebiten#691 looking this cause it. However, I'm not sure.

@stevetranby
Copy link
Contributor

stevetranby commented Oct 2, 2018

I think I was able to 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 10.14.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) */
//...

@Volodymyr-13
Copy link

Volodymyr-13 commented Oct 2, 2018

I just used Xcode 9. Everything works perfect in it, nothing needs to be changed.
Also, I reported bug to Apple, will see what's happened next. However, I reported only about cocos2d-iphone and SpriteBuilderX app.

Here is info about combinations I tested also:

  • Xcode 10 + 10.14 = BUG
  • Xcode 10 + 10.13.6 = all ok
  • Xcode 9( 9.4.1 tested only ) + 10.14 = all ok
  • Xcode 9( all versions ) + 10.13.6 = all ok

@stevetranby
Copy link
Contributor

@KAMIKAZEUA yeah XCode10+Mojave specific issue. Works fine without hack on XCode10+HighSierra. Probably a bug by Apple. Strange for sure.
(I edited my prev. response to say "hack" instead of "fix", heh)

@Volodymyr-13
Copy link

Volodymyr-13 commented Oct 2, 2018

Thanks. Well, for now I can use Xcode 9 :) I hope Apple will take a look at my bug report and fix this in new Xcode. Also, I tested on 10.1 beta - same.

@Volodar
Copy link

Volodar commented Oct 8, 2018

I think I was able to 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.

Thanks!

@Volodymyr-13
Copy link

My bug(mentioned before) closed as duplicate, I was not first :) who reported that.
So waiting for some new version of Xcode. Looks like problem in it, but I'm thinking that this could be also Mojave. Anyway, best what I can do is keep updated both.

@drelaptop drelaptop changed the title Stuttering movement and black screen on macOS 10.14 and Cocos2d-x 3.17 Stuttering movement and black screen on macOS 10.14 & Xcode 10 Oct 15, 2018
@stevetranby
Copy link
Contributor

Besides wrapping this in a #if XC10+10.14 you can also move the update call hack into its own loop that is only called a finite 2+ times (it seems 2 is enough).

for 3 times { do hack and normal main loop and events stuff }
while { original normal main loop and events stuff w/out hack }

@Volodymyr-13
Copy link

With this current fix, I’m still seeing shuttering, but no black screen.

@stevetranby
Copy link
Contributor

Yeah, looks like Apple broke VSYNC as well in the 10.14 + XCode10's OpenGL framework.
glfw/glfw#1337

SDL maintainer has been posting on Mojave issues as well.
https://twitter.com/icculus/status/1047935131292450816

@Volodymyr-13
Copy link

Volodymyr-13 commented Oct 29, 2018

Ahh, I see now, Apple will kill OpenGL, thats for sure Metal is a new future 🤘

@Volodymyr-13
Copy link

Volodymyr-13 commented Oct 30, 2018

Just tested:
Xcode 10 + 10.14.1 = BUG
Xcode 10.1 + 10.14.1 = BUG

No fixes from Apple and my bug report is not closed, so this issue hasn't been fixed

Got final update from Apple: this should be fixed in 10.14.2

@mars3142
Copy link
Contributor

mars3142 commented Nov 2, 2018

This is fixed in 10.14.2. I just installed the Developer Beta (10.14.2 Beta (18C31g)) and because of that, the issue can be closed.

@stevetranby
Copy link
Contributor

Blank screen is fixed, but it appears stuttering (and I believe vsync not enabled) is still present with a simple MoveBy animation. Maybe a new PR should be opened?

@stevetranby
Copy link
Contributor

Also, it is still in beta so while I'm sure it will continue working, probably should confirm after official release.

@drelaptop
Copy link
Contributor Author

Both are related, I can reopen this issue, and modify the title.

@Volodymyr-13
Copy link

Volodymyr-13 commented Nov 6, 2018

and I believe vsync not enabled) is still present with a simple MoveBy animation.

@stevetranby so it's implemented in cocos2d-x or due to some bug it's not working?

@stevetranby
Copy link
Contributor

@KAMIKAZEUA I'll try to download Xcode 9 and see if I can confirm with real numbers that it runs at 60 fps normally, but 59-65fps on Mojave w/usleep in main loop (see jerky MoveBy, and I'm sure any other per-frame changes), and finally 200-600fps (smooth, but high CPU) on Mojave w/out usleep.

@Bilalmirza
Copy link

@stevetranby is the stuttering fixed? or do I need to apply some changes.

@Bilalmirza
Copy link

So I updated to 10.14.2 the black screen issue is fixed. But the performance has dropped quite a bit.
besides the unstable fps. Even when the fps is stable there is a lot of stuttering. What do you guys suggest I do?

@stevetranby
Copy link
Contributor

stevetranby commented Jan 10, 2019

This is a GLFW issue. Either replace with a custom source version, or wait until it's fixed in GLFW's master and then also added into a future release that Cocos2d will upgrade to.

For now you can try to use XCode 9.x or revert back to High Sierra.

It's been "solved" by the SDL team, and shouldn't be much work, but currently still hasn't been applied to GLFW's code base.
glfw/glfw#1337 (comment)

@Bilalmirza
Copy link

Yeah i think it will be available with glfw 3.3

@stevetranby
Copy link
Contributor

Looks like it's fixed as of MacOS 10.14.4+ with XCode 10.2+.
(not sure if it was fixed in the OS or XCode/SDKs)

This can now be closed and @drelaptop or @minggo should revert the "hack" that was committed:

refs:

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

No branches or pull requests

7 participants