Stuttering movement and black screen on macOS 10.14 & Xcode 10
drelaptop opened this issue ยท 24 comments
- cocos2d-x version: 3.17
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.
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..
@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.
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) */
//...
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
@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)
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.
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!
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.
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 }
With this current fix, Iโm still seeing shuttering, but no black screen.
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
Ahh, I see now, Apple will kill OpenGL, thats for sure Metal is a new future ๐ค
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
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.
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?
Also, it is still in beta so while I'm sure it will continue working, probably should confirm after official release.
Both are related, I can reopen this issue, and modify the title.
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?
@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.
@stevetranby is the stuttering fixed? or do I need to apply some changes.
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?
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)
Yeah i think it will be available with glfw 3.3
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:
- https://github.com/cocos2d/cocos2d-x/pull/19090/files#diff-aada3be4a997e6c3853489783bbc2305
- PR #19090
refs: