Thursday, October 8, 2026
HomeiOS Developmentios - AVAudioPlayer a number of errors - BAD_ACCESS, unrecognized selector, DataSource...

ios – AVAudioPlayer a number of errors – BAD_ACCESS, unrecognized selector, DataSource learn failed, No manufacturing unit id registered for id

[ad_1]

In making an attempt so as to add sound results to my app with AVFoundation/AVAudioPlayer, I’ve encountered a number of points. A few of these are fixed; others solely happen when sounds are purported to be performed in quick succession, in response to person interplay. This may be seen by tapping the sq. view within the middle of the display screen within the MCVE; under a sure price of tapping, solely Errors 1 and a couple of happen, whereas in case you faucet quick sufficient you’ll (as well as) alternately encounter a crash attributable to Error 3 or 4. Though I believe the rate-related errors might have one thing to do with producing too many separate threads and/or these threads leading to simultaneous entry to the identical variable (particularly, when setting the booleans contained in the tuple values of the soundEffects dictionary), it isn’t clear to me why the error is completely different between completely different trials.

A few of these errors have already been mentioned right here on SO or elsewhere, however there doesn’t appear to be a particular working answer to any of them. I’ve linked these discussions on the related factors under, and supplied commentary on why they don’t resolve my app’s issues.
Sadly, from this 6 month outdated unanswered query, in addition to the dearth of consensus on the opposite points, it doesn’t appear to be this will likely be a query with an easy answer. I imagine this query remains to be value asking so as to deliver new consideration to this set of associated issues, and in addition as a result of the code instance right here someway manages to come across all of them without delay. (That wasn’t intentional, only a coincidence! :D) If somebody searches for one of many errors and finally ends up right here, there will likely be a helpful assortment of linked posts for them to take a look at. Any edits are welcome (I meant to make this a Group Wiki, however that choice does not appear to be out there for questions, solely solutions). Be happy so as to add in any further insights/context/particulars that you just suppose would enhance this query, or take away something that detracts or is not related.

Error 1 (Reveals as quickly as app launches, earlier than soundIsAvailable turns into true):
It isn’t simply on the simulator like this dialogue; it additionally happens on an actual iPhone 12. Shifting the AVAudioPlayer declarations to international scope didn’t repair something for me. The sluggish begin has additionally been mentioned right here and right here, however whereas enjoying the silent sound file (I do that inside viewDidLoad) as steered by a number of solutions does present a handy ‘timer’ for setting the soundIsAvailable boolean, it does nothing to keep away from the ~15 second delay earlier than the primary sound will play.

2022-09-20 20:46:57.640005-0500 Sound Errors[32793:2252821]  DataSource learn failed
2022-09-20 20:46:57.706245-0500 Sound Errors[32793:2252828] [plugin] AddInstanceForFactory: No manufacturing unit registered for id <CFUUID 0x600001169da0> F8BB1C28-BAE8-11D6-9C31-00039315CD46
2022-09-20 20:46:57.808740-0500 Sound Errors[32793:2252899]  AudioObjectPropertiesChanged: no such object

Error 2 (Happens after a while, however doesn’t rely on person interplay):

2022-09-20 20:47:12.805329-0500 Sound Errors[32793:2252828] [aqme]                AQMEIO.cpp:199   timed out after 15.000s (0 0); suspension rely=0 (IOSuspensions: )
2022-09-20 20:47:12.805850-0500 Sound Errors[32793:2252828]  AudioDeviceStop: no machine with given ID
2022-09-20 20:47:12.806364-0500 Sound Errors[32793:2252828]  AudioDeviceStop: no machine with given ID
2022-09-20 20:47:12.807407-0500 Sound Errors[32793:2252828] [aqme]  MEDeviceStreamClient.cpp:431   AQME Default-InputOutput: shopper stopping after failed begin: <CA_UISoundClientBase@0x153904f00>; working rely now 0
2022-09-20 20:47:12.808272-0500 Sound Errors[32793:2252828]      CA_UISoundClient.cpp:285   CA_UISoundClientBase::StartPlaying: AddRunningClient failed (standing = -66681).

Error 3: Unhealthy Entry (the thread quantity isn’t constant throughout trials, and nothing is printed to the console besides (11db))

Thread 6: EXC_BAD_ACCESS (code=1, deal with=0x10)

Error 4: Unrecognized Selector (it isn’t at all times __NSTaggedDate, however it does appear to be constantly 0x8000000000000000)

2022-09-20 21:57:33.690905-0500 Sound Errors[33833:2316174] -[__NSTaggedDate count]: unrecognized selector despatched to occasion 0x8000000000000000
2022-09-20 21:57:33.698566-0500 Sound Errors[33833:2316174] *** Terminating app on account of uncaught exception 'NSInvalidArgumentException', motive: '-[__NSTaggedDate count]: unrecognized selector despatched to occasion 0x8000000000000000'
*** First throw name stack:
(
    0   CoreFoundation                      0x000000018040c304 __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x000000018005131c objc_exception_throw + 56
    2   CoreFoundation                      0x000000018041afbc +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
    3   CoreFoundation                      0x0000000180410204 ___forwarding___ + 1308
    4   CoreFoundation                      0x000000018041268c _CF_forwarding_prep_0 + 92
    5   libswiftCore.dylib                  0x000000018bcb611c $sSD8_VariantVyq_SgxciM + 164
    6   libswiftCore.dylib                  0x000000018bcb6000 $sSDyq_SgxciM + 132
    7   Sound Errors                        0x00000001008a7094 $s12Sound_Errors14ErrorGeneratorV10playEffect5namedySS_tFZyycfU_ + 132
    8   Sound Errors                        0x00000001008a7148 $sIeg_IeyB_TR + 48
    9   libdispatch.dylib                   0x0000000100ef5d5c _dispatch_client_callout + 16
    10  libdispatch.dylib                   0x0000000100ef9210 _dispatch_continuation_pop + 756
    11  libdispatch.dylib                   0x0000000100f108c4 _dispatch_source_invoke + 1684
    12  libdispatch.dylib                   0x0000000100f0a8ac _dispatch_root_queue_drain + 440
    13  libdispatch.dylib                   0x0000000100f0b53c _dispatch_worker_thread2 + 248
    14  libsystem_pthread.dylib             0x00000001ae55eb04 _pthread_wqthread + 224
    15  libsystem_pthread.dylib             0x00000001ae55d904 start_wqthread + 8
)
libc++abi: terminating with uncaught exception of kind NSException
*** Terminating app on account of uncaught exception 'NSInvalidArgumentException', motive: '-[__NSTaggedDate count]: unrecognized selector despatched to occasion 0x8000000000000000'
terminating with uncaught exception of kind NSException
CoreSimulator 857.7 - Machine: iPhone 12 (D510B935-5295-43DC-AC72-E779D87B1D64) - Runtime: iOS 16.0 (20A360) - DeviceType: iPhone 12
(lldb)

Error 5 (this appears to be simply log noise, because it will get printed even when the sounds are enjoying accurately):

2022-09-20 20:48:54.755785-0500 Sound Errors[32793:2252630]  DataSource learn failed

Further Particulars: The sound recordsdata all use the .m4a format, and are all between 1 and a couple of seconds lengthy. I do know the difficulty isn’t that the app can’t discover the recordsdata, since they do play accurately within the time between when the AVAudioPlayer hundreds and when the crash occurs. All related code (apart from the sound recordsdata) is included right here; the remaining is only a default App template Xcode undertaking. I’ve BlackHole Audio Driver put in (that’s what I used to file the sounds), however don’t imagine that’s liable for any of those errors.

ViewController file

import UIKit

class ViewController: UIViewController {
    @IBOutlet weak var tappableView: UIView!
    
    let colours = [UIColor.systemGreen, UIColor.systemPink]
    var colorIndex = true
    
    override func viewDidLoad() {
        tremendous.viewDidLoad()
        ErrorGenerator.setUpSound()
    }

    
    @IBAction func viewTapped(_ sender: UITapGestureRecognizer) {
        // Reveals that the sq. view has acknowledged a faucet by toggling its colour
        colorIndex.toggle()
        tappableView.backgroundColor = colours[Int(truncating: NSNumber(value: colorIndex))]
        
        // Name the sound producing perform from the ErrorGenerator struct
        ErrorGenerator.playTapSounds()
    }
}

ErrorOrigin file

import Basis
import AVFoundation

struct ErrorGenerator {
    // The primary time AVAudioPlayer is used, it takes FOREVER (> 15 seconds) to begin.  This initializer is right here in order that we do not try to name the playEffect perform till this delay is over and soundIsReady has been set to true.
    static var AVInitializer = AVAudioPlayer()
    static var soundIsReady = false
    
    // Tuple gadgets are:  AVAudioPlayer, whether or not it's at present enjoying a sound impact, and the period of the sound impact (in seconds)
    static var audioPlayers: [String: (AVAudioPlayer?, Bool, Double)] = ["Sound 1": (nil, true, 1.39), "Sound 2": (nil, true, 1.1), "Sound 3": (nil, true, 1.28), "Sound 4": (nil, true, 1.06)]
    
    static func playEffect(named fileName: String) {
        if soundIsReady && audioPlayers[fileName]!.1 {
            let url = Bundle.principal.url(forResource: fileName, withExtension: "m4a")
            do {
                audioPlayers[fileName]?.0 = strive AVAudioPlayer(contentsOf: url!)
                audioPlayers[fileName]?.0?.play()
                // Do not let the identical sound impact be restarted till it has completed enjoying.  In any other case, it's going to minimize itself off with a static sound.
                audioPlayers[fileName]?.1 = false
                DispatchQueue.international(qos: .utility).asyncAfter(deadline: .now() + (audioPlayers[fileName]?.2 ?? 1.39)) {
                    audioPlayers[fileName]?.1 = true
                }
            }
            catch {
                print("Error enjoying sound impact file: (error)")
            }
        } else {
            print("Sound isn't but prepared")
        }
    }
    
    static func setUpSound() {
        DispatchQueue.international(qos: .utility).async {
            let url = Bundle.principal.url(forResource: "Empty", withExtension: "m4a")
            AVInitializer = strive! AVAudioPlayer(contentsOf: url!)
            AVInitializer.play()
            soundIsReady = true
        }
    }
    
    static func playTapSounds() {
        let s = "Sound (Int.random(in: 1...4))"
        print("Sound chosen: (s)")
        playEffect(named: s)
    }
}

Photos: I’ve included these along with the textual content error messages above, as a result of they spotlight the precise strains the place the issues happen, and since the Xcode sidebar has extra details about the thread construction than seems within the console.

Error 3 – Unhealthy Entry

Bad Access Thread 1

Error 3 – Unhealthy Entry (with excessive thread quantity)

Bad Access Thread 25

Error 4 – Unrecognized Selector

Unrecognized Selector image 1
Unrecognized Selector image 2

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments