Expo AV getting NSURLErrorDomain (timeout) on loadAsync

Please provide the following:

  1. SDK Version: ~47.0.9
  2. Platforms(Android/iOS/web/all): iOS

I’m trying to load several (3-5) mp3 sounds from a remote server for playback using Expo AV in iOS. I’m calling loadAsync with the URI option for each file, as such:

baseSound = new Audio.Sound();
baseSoundStatus = await baseSound.loadAsync({uri: baseFileURI}, initialStatus);

When I load all sounds in sequence it typically works fine. However, this is quite slow. If I try loading sounds in parallel (i.e. firing off all the loadAsyncs and waiting for them to complete) I almost always get at least one sound, usually more, erroring out with:

Error: The AVPlayerItem instance has failed with the error code -1001 and domain "NSURLErrorDomain"

According to the Apple docs the -1001 is a timeout. I have tried wrapping each of my parallel requests in a retry function (up to 4 times), but that doesn’t help much. Once the first request fails, it’s very likely that all subsequent requests fail as well, even though on each try I create a new Audio.Sound() from scratch and retry the loadAsync. Rarely, a retry will succeed. But each retry takes 10-15 seconds so even in the rare case that the retry works, it’s now taken me something like 20-30 seconds to load a sound. Some of these sound are long and some are as short as 5 seconds, and that doesn’t seem to affect the likelihood of failure.

So I’m not convinced it’s just a straightforward HTTP timeout – I’m wondering if it’s possible that there is some issue somewhere between Expo AV and the actual network request to fetch the sound such that if you fire off too many requests in parallel, some of them begin to fail and will never load correctly after that. It’s a somewhat mysterious behavior, if anyone could shed some light on it that would be very helpful, thank you.

Otherwise if there is a better way to accomplish my task that I’m not seeing, please let me know. Basically I need 3-5 sounds to load in order to for my interface to be usable so I’d like them to load as quickly as possible.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.