If AVURLAsset.tracks is empty but the video/audio plays, it may be due to lazy loading ensure you call loadValuesAsynchronously(forKeys:) on the asset before accessing tracks.
AVURLAsset.tracks
loadValuesAsynchronously(forKeys:)