High CPU Usage by OpenGL

I’m experimenting some Problems with OpenGL on OSX. Running the OpenGLDemo.h from the examples folder the CPU Usage is about 60-70%. The same issue appears with the OpenGL tutorial.
Running a very similar code with GLFW (replacing the WavefrontObjFile with assimp and using another library to load the images) I obtain an 1-5% CPU usage.
I think this problem appears since OSX 10.14, I’m trying to implement some 2D graphics with opengl and there I have the same problems, the CPU Usage is about 50%.
On Linux there are no problems, the OpenGLDemo uses about 1% CPU. I didn’t test it on Windows yet.
I’m working with Intel HD Graphics 4000 1536 MB.
Taking a look to Instruments its look like Juce Message Thread is doing a lot of work. Is there any workaround?
Regards.

I noticed this after upgrading to XCode 10.
XCode 9 worked fine.

I compiled and executed the code (OpenGL examples) in another computer with OSX 10.13 (High Sierra), Juce 5.4.1, XCode 10, no problems there, 1-5% CPU usage. I think this is a Mojave specific problem.Another people are claiming for similar problems concerning OpelGL and Mojave in Juce. Have the Juce’s developers a work around, or could you reproduce the problem?

The OpenGL examples compiled with XCode 9 work fine on Mojave as well.
Maybe it’s something they changed for Mojave support in XCode 10.

XCode is only an IDE, in order to compile and execute the code you have to use a compiler. With XCode 9 the compiler is Clang 6, with XCode 10 Clang 7, with libc++ (I don’t know the actual version). In order to upgrade clang you have to upgrade the command line tools. I don’t have clang 6 in my Mojave computer, I can try to install it tomorrow. It is possible to use gcc 8 with the XCode instead of Clang, tomorrow I could see if with gcc is possible to achieve a better performance .

When I compile against the MacOSX10.13.sdk (the old one, LLVM 6) there is no problems, all works fine. If I compile against the SDK 10.14 (the new one, LLVM 7) the Juce Threads are working like hell. It looks like a temporary Mojave bug (?) apparently it will be solved with the next update. It will be nice if the Juce’s developers could give an answer about that.

4 Likes