Benjamin Schmidt
Benjamin Schmidt

Reputation: 1061

AVAudioEngine: HALC_ShellObject errors, no audio. What can I even look for?

In an iOS app running on the Mac via Mac Catalyst, I'm using AVAudioEngine to play an audio file from the bundle. That works totally fine on my iOS devices, but not on the Mac. The code is pretty simple. Both my existing project and the fresh project have this code in the very first UIViewController's viewDidAppear method:

if let audioFileURL = Bundle.main.url(forResource: "audio", withExtension: "mp3") {
    if let audioFile = try? AVAudioFile(forReading: audioFileURL) {
        self.engine = AVAudioEngine()
        self.player = AVAudioPlayerNode()
                
        self.engine.attach(self.player)
        self.engine.connect(self.player, to: self.engine.mainMixerNode, format: audioFile.processingFormat)
                
        do {
            try engine.start()
                    
            self.player.scheduleFile(audioFile, at: nil)
            self.player.play()
        } catch let error {
            print("Error starting engine: \(error)")
        }
    }
}

To emphasize: Both the engine and the player node are properties of the class using them.

This exact code works perfectly fine in a fresh iOS project with Catalyst enabled running on the Mac. This same exact code does not work in an app I started a week ago. Instead I get some errors in the log.

When calling engine.start():

2021-02-04 16:38:20.540726+0100 AudioVision[20560:882974]  HALC_ShellObject::HasProperty: call to the proxy failed, Error: -308 (\M^?\M^?\M-~\M-L)
2021-02-04 16:38:20.542025+0100 AudioVision[20560:882974]  HALC_ProxySystem::GetObjectInfo: got an error from the server, Error: 560947818 (!obj)
2021-02-04 16:38:20.542126+0100 AudioVision[20560:882974]  HALC_ShellObject::HasProperty: there is no proxy object
2021-02-04 16:38:20.545358+0100 AudioVision[20560:882974]  HALC_ProxySystem::GetObjectInfo: got an error from the server, Error: 560947818 (!obj)
2021-02-04 16:38:20.545414+0100 AudioVision[20560:882974]  HALC_ShellObject::HasProperty: there is no proxy object
2021-02-04 16:38:20.546011+0100 AudioVision[20560:882974]  HALC_ProxySystem::GetObjectInfo: got an error from the server, Error: 560947818 (!obj)
2021-02-04 16:38:20.546052+0100 AudioVision[20560:882974]  HALC_ShellObject::HasProperty: there is no proxy object
2021-02-04 16:38:20.546154+0100 AudioVision[20560:882974]  HALC_ProxySystem::GetObjectInfo: got an error from the server, Error: 560947818 (!obj)
2021-02-04 16:38:20.546195+0100 AudioVision[20560:882974]  HALC_ShellObject::HasProperty: there is no proxy object
2021-02-04 16:38:20.546263+0100 AudioVision[20560:882974]  AudioObjectRemovePropertyListener: no object with given ID 320
2021-02-04 16:38:20.546326+0100 AudioVision[20560:882974]  AudioObjectRemovePropertyListener: no object with given ID 320
2021-02-04 16:38:20.546367+0100 AudioVision[20560:882974]  AudioObjectRemovePropertyListener: no object with given ID 320

But the app does not crash, nor throw an exception. It just pretends as if everything is fine, except no audio is playing. Again, the same exact code works just fine in a fresh Mac Catalyst project.

I can't for the life of me find anything regarding those log entries. They do not appear in the working fresh project. I am not doing anything else with Audio in the entire app, only rendering some stuff in an MTKView.

Does anyone have any idea what I could even look for to find the cause?

The app is targeting macOS 11.1 / iOS 14.3 and running on macOS Big Sur 11.2 and iPadOS 14.4 in both cases.

Edit: Further investigation shows that AVAudioPlayer can play audio just fine. The same log messages appear but audio works. Now I'm completely baffled.

Upvotes: 3

Views: 1113

Answers (1)

Benjamin Schmidt
Benjamin Schmidt

Reputation: 1061

I was able to trace the cause of no audio to the "Audio Input" permission for the hardened runtime. As soon as I disable that, audio playback works. That still presents a problem though, as I do need that permission. However, it suggests that it is a bug in macOS Big Sur (the Catalyst part of it).

Upvotes: 3

Related Questions