Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 10 observer未移除引发的异常崩溃 #447

Open
beatman423 opened this issue Jun 28, 2021 · 10 comments
Open

iOS 10 observer未移除引发的异常崩溃 #447

beatman423 opened this issue Jun 28, 2021 · 10 comments
Labels

Comments

@beatman423
Copy link

必现/偶发?
偶发

描述bug
iOS 10系统中 由于player或playerItem释放时未移除observer引发的Fatal Exception: NSInternalInconsistencyException
(Pod已经升级到最新版本)

你期望的结果是什么?
在iOS 10环境下 在player或playerItem释放时正确移除observer

运行环境

  • iPhone 5
  • iOS 10.3.4
  • Xcode 12.5
  • Objective-C

截图
如果有必要的话,请上传几张截图
WechatIMG23
WechatIMG24

@beatman423 beatman423 added the bug label Jun 28, 2021
@beatman423
Copy link
Author

@changsanjiang 麻烦看一下吧 多谢了

@SUWW
Copy link

SUWW commented Apr 12, 2022

playerItem

请问有解决了吗

@changsanjiang
Copy link
Owner

@SUWW #153

@SUWW
Copy link

SUWW commented Apr 12, 2022

@SUWW #153

十分感谢你的回复,我有看到的,但是里面说的方法,只有那个替换文件的,我没有尝试,因为我文件中并没有那个文件的。我的SJBaseVideoPlayer版本应该是最新的。SJBaseVideoPlayer (3.6.7), SJMediaCacheServer (1.7.7),SJUIKit (0.0.0.58):。我在demo中又无法复现

@changsanjiang
Copy link
Owner

报错是一样的吗, 最好能提供一些日志

@SUWW
Copy link

SUWW commented Apr 12, 2022

@changsanjiang 报错日子如下
崩溃的原因是=-[SJVideoModel videoUrl]: unrecognized selector sent to instance 0x28126eb80,,,崩溃的名称是=NSInvalidArgumentException,,,崩溃的堆栈信息是=(
0 CoreFoundation 0x0000000194063270 37A3D601-9398-3DC2-9D00-1B162726A4C9 + 1159792
1 libobjc.A.dylib 0x00000001a7df8480 objc_exception_throw + 56
2 CoreFoundation 0x0000000193f72278 37A3D601-9398-3DC2-9D00-1B162726A4C9 + 172664
3 CoreFoundation 0x00000001940658b8 37A3D601-9398-3DC2-9D00-1B162726A4C9 + 1169592
4 CoreFoundation 0x000000019406785c _CF_forwarding_prep_0 + 92
5 BigStar 0x00000001055620f8 BigStar + 6955256
6 UIKitCore 0x0000000196b1ccd8 E136F680-E4B6-3BCE-8132-4A39EC1ED9FA + 13913304
7 UIKitCore 0x0000000196aea608 E136F680-E4B6-3BCE-8132-4A39EC1ED9FA + 13706760
8 UIKitCore 0x0000000196afd750 E136F680-E4B6-3BCE-8132-4A39EC1ED9FA + 13784912
9 BigStar 0x0000000105562790 BigStar + 6956944
10 BigStar 0x00000001055634fc BigStar + 6960380
11 BigStar 0x00000001060e12ec BigStar + 19010284
12 BigStar 0x0000000105563124 BigStar + 6959396
13 libdispatch.dylib 0x0000000193c9b298 ECEF88A0-245A-33C1-823D-3160E1F3D674 + 397976
14 libdispatch.dylib 0x0000000193c40028 ECEF88A0-245A-33C1-823D-3160E1F3D674 + 24616
15 libdispatch.dylib 0x0000000193c50d64 ECEF88A0-245A-33C1-823D-3160E1F3D674 + 93540
16 libdispatch.dylib 0x0000000193c49bc4 ECEF88A0-245A-33C1-823D-3160E1F3D674 + 64452
17 CoreFoundation 0x0000000193fe2298 37A3D601-9398-3DC2-9D00-1B162726A4C9 + 631448
18 CoreFoundation 0x0000000193fdc6f8 37A3D601-9398-3DC2-9D00-1B162726A4C9 + 607992
19 CoreFoundation 0x0000000193fdb7d0 CFRunLoopRunSpecific + 572
20 GraphicsServices 0x00000001aa71d570 GSEventRunModal + 160
21 UIKitCore 0x00000001969082d0 E136F680-E4B6-3BCE-8132-4A39EC1ED9FA + 11731664
22 UIKitCore 0x000000019690d84c UIApplicationMain + 164
23 BigStar 0x0000000105e7705c BigStar + 16478300
24 libdyld.dylib 0x0000000193cba140 FFBE9840-BC5A-338D-8AE0-C6FFE5E834CC + 4416
)

或者你看下开发者2群,我有在群里提问的,这里我无法上传图片

@SUWW
Copy link

SUWW commented Apr 12, 2022

@changsanjiang 上面的日志是后台提供的。我xcode控制台打印的如下

[时间]: 2022-04-12 10:00:20
[设备]: iPhone11,6
[系统版本] : 15.3.1
[应用版本]: 1.0.1
[NSObject]:<NSKeyValueObservance 0x281 cOccf0: Observer:
0x281185530, Key path: playModel, Options: <New: YES, Old: YES,
Prior: NO>.上下文: 0x0, Property: 0x281cc7b70>
[崩溃类型]: NSRangeException
[崩溃原因]:无法从<NSKeyValueObservance 0x281c0ccf0>中删
除键路径"playModel"的观察者<SJVideoPlayerURL AssetObserver
0x281180d10>,因为它没有注册为观察者。
[错误地点]: -[_ _SJKVOAutoremove dealloc]

我只要屏蔽了

  • (void)configureWithURL:(NSURL *)URL {
    [self stop];
    SJVideoPlayerURLAsset *asset = [SJVideoPlayerURLAsset.alloc initWithURL:URL];

// self.URLAsset = asset;
}方法中的self.URLAsset = asset 应该是这个方法里出了问题,

@SUWW
Copy link

SUWW commented Apr 12, 2022

@changsanjiang
[Time]:2022-04-12 12:59:34
[Bundle Id]:
[Device]:iPhone11,6
[System Version]:15.3.1
[AppVersion]:1.0.1
[NSObject]:<__SJKVOAutoremove: 0x2839a97a0>
[Crash Type]: NSRangeException
[Crash Reason]: Cannot remove an observer <SJVideoPlayerURLAssetObserver 0x28343ae00> for the key path "playModel" from <__SJKVOAutoremove 0x2839a97a0> because it is not registered as an observer.
[Error Place]: -[__SJKVOAutoremove dealloc]
[Crash Type]: (
0 CoreFoundation 0x0000000180dc9110 E2F84645-2905-31EF-8EC7-3CC19C3CDDB3 + 626960
1 libobjc.A.dylib 0x0000000199619d64 objc_exception_throw + 60
2 Foundation 0x000000018258ae54 925A43CD-EAF2-3161-9378-3ED87468301D + 220756
3 Foundation 0x00000001825af184 925A43CD-EAF2-3161-9378-3ED87468301D + 369028
4 GJNoCrash 0x0000000105f768a4 -[NSObject(KVOCrash) gj_removeObserver:forKeyPath:] + 100
5 SJUIKit 0x0000000106aa4254 -[__SJKVOAutoremove dealloc] + 84
6 libobjc.A.dylib 0x000000019960633c 56A134B6-C3D8-3D91-B1FC-7BDB75C5903B + 9020
7 libobjc.A.dylib 0x0000000199608b84 objc_destructInstance + 96
8 libobjc.A.dylib 0x00000001996121c8 _objc_rootDealloc + 80
9 GJNoCrash 0x0000000105f77048 -[NSObject(NSNotificationCrash) gj_dealloc] + 136
10 SJBaseVideoPlayer 0x000000010685da74 -[SJBaseVideoPlayer(PlayControl) _updateAssetObservers] + 208
11 SJBaseVideoPlayer 0x000000010685d6dc -[SJBaseVideoPlayer(PlayControl) setURLAsset:] + 268
12 BigStar 0x00000001030e0edc BigStar + 12193500
13 BigStar 0x0000000102be0c9c BigStar + 6950044
14 UIKitCore 0x00000001834610b4 920A0EE6-D266-3058-8144-27A27B23AD62 + 2654388
15 UIKitCore 0x00000001836609e0 920A0EE6-D266-3058-8144-27A27B23AD62 + 4749792
16 UIKitCore 0x0000000183486c40 920A0EE6-D266-3058-8144-27A27B23AD62 + 2808896
17 UIKitCore 0x0000000183355df4 920A0EE6-D266-3058-8144-27A27B23AD62 + 1560052
18 UIKitCore 0x0000000183366474 920A0EE6-D266-3058-8144-27A27B23AD62 + 1627252
19 QuartzCore 0x0000000184ac9794 A2DA3A56-96BC-362F-BD55-949AB26AD274 + 259988
20 QuartzCore 0x0000000184abbfb4 A2DA3A56-96BC-362F-BD55-949AB26AD274 + 204724
21 QuartzCore 0x0000000184ad05dc A2DA3A56-96BC-362F-BD55-949AB26AD274 + 288220
22 QuartzCore 0x0000000184ad8ed0 A2DA3A56-96BC-362F-BD55-949AB26AD274 + 323280
23 QuartzCore 0x0000000184abb70c A2DA3A56-96BC-362F-BD55-949AB26AD274 + 202508
24 CoreFoundation 0x0000000180d71610 E2F84645-2905-31EF-8EC7-3CC19C3CDDB3 + 267792
25 CoreFoundation 0x0000000180d408f4 E2F84645-2905-31EF-8EC7-3CC19C3CDDB3 + 67828
26 CoreFoundation 0x0000000180d3b98c E2F84645-2905-31EF-8EC7-3CC19C3CDDB3 + 47500
27 CoreFoundation 0x0000000180d4f468 CFRunLoopRunSpecific + 600
28 GraphicsServices 0x000000019c8f338c GSEventRunModal + 164
29 UIKitCore 0x00000001836f25d0 920A0EE6-D266-3058-8144-27A27B23AD62 + 5346768
30 UIKitCore 0x0000000183470f74 UIApplicationMain + 364
31 BigStar 0x00000001034f6f6c BigStar + 16478060
32 dyld 0x0000000105d45aa4 start + 520
)
SJMediaPlaybackController<0x280428240>.assetStatus.Preparing

xcode断点锁定在以下代码中崩溃

  • (void)dealloc {
    if ( _factor ) {
    [_target removeObserver:_observer forKeyPath:_keyPath];
    _factor = nil;
    }

}

@changsanjiang
Copy link
Owner

@SUWW
Copy link

SUWW commented Apr 12, 2022

问题已解决。我出现这个问题的原因是,因为项目中存在其它的kvo 自动移除的库导致的。希望出现这个问题的大家,可以查看下自己的项目中是否有其它的kvo 自动移除的库

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants