react-native-video: AVFoundationErrorDomain -11800

Bug

I am not able play remote videos on an IOS simulator (it was not possible to test it on a real device).

When I try to play an .m3u8 file or even an mp4 file, the console prints the following error:

2020-03-05 11:09:56.213199-0800 rntest[25157:381125] Task <F24E38AA-49E7-4546-B3F9-EE84F50EA7C0>.<3> load failed with error Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=https://cdn.theoplayer.com/video/elephants-dream/1280/media_w370587926_b2962000_vo_slen_t64TWFpbg==_0.ts, NSErrorFailingURLKey=https://cdn.theoplayer.com/video/elephants-dream/1280/media_w370587926_b2962000_vo_slen_t64TWFpbg==_0.ts, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <F24E38AA-49E7-4546-B3F9-EE84F50EA7C0>.<3>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <F24E38AA-49E7-4546-B3F9-EE84F50EA7C0>.<3>, NSLocalizedDescription=cancelled} [-999]
2020-03-05 11:09:56.214277-0800 rntest[25157:381125] Task <1ABBAD14-21BE-4245-92E3-6B7657D0F050>.<3> load failed with error Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=https://cdn.theoplayer.com/video/elephants-dream/en/media_w370587926_b160000_ao_slen_t64RW5nbGlzaA==_1.aac, NSErrorFailingURLKey=https://cdn.theoplayer.com/video/elephants-dream/en/media_w370587926_b160000_ao_slen_t64RW5nbGlzaA==_1.aac, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <1ABBAD14-21BE-4245-92E3-6B7657D0F050>.<3>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <1ABBAD14-21BE-4245-92E3-6B7657D0F050>.<3>, NSLocalizedDescription=cancelled} [-999]
2020-03-05 11:09:56.217 [info][tid:com.facebook.react.JavaScript] 'On error', { error: { code: -11800, domain: 'AVFoundationErrorDomain' },
  target: 3 }
2020-03-05 11:09:56.228471-0800 rntest[25157:381087] Task <F24E38AA-49E7-4546-B3F9-EE84F50EA7C0>.<3> finished

The onError event of the react-native-video video throws an error code -11800 with the domain of AVFoundationErrorDomain. The IOS emulator logs show that the error is an NSURLErrorDomain with the code -999, which means canceled.

After some research, I read that we need to go to the Info.plist file and check / update the ATS and set allow arbitrary loads to be true. This didn’t work, and when looking for more information I saw some people talking about subdomain problems (which I didn’t quite understand) or that the 999 error is common when a request is called twice or the reference to the object manager is being deallocated prematurely.

I tried many things, but I can’t seem to get it to work.

Can anyone help me with this? Do I need to do any extra configuration for this to work?

Platform

Which player are you experiencing the problem on:

  • iOS

Environment info

React native info output:

 System:
    OS: macOS Mojave 10.14.5
    CPU: (4) x64 Intel(R) Core(TM) i5-8500B CPU @ 3.00GHz
    Memory: 119.88 MB / 7.95 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.5.0 - /usr/local/bin/node
    Yarn: 1.16.0 - /usr/local/bin/yarn
    npm: 6.9.0 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
  IDEs:
    Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0 
    react-native: 0.61.5 => 0.61.5 
  npmGlobalPackages:
    react-native-cli: 2.0.

Library version: 5.0.2

Steps To Reproduce

  1. yarn add @react-native-video
  2. cd ios && pod install && cd …
  3. react-native run-ios …

Expected behaviour

The video should play

Reproducible sample code

<Video
    ref={videoRef}
    source={{
      uri: "https://cdn.theoplayer.com/video/elephants-dream/playlist.m3u8", 
      type: "application/x-mpegurl"
   }}
  controls={false}
   resizeMode={'contain'}
   onLoad={onLoadEnd}
   onProgress={onProgress}
   onEnd={onEnd}
   paused={!state.play}
   {...rest}
/>

Video sample

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 7
  • Comments: 16

Most upvoted comments

I managed to fix this by doing the following:

  1. Stash any of your changes in your git branch, then revert back to an earlier branch (in my case, my development branch), and reload your app in the simulator.
  2. In your iOS Simulator menu: Device -> Erase All Content and Settings…
  3. Revert back to your original git branch and restart your dev Metro server.
  4. Reopen your app and try the video again. The error should be gone.

I only have theories on why this would work, and haven’t done the legwork to see if #1 or #2, or a combination of both, is the real fix here, but hopefully this will help someone else out.

Any updates on this?

I managed to fix this by doing the following:

  1. Stash any of your changes in your git branch, then revert back to an earlier branch (in my case, my development branch), and reload your app in the simulator.
  2. In your iOS Simulator menu: Device -> Erase All Content and Settings…
  3. Revert back to your original git branch and restart your dev Metro server.
  4. Reopen your app and try the video again. The error should be gone.

I only have theories on why this would work, and haven’t done the legwork to see if #1 or #2, or a combination of both, is the real fix here, but hopefully this will help someone else out.

The second option worked for me. 🚀 👍🏻 👏🏻

@Gabogg07 I haven’t found a solution yet.

Does anyone know if this is a problem related only to the ios simulator or is it happening on a real device? I still haven’t been able to test it on a real device.