Runtime warnings in Juce Demo in Xcode 9.1

opengl

#1

With latest develop tip, in Xcode 9.1 (9B55), running the OpenGL demo triggers a runtime warnings, which Xcode now helpfully provides in the errors pane on the left.

According to its warning [NSView frame] is not supposed to be used by non-main thread. In this case the OpenGL rendering thread calls component.getTopLevelComponent()->getScreenBounds() inside OpenGLContext::CachedImage::updateViewportSize which in turn causes NSViewComponentPeer to call the forbidden method.


#2

Yes, we know, this has been mentioned before. It’s incredibly hard to work around this one, because it’s essential that the paint stuff is called on the GL thread. It’s definitely a false alarm, because the message thread is safely locked when this happens, but there’s no way to shut up the assertion. We’ll try to figure out a workaround, but you’re safe to ignore it for now.


#3

Maybe instead of polling the [NSView frame] you could be notified when it changes and keep its current value in a member?


#4

yeah, a workaround like that is probably the only way to do it. Will have a look soon, as it is quite annoying.


#5

I’ve pushed some workarounds now that should sort out the two issues I saw, let me know if you hit any others!


#6

Looks like now the warnings don’t appear straight away, but once the mouse cursor hovers on the scrollbar on the bottom right they do trigger.


#7

OK, well I have no idea how we could work around every possible place that a component may choose to call things like its window size during a paint call…

I think we might just have to say that we’ve fixed the places where it happens all the time, but for other ones, you can stop the debugger breaking if you go to Scheme/Diagnostics and untick “Pause on Issues”.

The annoying thing is that these are all false alarms, it’s definitely not unsafe, but there’s no way to tell that to the thread checker.


#8

I think that the previously suggested method of having the NSViewComponentPeer keep this frame in a member that it updates when notified of changes would resolve this cleanly.