The autor of Creating a Movie with an Image and Audio on iOS proposes the way of rechecking for assetwriter readiness.
// lines 52-55
while !adaptor.assetWriterInput.isReadyForMoreMediaData { usleep(10) }
adaptor.append(buffer, withPresentationTime: startFrameTime)
Is this the canonical way of querying AVFoundation's objects, or maybe there's a better way than sleep and try again loop? The only remotely related post I found is How to check if AvAssetWriter has finished writing the last frame, and has four years and no answer.
What about requestMediaDataWhenReady( on queue: DispatchQueue, using block: @escaping () -> Void )
(see documentation)