macOS bug: OpenGL Core Profile using software rendering without any error! & FIX

macOS bug: OpenGL Core Profile using software rendering without any error! & FIX

metacollinTCEAD
Explorer Explorer
1,023 Views
1 Reply
Message 1 of 2

macOS bug: OpenGL Core Profile using software rendering without any error! & FIX

metacollinTCEAD
Explorer
Explorer

I have a few menu bar widgets that display stats like per-core usage, RAM, GPU usage, etc. etc.  

 

And it was with this that I noticed something odd.  Fusion 360 would start using 2800% of my CPU whenever I did, well, almost anything in Fusion 360.  Every single time.  Oh, and 2800% with 100% equalling 1 logical core/thread.  My workstation has dual Xeon 2690 v4 CPUs, and with hyper-threading turned on (as it is on my system) that amounts to 56 logical cores.  So 2800% is equal to 100% utilization of an entire 14 CPU cores - in other words, an entire Xeon CPU worth of effort.  

 

What would cause Fusion 360 to to consume such a huge amount of resources?  Well, rotating an empty design with the smallest window Fusion 360 allows for one.  Or just drawing a selection box.  Or zooming in and out.  Again, this is a completely empty design.  I also have a GTX 1080 with the latest Nvidia Web Drivers.  But, while looking into this somewhat bizarre behavior from Fusion 360, I noticed something else:  My GPU was doing nothing at all.  

 

So I suspected that perhaps Fusion 360 was actually using software rendering for some reason.  If that were the case, that could explain the CPU usage even with an empty design easily.  Even if nothing was being drawn, selection boxes or wiggling the rotation would cause a high rate of redraws to occur.  

 

Here is a video demonstrating this effect.  See the CPU usage in the upper right corner.

 

There is only one explanation for this:  Fusion 360 was falling back to software rendering, but silently. 

Running the graphics diagnostic within Fusion 360 reports everything is fine, accelerated, working.

 

But it's not.

 

Worse, if I chose 'Auto', it would pick the unaccelerated OpenGL Core Profile.  

 

However, oddly, if I used the old OpenGL Compatibility mode, the CPU usage dropped to nothing, while my GPU usage was low to medium, but in response to actions done in Fusion 360, where before it was basically zero.  Fusion 360 was actually using my GPU now, and it was awesome.  A slow, choppy, often laggy or unresponsive and generally frustrating  user experience I had had using Fusion 360 from the start instantly evaporated. 

 

Suddenly, Fusion 360 felt buttery smooth instead of clunky and choppy.  It finally worked and looked like the videos of people using it on Windows.  It's like an entirely different program now.  A terrific one.  

 

But I digress.  This discovery confirmed my suspicious about the software rendering, but the mystery remained:  why? Why was Fusion 360 using software rendering but only in the newer (and better) OpenGL Core driver?  And why was it not giving some sort of error or warning to that effect?  

 

Well, I dug a little deeper.  

 

When using the legacy OpenGL renderer, CGLChoosePixelFormat() is called with identical attributes as with the OpenGL Core Profile, save for setting the KCGLPFAOpenGLProfile attribute to KCGLOGLPVersion_3_2_Core, and omitting the kCGLPFANoRecovery attribute.  

 

I then looked at the OpenGL context that Fusion360 was creating in OpenGL Core Profile mode, and the context had 2 virtual screens, one that was accelerated, and one that used the Apple Software renderer.  And, presumably, for whatever reason the context was falling back or otherwise choosing to use the software renderer virtual screen instead of the accelerated virtual screen.  This can be verified with CGLGetVirtualScreen(), and even enforced using CGLSetVirtualScreen().  

 

I did an OpenGL call trace on Fusion 360, and indeed, when it calls CGLChoosePixelFormat(), &numPixelFormats is getting set to 2.  

 

Maybe it is as simple or easy as just not omitting the kCGLPFANoRecovery attribute?  I didn't really have a way to test this, but it seems to work for the OpenGL legacy profile.  I think there is something else going on though.  

 

I noticed some very odd behavior from Fusion 360 when set to OpenGL Core Profile mode.  For whatever reason, Fusion 360 was rapidly spawning almost 60 OpenGL contexts in rapid succession. This is compared to with the OpenGL Legacy mode, where it spawns... one.  Which is what one would expect, and all it needs.  I can't imagine why it would span on the order of 60 contexts in a row, except that there is definitely some sort of bug in the Core GL code on the mac side.  I think the exact number was 58, but I am had to hand count them.  

 

Maybe that's actually the correct behavior... I don't know what fanciness a more modern version of OpenGL might let Fusion 360 take advantage of.  Maybe a princely sum of rendering contexts is the new fashion, I don't know.  But I am certainly skeptical of that many contexts.  What could it even be doing with them?

 

I've attached the OpenGL call trace taken as Fusion 360 is starting up.  It generates, and does not free, something like 58 contexts in a row I might have missed a few as the program was starting.  I was only able to attach to Fusion 360 after it was running, launching it with OpenGL Profiler just made it hang.  I also looked through the call trace but didn't immediately see anything obviously wrong (with the very incomplete picture one can get from nothing but opengl calls).  I did notice some GL_FRAMEBUFFER_INCOMPLETE flags getting thrown.  Might be something, might be nothing.  

 

I don't know if this is even a bug in Fusion 360, it could very well be some unexpected behavior from Nvidia's Pascel drivers for macOS 10.13.  Who knows. 

 

 

The important take away here is that Fusion 360 is not only falling back to software rendering without any alert or error message (it queries the accelerated virtual screen, yet seems to be drawing to the second, software renderer virtual screen, so it probably thinks it is using hardware acceleration even though it sadly is not), but even worse, this is what the program selects by default, even when you set it to 'Auto'. 

 

The only workaround is to manually change the renderer to the legacy OpenGL profile, but let me say... I've been using Fusion 360 for almost a year with a choppy, generally frustrating and slow to respond interface and user experience because, well, there was never any alert or error letting me know it was using software rendering.  It was only after discovering, mostly by dumb luck today, that switching to the OpenGL legacy profile fixed it, that I investigated further and discovered all this.  

 

I know I'm not the only Fusion 360 user who has complained of choppy and/or somewhat unresponsive behavior of the mac version.  Maybe this is why?  Now, I doubt it is every mac user.  Autodesk would have spotted this if it was common to the entire platform.  But I also very much doubt that this bug effects only me.  If I had to guess, maybe it effects anyone using an after market Nvidia card (via an egpu setup on a laptop is pretty popular these days) or in an older mac pro.  Full disclosure, if you haven't already guessed, I am not using an official Apple machine.  But I have zero issues with OpenGL in any other programs, and use CUDA heavily.  Fusion 360 is the only program that seems to have this problem - for whatever reason.  And if this bug only effected a small subset of your mac users, possibly those with uncommon or unusual configurations (egpu, after market Nvidia Card), that could certainly explain all the complaints on your forums about poor or choppy performance.  Complaints that you'd likely be unable to reproduce on test machines. 

 

All I know is this bug has existed for, well, since I started using fusion.  I would watch instructional videos on youtube, and see how smooth and responsive it behaved for them, and wonder why it was nothing like that when I used it. 

 

Well, finally, its butter smooth and just like the videos I see.  Minus whatever features are lost by using the legacy OpenGL Profile.   

 

Anyway, at the very least, I think you might want to prioritize at least catching this error and alerting the user.  It honestly ruins the entire user experience and makes using Fusion 360 feel a lot more frustrating and unpleasant, since every action you do demands all of one's CPU power to render it.   

 

Regardless, any mac user suffering poor performance in fusion 360... see if switching to the OpenGL profile instead of the OpenGL Core profile helps.  It just might.  

1,024 Views
1 Reply
Reply (1)
Message 2 of 2

TrippyLighting
Consultant
Consultant

I can't say that I've had that sort of problem (I don't run a Hackintoish ...  I've thought about it) , but pretty cool analysis!


EESignature

0 Likes