聊天页面返回后程序崩溃
Surrel opened this issue · 3 comments
聊天页面又个kvo没移除,导致崩溃,需要在聊天页面的dealoc内加上
[self.conversationMessageCollectionView removeObserver:self forKeyPath:@"frame"];
您是使用最新的源码出现的崩溃?方便的话,贴一下崩溃时候的 log 和调用栈截图。
2019-10-25 14:02:44.953100 SealTalk[7634:1421012] -[RCDChatViewController dealloc]
2019-10-25 14:02:48.359598 SealTalk[7634:1421114] [] nw_socket_write_close shutdown(10, SHUT_WR): [57] Socket is not connected
2019-10-25 14:02:48.359996 SealTalk[7634:1421114] [] nw_endpoint_flow_service_writes [3.1 120.92.13.68:443 ready socket-flow (satisfied)] Write request has 0 frame count, 0 byte count
2019-10-25 14:02:48.363383 SealTalk[7634:1421251] [] __tcp_connection_write_eof_block_invoke Write close callback received error: [89] Operation canceled
2019-10-25 14:02:48.475517 SealTalk[7634:1421012] [RC:P-crash-F]env:{"_opengl":3,"_device":"iPhone6,2","_orientation":"FaceUp","_online":1,"_ram_total":1000,"_app_version":"2.9.25 Dev","_root":false,"_ram_current":918,"_background":false,"_nonfatal":false,"_os_version":"10.2","_disk_total":11636,"_os":"iOS","_bat":100,"_run":17,"_resolution":"640x1136","_disk_current":9519},reason:Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x103149200 of class UICollectionView was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x17422af80> (
<NSKeyValueObservance 0x1744472f0: Observer: 0x103057400, Key path: frame, Options: <New: YES, Old: YES, Prior: NO> Context: 0x0, Property: 0x174447320>
)'
,stack:0 CoreFoundation 0x00000001837c11d0 + 148
1 libobjc.A.dylib 0x00000001821f855c objc_exception_throw + 56
2 CoreFoundation 0x00000001837c1100 + 0
3 Foundation 0x000000018423c5f4 + 300
4 CoreFoundation 0x00000001837b0e28 + 188
5 CoreFoundation 0x00000001836a1ee0 + 28
6 libobjc.A.dylib 0x0000000182211fe0 + 704
7 UIKit 0x0000000189674668 + 1644
8 libobjc.A.dylib 0x0000000182211fe0 + 704
9 CoreFoundation 0x000000018369a028 _CFAutoreleasePoolPop + 28
10 CoreFoundation 0x000000018376c404 + 1668
11 CoreFoundation 0x000000018369a2b8 CFRunLoopRunSpecific + 444
12 GraphicsServices 0x000000018514e198 GSEventRunModal + 180
13 UIKit 0x00000001896e17fc + 684
14 UIKit 0x00000001896dc534 UIApplicationMain + 208
15 SealTalk 0x000000010011bad0 main + 124
16 libdyld.dylib 0x000000018267d5b8 + 4
2019-10-25 14:02:48.489258 SealTalk[7634:1421012] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x103149200 of class UICollectionView was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x17422af80> (
<NSKeyValueObservance 0x1744472f0: Observer: 0x103057400, Key path: frame, Options: <New: YES, Old: YES, Prior: NO> Context: 0x0, Property: 0x174447320>
)'
*** First throw call stack:
(0x1837c11b8 0x1821f855c 0x1837c1100 0x18423c5f4 0x1837b0e28 0x1836a1ee0 0x182211fe0 0x189674668 0x182211fe0 0x18369a028 0x18376c404 0x18369a2b8 0x18514e198 0x1896e17fc 0x1896dc534 0x10011bad0 0x18267d5b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
暂时使用下面代码处理, demo 下个版本会修复这个问题。
- (void)dealloc {
NSLog(@"%s", func);
[self.conversationMessageCollectionView removeObserver:self forKeyPath:@"frame"];
[[NSNotificationCenter defaultCenter] removeObserver:self];
}