我在Swift中写了99%,我不明白为什么这个线程崩溃了。我不能重现它,但它有时会发生。
库是: LTSupportAutomotive https://github.com/mickeyl/LTSupportAutomotive
错误:(从HockeyApp崩溃报告程序获取)在当前参数寄存器委托中找到选择器名称
异常类型: SIGSEGV
异常代码: 0xac7c95df0处的SEGV_ACCERR
Thread 6 Crashed:
0 libobjc.A.dylib 0x00000001fe175430 objc_retain + 16
1 LTSupportAutomotive 0x00000001065816f8 -[LTBTLEReadCharacteristicStream characteristicDidUpdateValue] (LTBTLEReadCharacteristicStream.m:43)
2 LTSupportAutomotive 0x0000000106582ac8 -[LTBTLESerialTransporter peripheral:didUpdateValueForCharacteristic:error:] (LTBTLESerialTransporter.m:299)
3 CoreBluetooth 0x0000000204b42cc0 -[CBPeripheral handleAttributeEvent:args:attributeSelector:delegateSelector:delegateFlag:] + 236
4 CoreBluetooth 0x0000000204b42e20 -[CBPeripheral handleCharacteristicEvent:characteristicSelector:delegateSelector:delegateFlag:] + 128
5 CoreBluetooth 0x0000000204b3e4d0 -[CBPeripheral handleMsg:args:] + 352
6 CoreBluetooth 0x0000000204b38bdc -[CBCentralManager handleMsg:args:] + 200
7 CoreBluetooth 0x0000000204b47750 __30-[CBXpcConnection _handleMsg:]_block_invoke + 56
8 libdispatch.dylib 0x00000001fe9c56c8 _dispatch_call_block_and_release + 20
9 libdispatch.dylib 0x00000001fe9c6484 _dispatch_client_callout + 12
10 libdispatch.dylib 0x00000001fe96dbd0 _dispatch_lane_serial_drain$VARIANT$mp + 588
11 libdispatch.dylib 0x00000001fe96e74c _dispatch_lane_invoke$VARIANT$mp + 480
12 libdispatch.dylib 0x00000001fe96da9c _dispatch_lane_serial_drain$VARIANT$mp + 280
13 libdispatch.dylib 0x00000001fe96e718 _dispatch_lane_invoke$VARIANT$mp + 428
14 libdispatch.dylib 0x00000001fe976eb8 _dispatch_workloop_worker_thread + 596
15 libsystem_pthread.dylib 0x00000001feba90dc _pthread_wqthread + 308
16 libsystem_pthread.dylib 0x00000001febabcec start_wqthread + 0中的崩溃代码
-(void)characteristicDidUpdateValue
{
NSData* value = _characteristic.value;
[_buffer appendData:value];
[self.delegate stream:self handleEvent:NSStreamEventHasBytesAvailable]; <--- here it is crashing
}这里从下面开始:
-(void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error
{
#ifdef DEBUG_THIS_FILE
NSString* debugString = [[NSString alloc] initWithData:characteristic.value encoding:NSUTF8StringEncoding];
NSString* replacedWhitespace = [[debugString stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"] stringByReplacingOccurrencesOfString:@"\r" withString:@"\\r"];
XLOG( @"%@ >>> %@", peripheral, replacedWhitespace );
#endif
if ( error )
{
LOG( @"Could not update value for characteristic %@: %@", characteristic, error );
return;
}
[_inputStream characteristicDidUpdateValue]; <---
}有人能帮助我使用Objective-C来避免这种崩溃吗?
谢谢
发布于 2019-03-31 16:17:28
委托的声明是unsafe_unretained,而不是weak。
https://stackoverflow.com/questions/54332612
复制相似问题