If my application is open when changing my Mac’s Light/Dark theme it triggers START_JUCE_APPLICATION() in main.cpp and then crashes. For my Mac users that have their theme set to “auto”, which automatically changes the theme at certain times of the day, this has been causing a crash if the app is open at that time.
I’m testing on Mac Sonoma, with Juce 7.0.9. Here’s the stack trace:
Thread 0 Crashed:: JUCE Message Thread Dispatch queue: com.apple.main-thread
0 ??? 0x0 ???
1 CoreFoundation 0x183c868ec ___CFXRegistrationPost_block_invoke + 88
2 CoreFoundation 0x183c86834 _CFXRegistrationPost + 440
3 CoreFoundation 0x183bc148c _CFXNotificationPost + 764
4 CoreFoundation 0x183bf28fc CFNotificationCenterPostNotificationWithOptions + 136
5 SkyLight 0x1894d1a20 post_coordinated_distributed_notification(CGSNotificationType, void*, unsigned int, void*) + 264
6 SkyLight 0x18922bd14 CGSPostLocalNotification + 188
7 SkyLight 0x18922b8f0 (anonymous namespace)::notify_datagram_handler(unsigned int, CGSDatagramType, void*, unsigned long, void*) + 116
8 SkyLight 0x1895be1f8 CGSDatagramReadStream::dispatchMainQueueDatagrams() + 228
9 SkyLight 0x1895be0f4 invocation function for block in CGSDatagramReadStream::mainQueueWakeup() + 28
10 libdispatch.dylib 0x183971cb8 _dispatch_call_block_and_release + 32
11 libdispatch.dylib 0x183973910 _dispatch_client_callout + 20
12 libdispatch.dylib 0x183981fa8 _dispatch_main_queue_drain + 984
13 libdispatch.dylib 0x183981bc0 _dispatch_main_queue_callback_4CF + 44
14 CoreFoundation 0x183c3f15c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
15 CoreFoundation 0x183bfca80 __CFRunLoopRun + 1996
16 CoreFoundation 0x183bfbc5c CFRunLoopRunSpecific + 608
17 HIToolbox 0x18e175448 RunCurrentEventLoopInMode + 292
18 HIToolbox 0x18e175284 ReceiveNextEventCommon + 648
19 HIToolbox 0x18e174fdc _BlockUntilNextEventMatchingListInModeWithFilter + 76
20 AppKit 0x1873d6c54 _DPSNextEvent + 660
21 AppKit 0x187bacebc -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 716
22 AppKit 0x1873ca100 -[NSApplication run] + 476
23 Syntorial 0x104b176b0 juce::MessageManager::runDispatchLoop() + 36 (juce_mac_MessageManager.mm:359) [inlined]
24 Syntorial 0x104b176b0 juce::JUCEApplicationBase::main() + 144 (juce_ApplicationBase.cpp:265) [inlined]
25 Syntorial 0x104b176b0 juce::JUCEApplicationBase::main(int, char const**) + 196 (juce_ApplicationBase.cpp:243) [inlined]
26 Syntorial 0x104b176b0 main + 236 (Main.cpp:128)
27 dyld 0x1837a50e0 start + 2360
Since this crash doesn’t involve any code that I’ve added to the JUCE-generated portion of my app, I figured this would happen with other Juce apps, so I tested with Projucer itself. But when changing the light/dark theme while Projucer is open, START_JUCE_APPLICATION() does not get triggered and thus no crash.
Any ideas? Is there a setting in Projucer, or maybe in the plist that I need to change to prevent JUCE’s START_JUCE_APPLICATION() from triggering upon theme change?
