我使用AVPlayer在Swift中播放远程视频,但不断出现这些崩溃
#0
Crashed: com.apple.avfoundation.playerlayer.configuration
EXC_BREAKPOINT 0x000000010522f968
0 libswiftCore.dylib
__hidden#23281_ line 134
specialized _assertionFailure(StaticString, String, file : StaticString, line : UInt, flags : UInt32) -> Never
1
libswiftFoundation.dylib
swift_stdlib_bridgeNSErrorToError + 59336
2 libswiftFoundation.dylib
swift_convertStringToNSString + 559540
3
libswiftFoundation.dylib
swift_stdlib_bridgeNSErrorToError + 61096
4 Foundation
-[NSKeyValueUnnestedProperty _givenPropertiesBeingInitialized:getAffectingProperties:] + 200
5
Foundation
-[NSKeyValueUnnestedProperty _initWithContainerClass:key:propertiesBeingInitialized:] + 152
6 Foundation
NSKeyValuePropertyForIsaAndKeyPathInner + 284
7 Foundation
NSKeyValuePropertyForIsaAndKeyPath + 144
8 Foundation
-[NSObject(NSKeyValueObserverRegistration) addObserver:forKeyPath:options:context:] + 92
9 AVFoundation
-[AVPlayerItem addObserver:forKeyPath:options:context:] + 368
10 AVFoundation
-[AVKVODispatcher startObservingValueAtKeyPath:ofObject:options:usingBlock:] + 136
11 AVFoundation
-[AVKeyPathDependency _startObservingSecondLevelPropertyOnNewCurrentValueForTopLevelDependencyProperty:] + 132
12 AVFoundation
-[AVKeyPathDependencyManager dependencyHostIsFullyInitialized] + 236
13 AVFoundation
-[AVKeyPathFlattener initForObservingValueAtKeyPath:onObject:] + 188
14 AVFoundation
-[AVKVODispatcher startObservingValueAtTwoPartKeyPath:ofObject:options:usingBlock:] + 100
15 AVFoundation
-[AVKVODispatcher(LegacyCallbackMethod) startObservingObject:weakObserver:forTwoPartKeyPath:options:context:] + 152
16 AVFoundation
-[AVPlayerLayer _startObservingPlayer:] + 404
17 libdispatch.dylib
_dispatch_call_block_and_release + 24
18 libdispatch.dylib
_dispatch_client_callout + 16
19 libdispatch.dylib
_dispatch_queue_serial_drain$VARIANT$mp + 528
20 libdispatch.dylib
_dispatch_queue_invoke$VARIANT$mp + 340
21 libdispatch.dylib
_dispatch_root_queue_drain_deferred_wlh$VARIANT$mp + 404
22 libdispatch.dylib
_dispatch_workloop_worker_thread$VARIANT$mp + 644
23 libsystem_pthread.dylib
_pthread_wqthread + 932
24
libsystem_pthread.dylib
start_wqthread + 4
我使用传统的KVO通过向自己添加一个观察者并覆盖observeValueForKey函数,并尝试使用新的基于块的KVO,但是总是会发生这种崩溃的事情(是的,我总是删除deinit上的观察者) )。这主要发生在ios 11设备上,但我从来没有在我自己的设备上发生这种崩溃,所以我不知道它是如何发生的。
有没有人知道为什么会发生这种情况或我可以尝试修复它的事情?当我在应用中添加更多视频时,崩溃率一直在上升。