Paint From Background Thread (Main Thread Checker) Xcode 9 JUCE 5.1.2


#1

Hey All,

Computer updated to Xcode 9 causing me to update to JUCE 5.1.2 for the AU build fix.

Seems now though, that calling repaint from a background thread even after gaining the messagemanager lock is causing some warnings & issues to popup.

From Xcode:

Main Thread Checker: UI API called on a background thread: -[NSView setNeedsDisplayInRect:]
PID: 41945, TID: 715758, Thread name: Pool, Queue name: com.apple.root.default-qos.overcommit, QoS: 21
Backtrace:
4   App                              0x000000012cb402a9 _ZN4juce19NSViewComponentPeer25setNeedsDisplayRectanglesEv + 169
5   App                              0x000000012cb3f4ce _ZN4juce19NSViewComponentPeer7repaintERKNS_9RectangleIiEE + 414
6   App                              0x000000012c9e1224 

This is from a background thread who’s responsibility is to render audio thumbnails and then paint them once done rendering & saving to an image.

It’s possible that this code isn’t the greatest and perhaps this has uncovered an underlying issue on my end as it’s fairly old, but just wondering if anyone else has hit this, or if the JUCE team is aware of this new change with the new Xcode SDK and has given some testing around it.

They have added: Main Thread Checker

At app launch, the Main Thread Checker dynamically replaces the implementations of methods that should only be called on the main thread with a version that prepends the check. Methods known to be safe for use on background threads are excluded from this check.

So it seems these calls are now failing the Main Thread Checker. The strangest part is that the code hangs for the threadpooljobs now as if they were not even on a background thread.

Thanks,

J


#2

Yes, looks like the main thread checker is going to become a bit of a headache for everyone.

Odd to see that they don’t consider a repaint to be safe, I’d have thought that’s one of the few bits of GUI code that should be accessible from other threads… In juce we can work around that by posting a message, but it seems a bit annoying since as far as I know it does work OK.


#3

Definitely, I’ve never had a problem. But sounds good, async message is the way to go unless you guys find some way to shut them up.

Thanks