pesky problem: IsFormatSampleRateAndChannelCountValid(format) error in IOS simulator - audiokit

I keep getting this pesky error on init sometimes. It occurs for a while and sometimes it goes away. I am not sure what is the problem. Please help. Details below
Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: IsFormatSampleRateAndChannelCountValid(format)'
The stack trace points to this piece of init() code.
init() {
guard let AK52_input = AK52_engine.input else {
fatalError()
}
do {
AK52_recorder = try NodeRecorder(node: AK52_input)
} catch let err {
fatalError("\(err)")
}
let silencer = Fader(AK52_input, gain: 0)
self.AK52_silencer = silencer
AK52_mixer.addInput(silencer)
AK52_mixer.addInput(AK52_player)
AK52_engine.output = AK52_mixer <----- error pops from here
}
And this code is identical to the one in the AudioCookbook. Infact, I see the same error when I run AudioCookbook too.
Please help.
thanks,
-Vittal

Related

NSInternalInconsistencyException - Animator is already stopped

Currently getting the following runtime exception
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Animator <UIViewPropertyAnimator(0x600003f24200) [stopped] interruptible> is already stopped!'
Because of the following line of code
// other code up here that modifies offsetAnimator
...
// stop any current running animations on offset
if let offsetAnimator = offsetAnimator {
offsetAnimator.stopAnimation(false) // this line is where the exception gets raised
offsetAnimator.finishAnimation(at: .end)
}
What is perplexing, however, is why this error is NOT readily reproducible
// doing this doesn't always result in an error
if let offsetAnimator = offsetAnimator {
offsetAnimator.stopAnimation(false)
offsetAnimator.finishAnimation(at: .end)
offsetAnimator.stopAnimation(false)
offsetAnimator.finishAnimation(at: .end)
}
What on earth is happening? Can someone explain to me why this error is occurring?
Why does it seem to only happen sporadically? Shouldn't calling .stop twice always trigger it?

Debug Swift crash EXC_BREAKPOINT (SIGTRAP)

I just downloaded a crash that happened and I am not sure how I could get more details as to what happened. All I can see is that crash happened inside of a Operation Queue, all I can see is that it happened inside of SyncToServer.sync(object:) method call and that it happened inside of a block.
I suspect that it could happen in this part of code:
self.queue.async {
if success {
self.syncObjects.remove(at: index)
self.saveState()
} else {
self.syncIndex += 1
}
self.syncing = false
self.sync()
}
I am also attaching the crash report below.

Google Autocomplete function Crash after Call

I am using Google PlaceAutoComplete method to get suggestions of the Addess that is entered in textField.
func placeAutocomplete(text:String) {
let placesClient = GMSPlacesClient()
let filter = GMSAutocompleteFilter()
filter.type = .Address
placesClient.autocompleteQuery("New Delhi", bounds: nil, filter: nil) { (results, error) in
guard error == nil else {
print("Autocomplete error \(error)")
return
}
self.addressArray.removeAll()
for result in results! {
self.addressArray.append(result.attributedFullText.string)
print("Result \(result.attributedFullText.string) with placeID \(result.placeID)")
}
}
}
When i call this method. It crashes, say the Following error.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary boolValue]: unrecognized selector sent to instance 0x7fe338f01e40'
I have tried to found using exception breakpoint but doesn't work.
Can any have idea, where i am wrong?
I have resolved the issue by correcting in the plist for "allow arbitrary loads" in App Transport security Settings. I was typed it true but its type was set string instead for Boolean
Somewhere a NSDictionary is being passed to the code where it is expecting a something that can be interpreted as a boolean such as an NSString or NSNumber. I don't see anything like that in the code you provided. If exception breakpoints aren't working I would try adding normal breakpoints somewhere and stepping over code until it crashes. You could also try removing certain sections and code and seeing if the crash is still happening, this will let you narrow down what portion of your code is to blame.

AppleWatch - "attempt to insert nil" when calling WKInterfaceDevice addCachedImage

Calling WKInterfaceDevice addCachedImage(_:name:) to send an image from my iPhone app to the Apple Watch (where the extension can tell an image view to show it) crashes. The exception is this:
2015-06-09 20:47:57.079 TimeInterval[20195:5186462] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[3]'
Various Google and StackOverflow searches show this has to do with using a shortcut to create an NSDictionary that doesn't allow passing in nil. However, my code isn't making a dictionary at all. Furthermore, when the debugger breaks (breakpoint on exceptions) I verify that the UIImage and the NSString name that I am passing are both definitely not nil.
Has anyone else seen this? Any idea why it happens or how to fix it? Has anyone actually been successful using addCachedImage? (Considering how new AppleWatch is, who knows!)
My chunk of code, in case it helps:
func application(application: UIApplication, handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]?, reply: (([NSObject : AnyObject]!) -> Void)!) {
if let info = userInfo {
NSLog("watch kit request: %#", info)
if let element = info["element"] as? String {
//Request to render an element
if element == "timer" {
let timerView = NPProgressLabel(size: CGSizeMake(48, 48))
timerView.text = info["value"] as! String
timerView.progressPercent = (info["progress"] as! NSNumber).floatValue
timerView.render()
let device = WKInterfaceDevice.currentDevice()
var success = false
if let image = timerView.currentImage {
success = device.addCachedImage(image, name: timerView.currentImageName()) // <------- crashing here ----------
} else {
NSLog("no image");
}
if !success {
NSLog("failed")
} else {
NSLog("addCachedImage success")
}
reply(["imageName": timerView.currentImageName()])
} else {
reply(["error": "Unknown element"])
}
return
}
}
reply(["error": "Bad request"])
}
The exact error I get may be an Apple bug, but I think the answer to my question is that WKInterfaceDevice's addCachedImage should not be called from the iPhone app but rather from the WatchKit Extension. Between iPhone app and WatchKit Extension I have to use a shared container to save then load the image, then the extension can call addCachedImage.

Swift: Key has no data exception, despite checking for nil

I'm scratching my head over this one, I thought the whole point of checking for nil was to ensure unsafe variables were ignored at run-time allowing the app to not crash.
I have tried to check the key returned from the server for nil, and also tried optional chaining to test for nil, neither are working and I still get the error:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Key "avatar" has no data. Call fetchIfNeeded before getting its value.'
I understand this means that no data was found for the avatar key, but due to the tests I am running I'm confused why this error is even being raised
for var i = 0; i < recipients.count; i++
{
if let u = recipients[i] as PFUser!
{
if u.valueForKey("avatar") != nil
{
println(i)
}
}
}
Conversely, I tried to optional chain the result of the image:
if let image: UIImage = UIImage(data: (u["avatar"]!.getData() as NSData?)!) {}
Both times the application will crash throwing the exception stated above. My stack trace shows nothing else which is of use, however the println statement will print 0, 1 and then crash on element 2 (where the collection size is 4 so I am not out of bounds).
Any ideas on how I can fix this?

Resources