iOS 11 : Media Player crash
<p><p>从 iOS 11 开始,我一直看到这种崩溃:</p>
<pre>1 libdispatch.dylib _dispatch_sync_wait + 63192
2 MediaToolbox videoQueueRemote_Invalidate + 5984376
3 MediaToolbox videoQueueRemote_Invalidate + 5984376
4 MediaToolbox videoQueueRemote_Finalize + 5984828
5 CoreMedia FigBaseObjectFinalize + 47300
6 核心基金会_CFRelease + 963176
7 AVFoundation- + 1467352
8 QuartzCore CA::Transaction::commit() + 745496
9 MediaToolbox FigLayerSynchronizerSynchronizeToMoment + 857340
10 MediaToolbox videoQueueRemote_SynchronizeLayerToMoment + 5994476
11 MediaToolbox figSyncMomentSource_sendMomentInternal + 852744
12 libdispatch.dylib _dispatch_client_callout + 6404
13 libdispatch.dylib _dispatch_queue_serial_drain$VARIANT$mp + 46184
14 libdispatch.dylib _dispatch_queue_invoke$VARIANT$mp + 48632
15 libdispatch.dylib _dispatch_root_queue_drain_deferred_wlh$VARIANT$mp + 51244
16 libdispatch.dylib _dispatch_workloop_worker_thread$VARIANT$mp + 84560
17 libsystem_pthread.dylib_pthread_wqthread + 4680
</pre>
<p>只是想了解这是我的应用程序的问题还是苹果 BETA 问题。 </p>
<p>注意:问题是间歇性的。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我不知道媒体播放器框架,但我猜你使用 <code>AVPlayer</code> 来播放视频,因为 <a href="https://developer.apple.com/documentation/mediaplayer" rel="noreferrer noopener nofollow">documentation</a>状态</p>
<blockquote>
<p>To enable users to play videos containing MPMediaItem objects, use
AVPlayer. You cannot play video media items using the Media Player
framework.</p>
</blockquote>
<p>如果是这样,您可能使用 <code>AVPlayerLayer</code> 进行显示,这很可能在内部使用 <code>AVSampleBufferDisplayLayer</code>。哪一个来自您的堆栈跟踪:</p>
<blockquote>
<p>7 AVFoundation - + 1467352</p>
</blockquote>
<p>在直接使用 <code>AVSampleBufferDisplayLayer</code> 时,我遇到了同样的崩溃并在后台线程上看到了相同的堆栈跟踪。经过大量调试和测试后,我发现将所有涉及该层的代码移至主线程可以避免崩溃。 <code>viewWill...</code> 和 <code>viewDid...</code> 回调是设置的好地方:</p>
<pre><code>var player : AVPlayer!
var layer : AVPlayerLayer!
// var layer : AVSampleBufferDisplayLayer! // in my case
override func viewDidLoad() {
super.viewDidLoad()
self.layer = AVPlayerLayer(player: player)
// self.layer = AVSampleBufferDisplayLayer() // in my case
self.layer.frame = self.view.bounds
self.view.layer.addSublayer(self.layer)
}
</code></pre>
<p>使用 <code> 时 <code>enqueue(_ sampleBuffer: CMSampleBuffer)</code> 和 <code>flush()</code> 或 <code>flushAndRemoveImage()</code> 也是如此AVSampleBufferDisplayLayer</code>.</p></p>
<p style="font-size: 20px;">关于iOS 11 : Media Player crash,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/45573203/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/45573203/
</a>
</p>
页:
[1]