When trying to set the swap interval to a value higher than 1 on MacOS (in order to wait for more than one vertical refresh before swapping the buffer), I was seeing the GUI drawing slow down much more than it should.
After doing some timing measurements I found that the
flushBuffer call was repeatedly taking less than 0.5ms which was in turn causing the thread to sleep due to the hack to prevent CPU burn when the window is occluded.
After quite a bit of digging I eventually came across the following documentation:
OpenGL Programming Guide for Mac: Synchronize with the Screen Refresh Rate
It states that the swap interval "can be set only to
1", which is very likely the reason I was experiencing problems.
Could we add an assertion inside
juce_OpenGL_osx.h that ensures only
1 is passed in, perhaps even limiting the incoming value?