bmueller
bmueller

Reputation: 2711

AVSpeechSynthesizer causing crashes on iOS 8.3

I've had a number of users reporting crashing on iOS 8.3. The crash log states:

Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'

But I'm not inserting any nil objects into any arrays.

One of the last calls in the stack trace is to [TTSSpeechSynthesizer _startSpeakingString:orAttributedString:toURL:withLanguageCode:request:error:], so I figured it might be something to do with AVSpeechSynthesizer - and lo and behold, once I removed all TTS code the app stopped crashing.

This crash is only happening for a small subset of users, and the only commonality I've been able to find so far is that they're all on 8.3. Some of the apps that are crashing haven't been updated in over a year and worked fine just prior to them updating.

Anyone have any ideas on what could be causing this?

Upvotes: 2

Views: 432

Answers (1)

bmueller
bmueller

Reputation: 2711

Finally figured out that, for some reason, the "en-US" voice is sometimes getting removed from devices during iOS upgrades. I got my hands on a device that was experiencing this issue, and querying the array that lists all the voices on the system returns a list of all the voices except "en-US".

I solved my issue by looping through the array to see if "en-US" is available. If it is, I set it as the utterance's voice. If not, I leave the voice empty.

Upvotes: 1

Related Questions