juce-framework / JUCE

JUCE is an open-source cross-platform C++ application framework for desktop and mobile applications, including VST, VST3, AU, AUv3, LV2 and AAX audio plug-ins.

Home Page:https://juce.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug][Regression]: ARA plugins assertion failure on load

danra opened this issue · comments

Detailed steps on how to reproduce the bug

  1. Workaround #1307 by reverting 60df982 to get local copy step to work on Logic
  2. Open ARAPluginDemo example in Projucer
  3. Set target macOS to 13 (resolves JUCE's static_assert on the new linker on Xcode 15.0.1)
  4. Save to Xcode project, build, and run Logic Pro 10.8.1 (Rosetta) with debugger attached.
  5. Bug: Assertion failure on load

This is apparently due to the recent Timer changes in 005040d and 47be26d. Reverting these two commits resolves the issue.

What is the expected behaviour?

No assertion failure

Operating systems

macOS

What versions of the operating systems?

14.1.1

Architectures

x86_64

Stacktrace

Thread 1 Queue : com.apple.main-thread (serial)
#0	0x000000013c0eb62c in juce::AsyncUpdater::triggerAsyncUpdate() at /Users/dan/dev/JUCE_vanilla/JUCE/modules/juce_events/broadcasters/juce_AsyncUpdater.cpp:66
#1	0x000000013c0f5fd9 in juce::Timer::TimerThread::TimerThread() at /Users/dan/dev/JUCE_vanilla/JUCE/modules/juce_events/timers/juce_Timer.cpp:35
#2	0x000000013c0f5dc5 in juce::Timer::TimerThread::TimerThread() at /Users/dan/dev/JUCE_vanilla/JUCE/modules/juce_events/timers/juce_Timer.cpp:33
#3	0x000000013c0f5aa1 in juce::SharedResourcePointer<juce::Timer::TimerThread>::Weak::lockOrCreate() at /Users/dan/dev/JUCE_vanilla/JUCE/modules/juce_core/memory/juce_SharedResourcePointer.h:156
#4	0x000000013c0f5965 in juce::SharedResourcePointer<juce::Timer::TimerThread>::SharedResourcePointer() at /Users/dan/dev/JUCE_vanilla/JUCE/modules/juce_core/memory/juce_SharedResourcePointer.h:172
#5	0x000000013c0ece05 in juce::SharedResourcePointer<juce::Timer::TimerThread>::SharedResourcePointer() at /Users/dan/dev/JUCE_vanilla/JUCE/modules/juce_core/memory/juce_SharedResourcePointer.h:90
#6	0x000000013c0ecdd2 in juce::Timer::Timer() at /Users/dan/dev/JUCE_vanilla/JUCE/modules/juce_events/timers/juce_Timer.cpp:293
#7	0x000000013bf8b51d in juce::ARADocumentControllerSpecialisation::ARADocumentControllerImpl::ARADocumentControllerImpl(ARA::PlugIn::PlugInEntry const*, ARA::ARADocumentControllerHostInstance const*, juce::ARADocumentControllerSpecialisation*) at /Users/dan/dev/JUCE_vanilla/JUCE/modules/juce_audio_processors/utilities/ARA/juce_ARADocumentController.cpp:33
#8	0x000000013bf8b49d in juce::ARADocumentControllerSpecialisation::ARADocumentControllerImpl::ARADocumentControllerImpl(ARA::PlugIn::PlugInEntry const*, ARA::ARADocumentControllerHostInstance const*, juce::ARADocumentControllerSpecialisation*) at /Users/dan/dev/JUCE_vanilla/JUCE/modules/juce_audio_processors/utilities/ARA/juce_ARADocumentController.cpp:37
#9	0x000000013bed71d1 in std::__1::__unique_if<juce::ARADocumentControllerSpecialisation::ARADocumentControllerImpl>::__unique_single std::__1::make_unique[abi:v160006]<juce::ARADocumentControllerSpecialisation::ARADocumentControllerImpl, ARA::PlugIn::PlugInEntry const*&, ARA::ARADocumentControllerHostInstance const*&, juce::ARADocumentControllerSpecialisation*>(ARA::PlugIn::PlugInEntry const*&, ARA::ARADocumentControllerHostInstance const*&, juce::ARADocumentControllerSpecialisation*&&) at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/include/c++/v1/__memory/unique_ptr.h:686
#10	0x000000013bed70f3 in juce::ARADocumentControllerSpecialisation::ARADocumentControllerSpecialisation(ARA::PlugIn::PlugInEntry const*, ARA::ARADocumentControllerHostInstance const*) at /Users/dan/dev/JUCE_vanilla/JUCE/modules/juce_audio_processors/utilities/ARA/juce_ARADocumentController.cpp:826
#11	0x000000013bd03b09 in ARADemoPluginDocumentControllerSpecialisation::ARADemoPluginDocumentControllerSpecialisation(ARA::PlugIn::PlugInEntry const*, ARA::ARADocumentControllerHostInstance const*) at /Users/dan/dev/JUCE_vanilla/ARAPluginDemo/Source/ARAPluginDemo.h:711
#12	0x000000013bd03ad5 in ARADemoPluginDocumentControllerSpecialisation::ARADemoPluginDocumentControllerSpecialisation(ARA::PlugIn::PlugInEntry const*, ARA::ARADocumentControllerHostInstance const*) at /Users/dan/dev/JUCE_vanilla/ARAPluginDemo/Source/ARAPluginDemo.h:711
#13	0x000000013bd01458 in juce::ARADocumentControllerSpecialisation::FactoryConfig<ARADemoPluginDocumentControllerSpecialisation>::createDocumentController(ARA::PlugIn::PlugInEntry const*, ARA::ARADocumentControllerHostInstance const*) const at /Users/dan/dev/JUCE_vanilla/JUCE/modules/juce_audio_processors/utilities/ARA/juce_ARADocumentController.h:459
#14	0x000000013be791fe in ARA::PlugIn::PlugInEntry::createDocumentControllerWithDocument(ARA::ARADocumentControllerHostInstance const*, ARA::ARADocumentProperties const*) at /Users/dan/dev/ARA_SDK/ARA_Library/PlugIn/ARAPlug.cpp:2831
#15	0x000000013bd01105 in ARA::PlugIn::PlugInEntry::DispatcherFunctions<&ARA::PlugIn::PlugInEntry::EntryWrapper<juce::ARADocumentControllerSpecialisation::FactoryConfig<ARADemoPluginDocumentControllerSpecialisation>, void>::getEntry()>::createDocumentControllerWithDocument(ARA::ARADocumentControllerHostInstance const*, ARA::ARADocumentProperties const*) at /Users/dan/dev/ARA_SDK/ARA_Library/PlugIn/ARAPlug.h:1860
#16	0x0000000113507a9b in ARA_Interface::SetupSubClass() ()
#17	0x0000000113645947 in ARA_Set::FindOrAdd(ARA_Object*) ()
#18	0x0000000113646235 in ARA_List::FindOrAdd(ARA_Object*) ()
#19	0x00000001136676d8 in MAAEAudioUnit::AU2PlugIn::Enter_macOS(NSArray*) ()
#20	0x0000000113437ec4 in MD::Init(int, CDRV_ALPRunMode_t) ()
#21	0x0000000113478747 in MDCA::Init(int, CDRV_ALPRunMode_t) ()
#22	0x000000010025b137 in ___lldb_unnamed_symbol18190 ()
#23	0x00000001007ac998 in ___lldb_unnamed_symbol29162 ()
#24	0x000000010048a8b8 in ___lldb_unnamed_symbol23198 ()
#25	0x000000010178a79a in ___lldb_unnamed_symbol74489 ()
#26	0x0000000100b431ba in ___lldb_unnamed_symbol38604 ()
#27	0x00007ff80ab88ef6 in __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ ()
#28	0x00007ff80ac18cac in ___CFXRegistrationPost_block_invoke ()
#29	0x00007ff80ac18bfd in _CFXRegistrationPost ()
#30	0x00007ff80ab58e49 in _CFXNotificationPost ()
#31	0x00007ff80ba3a22e in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#32	0x00007ff80e10c03a in -[NSApplication _postDidFinishNotification] ()
#33	0x00007ff80e10bd82 in -[NSApplication _sendFinishLaunchingNotification] ()
#34	0x00007ff80e109e27 in -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] ()
#35	0x00007ff80e109a7c in -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] ()
#36	0x00007ff80ba62d4e in -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] ()
#37	0x00007ff80ba62b61 in _NSAppleEventManagerGenericHandler ()
#38	0x00007ff811c009da in ___lldb_unnamed_symbol868 ()
#39	0x00007ff811c00228 in ___lldb_unnamed_symbol867 ()
#40	0x00007ff811bf9b7d in aeProcessAppleEvent ()
#41	0x00007ff815909664 in AEProcessAppleEvent ()
#42	0x00007ff80e103bae in _DPSNextEvent ()
#43	0x00007ff80e9f7348 in -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] ()
#44	0x0000000101792acd in ___lldb_unnamed_symbol74626 ()
#45	0x00007ff80e0f4dfa in -[NSApplication run] ()
#46	0x00007ff80e0c8e10 in NSApplicationMain ()
#47	0x0000000100acdfc3 in ___lldb_unnamed_symbol37014 ()
#48	0x00000002029aa3a6 in start ()

Plug-in formats (if applicable)

AU

Plug-in host applications (DAWs) (if applicable)

Tested on Logic Pro 10.8.1 (Rosetta)

Testing on the develop branch

The bug is present on the develop branch

Code of Conduct

  • I agree to follow the Code of Conduct

Thanks for reporting I think I see what might be going wrong here I'll take a look tomorrow.

@danra unfortunately we're struggling to reproduce this one. It's a bit of a head scratcher, despite my initial enthusiasm, I'm having a hard time to see how this assertion ever gets hit but more curiously how the commits in question could be the cause. Although they touch the TimerThread, the TimerThread was always created by the first Timer being created and it always called triggerAsyncUpdate() in its constructor so the order of events should be identical. The only conclusion is some kind of race between this and whatever creates the MessageManager (which we're looking into).

Is there potentially anything special / specific about how the plugin is being loaded? maybe you could share a project that always asserts for you when it's loaded? if you're able to try and reproduce this on another machine that could also be a useful data point too.

Thanks.

the TimerThread was always created by the first Timer being created

Are you sure? Looking at the code, and verifying with a breakpoint in TimerThread ctor, prior to 47be26d I do not see it constructed just by constructing a timer. It looks like it only gets constructed when a timer is first added. Whereas after this commit, TimerThread does get immediately constructed along with the Timer construction, as evident in the stack trace attached above. (Maybe that's undesirable new behavior regardless of the assert).

Is there potentially anything special / specific about how the plugin is being loaded? maybe you could share a project that always asserts for you when it's loaded?

I'm actually getting this prior to any project loading - just every time I open Logic 10.8.1 (Rosetta) with the debugger attached, at this stage:
Screenshot 2023-12-08 at 11 32 28

@danra apologies you're absolutely right I thought I remembered we were adding timers in the constructor. I guess this means the change in the Timer has changed user requirements from requiring a MessageManager exists when you call startTimer(), to requiring a MessageManager exists when any object inheriting from Timer is constructed.

I'll give this some thought. Unfortunately I was certainly having issues debugging a Rosetta build, some break points weren't hitting and I even had a crash that didn't stop the debugger.

@szarvas has kindly taken this up and has been taking a look.

Thank you for reporting.

This has been fixed on develop
00e96e7