简体   繁体   中英

AVPlayer causes Simulator to crash but runs fine on device

I've searched all the Internet around, but found no mentions of this error.

I am using AVPlayer to play stream audio from remote or local URL. However, while on my device it works fine, on simulator it is crashing.

I've found out that creation of player is going fine, but as soon as I call [playerInstance play] the app crashes.

The error is occurring somewhere in CommonURLAssetNotificationQueue. And the exception breakpoint points me to 0x10e8a2519: pushq %rbp, which is not helpful at all.

However, on device it works fine.

So, is it my mistake and I have to fix the code? Or it's just simulator acting wonky?

It is likely that you have an exception breakpoint enabled. The play method in AVPlayer normally throws an exception, even though nothing is wrong. The exception doesn't crash the app, and the app then continues to run exactly as you wanted it to. If you have exception breakpoints enabled, however, Xcode notices the exception and crashes the app. If you go into the left sidebar and disable your exception breakpoint the app will run without crashing.

在此输入图像描述

Change exception all as Objective C.

My resolving method is to add 'usage description' in App's Info page. Because the AVPlayer Demo App is trying to use local photo library without asking permission, this causes the demo app to crash. After adding the 'Privacy — Photo Library Usage Description', I can run this demo app successfully.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM