AVAssetExportSession exportAsynchronously stuck/freeze/not starting

I attempt to export videos from Photo Library, but the export callback is never executed. I periodically check the progress of the export, and the progress is always zero.

AVAssetExportSession.Status always in waiting state


The code below works in 99.9% cases, but sometimes on some devices (absolutely randomly) it stops working, and only restart of the iPhone helps.

Code Block
import AVFoundation
let asset = AVAsset()
let outputURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0].appendingPathComponent("test.mov", isDirectory: false)
let exportSession = AVAssetExportSession(asset: asset, presetName: AVAssetExportPreset1280x720)
exportSession?.outputFileType = .mov
exportSession?.outputURL = outputURL
try? FileManager.default.removeItem(at: outputURL)
exportSession?.exportAsynchronously(completionHandler: {
print("sometimes never calls")
})


It is an example of the output URL: file:///var/mobile/Containers/Data/Application/B9EB607F-8F6F-4E3B-A6C3-88B580B8839F/Documents/last.mov


P.S. Some other video apps also freeze on video export (Videoleap, PicsArt) but some video apps (Filto, InShot) continue working
If if your testing you are able to reproduce the issue, you can gather a sysdiagnose and file a report using the Feedback Assistant.
Having the exact same issue. Interestingly, when in this bad state - the iphone screen recorder also won't complete. However, there is a solution, because at least one other app is able to export. Any luck on resolving?
I'm also facing this issue, any luck with understanding what is causing this ?
I have run into this issue as well. Wanted to bump this thread and also find out if a solution was ever discovered. Is there any recovery method other than a full phone restart?
I'm also facing this issue, no solution either...

I'm also facing this issue, no solution either...

Did anyone on this thread file a bug? If so, what was your bug number?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

9 months later still happening. No solution. Apple tech support said they couldn't help since I can't tell them how to reproduce this random occurrence.

9 months later still happening.

It would help if someone could post a bug number, per my earlier request.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Exact same issue appear on my iPhone 12 (iOS 14.6) and my iPhone XR (iOS 14.4.2).

This appears when import multiple videos from gallery to my app, apply some processing like crop or resize video to each one using AVAssetExportSession and before export ends I force close app, next I open again my app and try import another video files AVAssetExportSession is blocked (Another operations like play video doesn't work in this time), takes a lot of time (About 5 minutes) and finally ends with status .failed (The operation could not be completed), after that all operations over AVAssetExportSession executes normally!

Restarting iPhone unblock AVAssetExportSession but is very frustrating!

Please some advice or workaround for avoid this issue?

  • I added device log (MediaServerD process logs), each time AVExportSession call .fail log this line
  • <<<< FigExportCommmon >>>> remakerFamily_Finalize: (0x135f49df0) state invalidated

https://feedbackassistant.apple.com/feedback/9155832 please help!

I ran into the exact same issue:

I have an app that uses ExportSession to resize videos and livephoto videos. This can run both in foreground or background, and I usually process at most 4 assets at a time. This works 99% of the time, but randomly it would get stuck waiting on exportSession all at the same time. I would wait indefinitely without any error. I tried to kill the app in task switcher or restart from debugger but nothing works short of rebooting the phone.

I do not have diagnostics because this issue is very rare and happens randomly. I do observe it happen more often on my iPhone11 than on iphone6

https://feedbackassistant.apple.com/feedback/9188280

I can reproduce it by killing the app several times In the middle of the exporting process, then suddenly the ExportSession stops working and is stuck with status == .waiting, then I must rebooting the device to solve it. I search (a lot) for a way to observe or check the status of the device's capabilities to know if it is available, with no luck... Maybe the steps to reproduce can help someone at apple fix it.

Maybe the steps to reproduce can help someone at apple fix it.

Indeed. Please add that info to your bug report and then post the bug number here.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Did anyone ever find a solution to this. I have tried everything. Export works 99% of the time but every once in a blue moon export & app freezes and then I have to terminate app. Please assist @eskimo. Can you look into those couple of feedbacks that were submitted by others and let me know on this thread what the responses were from app devs? Thank you!

I see only two bug reports on this thread (FB9155832, FB9188280) neither of which are resolved.

Given that this affects a wide variety of apps, it’s hard to imagine it being an issue with your code. My advice is that, if you see this problem, you grab a sysdiagnose and include that in your own bug report. It’s possible that the extra bugs will contain the info needed by the engineering team to debug the issue.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

AVAssetExportSession exportAsynchronously stuck/freeze/not starting
 
 
Q