Audio Unit hosting: Mysterious Error thrown when key presses dispatched: (Is anyone from Apple out there ?) ...

In our audio unit host, we're seeing the following error thrown when keypresses are dispatched to an audio unit view , does anyone know what it means and more importantly what might be causing it ? ....

I can only guess that perhaps an object has been released or not retained properly somewhere but cannot find a solution.

This is error message when caught in the debugger

_Thread 1: "assertion failed: '<AUAudioUnitRemoteViewController: 0x600002b00c60> does not conform to AUAudioUnitViewControllerHostInterface' in -[NSRemoteView ensureClientExportedObject] on line 7080 of file /AppleInternal/Library/BuildRoots/66382bca-8bca-11ec-aade-6613bcf0e2ee/Library/Caches/com.apple.xbs/Sources/ViewBridge/NSRemoteView.m"

A bit more info:   It’s beginning to look a bit like a system bug.  But when you’re developing an audio unit host the documentation that Apple provides is so poor one  has to play the trial and error game far too often  …

At first I thought it was possibly related to us hosting the AU view in a SwiftUI view using NSRepresentable. 

So I removed SwiftUI from the equation and simply put the AU view directly into a floating panel/window.

And I still got similar crashes:

_- The issue will only crash the host if the audio unit  is loaded  “OUT OF PROCESS” 

The exception is always thrown after two or more  key events occur, whether or not the audio unit is in or out of process.When the AU is IN PROCESS however,  an exception is reported in the debugger but it appears something internal to the api must be catching the exception hence preventing a crash.From the console crash logs it does appear that some part of the audio unit view hierarchy  is being released internally …. (I’ll have to post the log in another message, due to character limits)

_ So a workaround is to host all audio units in-process which is a bit of a downside  but at least for now it’s working.

I would love to know if anyone else has experience anything like this. !!  

.. I think I’ll file a bug report but I don’t hold out any hope whatsoever :( ...

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread

0   AppKit                            0x7ff80b5535c5 -[NSWindow _setKeyViewGroupBoundaryNeedsRecalc:] + 32

1   AppKit                            0x7ff80b53b4e9 -[NSView _primitiveSetNextKeyView:] + 227

2   AppKit                            0x7ff80b57989a -[NSView _removeNextPointersToMe] + 602

3   AppKit                            0x7ff80b579428 -[NSView _removeFromKeyViewLoop] + 203

4   AppKit                            0x7ff80b578ddb -[NSView _finalize] + 797

5   AppKit                            0x7ff80b578986 -[NSView dealloc] + 119

6   libdispatch.dylib                 0x7ff808886317 _dispatch_client_callout + 8

7   libdispatch.dylib                 0x7ff808892c78 _dispatch_main_queue_drain + 943

8   libdispatch.dylib                 0x7ff8088928bb _dispatch_main_queue_callback_4CF + 31

9   CoreFoundation                    0x7ff808b459c7 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9

10  CoreFoundation                    0x7ff808b0693f __CFRunLoopRun + 2771

11  CoreFoundation                    0x7ff808b057ac CFRunLoopRunSpecific + 562

12  HIToolbox                         0x7ff81178cce6 RunCurrentEventLoopInMode + 292

13  HIToolbox                         0x7ff81178ca4a ReceiveNextEventCommon + 594

14  HIToolbox                         0x7ff81178c7e5 _BlockUntilNextEventMatchingListInModeWithFilter + 70

15  AppKit                            0x7ff80b52c5cd _DPSNextEvent + 927

16  AppKit                            0x7ff80b52ac8a -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1394

17  ViewBridge                        0x7ff8100581c2 __75-[NSViewServiceApplication nextEventMatchingMask:untilDate:inMode:dequeue:]_block_invoke + 111

18  ViewBridge                        0x7ff810058003 -[NSViewServiceApplication _withToxicEventMonitorPerform:] + 114

19  ViewBridge                        0x7ff810045bf3 -[NSViewServiceApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 151

20  AppKit                            0x7ff80bcfd55e -[NSTextView _bellerophonTrackMouseWithMouseDownEvent:originalSelection:granularity:extending:rectangular:toggling:multiple:autoscrollEvent:] + 1402

21  AppKit                            0x7ff80b8e8710 -[NSTextView mouseDown:] + 7259

22  AppKit                            0x7ff80b72a1f1 -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 4859

23  AppKit                            0x7ff80b69e39e -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 2582

24  AppKit                            0x7ff80b69d76e -[NSWindow(NSEventRouting) sendEvent:] + 352

25  AppKit                            0x7ff80b69bb44 -[NSApplication(NSEvent) sendEvent:] + 352

26  ViewBridge                        0x7ff81004666b __65-[NSViewServiceApplication sendEventWithoutCatch:withForwarding:]_block_invoke + 115

27  ViewBridge                        0x7ff8100465bd -[NSViewServiceApplication eventHasNotHitWindow:actions:] + 62

28  ViewBridge                        0x7ff810046337 -[NSViewServiceApplication sendEventWithoutCatch:withForwarding:] + 344

29  ViewBridge                        0x7ff8100d37ce +[ViewBridgeUtilities allowSettingMousePointerImageInBackground:whilePerformingActions:] + 239

30  ViewBridge                        0x7ff81004612f -[NSViewServiceApplication sendEvent:withForwarding:] + 103

31  AppKit                            0x7ff80b95496b -[NSApplication _handleEvent:] + 65

32  AppKit                            0x7ff80b51d35e -[NSApplication run] + 623

33  AppKit                            0x7ff80b4f12b7 NSApplicationMain + 817

34  libxpc.dylib                      0x7ff808785874 _xpc_objc_main + 867

35  libxpc.dylib                      0x7ff808785239 xpc_main + 99

36  ViewBridge                        0x7ff81003f406 -[NSXPCSharedListener resume] + 16

37  ViewBridge                        0x7ff8100417e6 NSViewServiceApplicationMain + 1326

38  AUHostingServiceXPC                  0x105c738c8 0x105c6d000 + 26824

39  dyld                                 0x10cd5d51e start + 462

Thread 1:

0   libsystem_pthread.dylib           0x7ff808a3cf48 start_wqthread + 0

… 

Audio Unit hosting: Mysterious Error thrown when key presses dispatched: (Is anyone from Apple out there ?) ...
 
 
Q