ios – [AVOutputContext(FigRoutingContext)currentRoutingContextFactory]中的崩溃AVFoundation

我们在AVFoundation崩溃了.

AVFoundation
 [AVOutputContext(FigRoutingContext)currentRoutingContextFactory]

EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000a3c27beb8

Crashed: Thread
0  libobjc.A.dylib                0x183b8c910 objc_msgSend + 16
1  AVFoundation                   0x18a5401bc +[AVOutputContext(FigRoutingContext) currentRoutingContextFactory] + 56
2  AVFoundation                   0x18a53ae28 +[AVFigRoutingContextOutputContextImpl sharedAudioPresentationOutputContext] + 28
3  AVFoundation                   0x18a4d0a24 +[AVOutputContext sharedAudioPresentationOutputContext] + 40
4  MediaPlayer                    0x195deb1cc -[MPAVLightweightRoutingController pickedRoutes] + 68
5  MediaPlayer                    0x195e04338 -[MPVolumeView _setShowsVolumeSlider:] + 96
6  MediaPlayer                    0x195e02ad4 -[MPVolumeView layoutSubviews] + 208
7  UIKit                          0x18e593770 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1420
8  QuartzCore                     0x188b3525c -[CALayer layoutSublayers] + 184
9  QuartzCore                     0x188b393ec CA::Layer::layout_if_needed(CA::Transaction*) + 324
10 QuartzCore                     0x188aa5aa0 CA::Context::commit_transaction(CA::Transaction*) + 320
11 QuartzCore                     0x188acd5d0 CA::Transaction::commit() + 580
12 QuartzCore                     0x188acdd10 CA::Transaction::release_thread(void*) + 244
13 libsystem_pthread.dylib        0x1845e457c _pthread_tsd_cleanup + 572
14 libsystem_pthread.dylib        0x1845e42cc _pthread_exit + 88
15 libsystem_pthread.dylib        0x1845e40d4 _pthread_wqthread + 1472
16 libsystem_pthread.dylib        0x1845e3b08 start_wqthread + 4

Crashlytics写道:

This crash has non-main threads that appear to use UIKit classes or
functions. Generally speaking, it is only safe to use UIKit from the
main thread. Calling into UIKit from background threads can cause
unpredictable behavior (like crashes!). Please double check that all
of your code (that is not on the main thread) has been explicitly
marked as safe to use in the background by Apple.

但是我们不在app中使用其他线程.

Crashlytics日志:

Crashed: Thread 0 libobjc.A.dylib 0x184370910
objc_msgSend + 16 1 AVFoundation 0x18ad241bc
+[AVOutputContext(FigRoutingContext) currentRoutingContextFactory] + 56 2 AVFoundation 0x18ad1ee28
+[AVFigRoutingContextOutputContextImpl sharedAudioPresentationOutputContext] + 28 3 AVFoundation
0x18acb4a24 +[AVOutputContext sharedAudioPresentationOutputContext] +
40 4 MediaPlayer 0x1965cf1cc
-[MPAVLightweightRoutingController pickedRoutes] + 68 5 MediaPlayer 0x1965e8338 -[MPVolumeView _setShowsVolumeSlider:] + 96 6 MediaPlayer
0x1965e6ad4 -[MPVolumeView layoutSubviews] + 208 7 UIKit
0x18ed77770 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1420
8 QuartzCore 0x18931925c -[CALayer
layoutSublayers] + 184 9 QuartzCore 0x18931d3ec
CA::Layer::layout_if_needed(CA::Transaction*) + 324 10 QuartzCore
0x189289aa0 CA::Context::commit_transaction(CA::Transaction*) + 320 11
QuartzCore 0x1892b15d0 CA::Transaction::commit() +
580 12 QuartzCore 0x1892b1d10
CA::Transaction::release_thread(void*) + 244 13
libsystem_pthread.dylib 0x184dc857c _pthread_tsd_cleanup + 572
14 libsystem_pthread.dylib 0x184dc82cc _pthread_exit + 88 15
libsystem_pthread.dylib 0x184dc80d4 _pthread_wqthread + 1472 16
libsystem_pthread.dylib 0x184dc7b08 start_wqthread + 4

初始代码:

self.volumeView = MPVolumeView.init(frame: CGRect.init(x: 0, y: 2,
                                                                     width: 52.0,
                                                                     height: 30.0))
self.volumeView?.showsVolumeSlider = false            self.volumeView?.showsRouteButton = true

self.volumeView?.setRouteButtonImage(UIImage.init(named: "streaming_icon"), for: .normal)
self.volumeView?.setRouteButtonImage(UIImage.init(named: "selected_streaming_icon"), for: .selected)

self.volumeView.sizeToFit()

请帮助解决此问题.

最佳答案 我联系了Apple,他们已经验证了我的理论,即MPVolumeView在后台线程上执行UI布局更改.

错误报告已创建.

更新2018-05-30:
Engineering已确定您的错误报告(40594280)是39309134的副本,将被关闭.

点赞