首页 > 解决方案 > AVSpeechSynthesizer 导致 ios11.4 崩溃

问题描述

我遇到了与 AVSpeechSynthersizer 相关的崩溃。我的代码是

   AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:text];

    utterance.rate = rate;
    utterance.pitchMultiplier = pitchMultiplier;
    utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:languageCode];
    _startTime = [[NSDate date] timeIntervalSince1970];
    [self.speechSynthesizer speakUtterance:utterance];

这次崩溃只有一个用户案例。操作系统版本为 11.4,设备为 iPhone6。

崩溃堆栈信息:

Incident Identifier: 24E003DC-47C0-45B0-A22E-A351B2A8046A
CrashReporter Key:   c8844c975fe64b90aad2b813254959a928e4c4ea
Hardware Model:      iPhone7,2
Process:         qcs.r [779]
Path:            /var/containers/Bundle/Application/0242C042-0AE5-4033-AE07-D1BECD6DD910/qcs.r.app/qcs.r
Identifier:      com.meituan.qcs.r.ios
Version:         2.1.9 (1682)
Code Type:       ARM-64
Parent Process:  ? [1]

Date/Time:       2018-06-14 13:41:58.000 +0800
OS Version:      iOS 11.4 (15F79)
Report Version:  104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000 at 0x0000000000000000
Crashed Thread:  53

Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSString stringWithUTF8String:]: NULL cString
UserInfo:(null)'

Thread 53 Crashed:
0   CoreFoundation                  __exceptionPreprocess+ 228
1   libobjc.A.dylib                 objc_exception_throw (in libobjc.A.dylib) + 56
2   CoreFoundation                  -[NSException initWithCoder:]+ 0
3   Foundation                      +[NSString stringWithUTF8String:]+ 92
4   TTSSpeechBundle                 0x0000000105f87544 0x105f70000 + 95556
5   libsystem_pthread.dylib         _pthread_body (in libsystem_pthread.dylib) + 272
6   libsystem_pthread.dylib         _pthread_body (in libsystem_pthread.dylib) + 0
7   libsystem_pthread.dylib         thread_start (in libsystem_pthread.dylib) + 4

标签: crashtext-to-speech

解决方案


您的文本参数是否可能为零?初始化字符串:文本


推荐阅读