question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Recording does not work on iOS 15

See original GitHub issue

Description

Unable to record a video from a device on iOS 15. This is reliably reproducible when recording a video that has a length of about 1.5-2 minutes.

I believe the issue lies in the RecordRTC library as I have tested it on webrtc-experiment and it doesn’t work too. I added some more logs on https://github.com/muaz-khan/RecordRTC/issues/782#issuecomment-986439163 If you guys have any ideas on how to use the library for iOS devices considering the caveats in RecordRTC I would appreciate to hear it. Please feel free to contact me if more info is needed, thanks!

Steps to reproduce

  1. Set up this repo for local development
  2. Update the maxLength in https://github.com/collab-project/videojs-record/blob/a36ba88e74ecadbf765c2bf191fb094e724a75b2/examples/audio-video.html to ~360 for testing more long-lasting videos
  3. Host it locally via HTTPS (need to update the start script with https key: npm run build && webpack serve --config ./build-config/webpack.dev.main.js --https)
  4. Proceed to the local network address of your PC from an iOS device
  5. Try recording a video for about 1.5-2 min.

Results

Expected

The replay via online-player should be working and the file should not be 0 bytes in length.

Actual

It both can’t be replayed in the online player or to be downloaded and played since the file is broken. Also, the error below is thrown.

Error output

Screen Shot 2021-12-06 at 12 06 02
"ERROR:" – "(CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED)" – "The media could not be loaded, either because the server or network failed or because the format is not supported."

Additional Information

versions

videojs

7.14.3

recordrtc

5.6.2

browsers

  • Safari 15
  • Chrome 96

OSes

iOS 15.1.1

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:5

github_iconTop GitHub Comments

7reactions
chernodubcommented, Jan 27, 2022

For anyone looking (including @markitosgv), I was able to fix the issue by monkey-patching the bitrate of the video on iOS devices (as far as I understood, videojs-record doesn’t provide an API to do that properly):

function isIOS() {
  return [
    'iPad Simulator',
    'iPhone Simulator',
    'iPod Simulator',
    'iPad',
    'iPhone',
    'iPod'
  ].includes(navigator.platform)
  // iPad on iOS 13 detection
  || (navigator.userAgent.includes("Mac") && "ontouchend" in document)
}

/** 
 * On some of the iOS devices, the video gets too big so that Safari fails to process the file and returns 0-byted one without failing (which is undocumented and, obviously, an error).
 * As a workaround, we reduce the quality of a video in the native recording API (which is used by the `videojs-record` and `RecordRTC` internally) so that it won't get to this size.
 * 
 * TODO: remove it when https://bugs.webkit.org/show_bug.cgi?id=85851 is resolved by Apple.
 */
if (isIOS()) {
  const DefaultMediaRecorder = window.MediaRecorder;
  const kb = 8 * 1024;
  const preferredBitRatePerSecond = 100 * kb;
  window.MediaRecorder = class extends DefaultMediaRecorder {
    constructor(stream, options) {
      super(stream, {
        ...options, 
        audioBitsPerSecond: preferredBitRatePerSecond,
        videoBitsPerSecond: preferredBitRatePerSecond,
      });
    }
  }
}
1reaction
markitosgvcommented, Jan 27, 2022

you save my day @chernodub

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix Screen Recording Not Working on iPhone after iOS 16.2 ...
Launch Settings App → Find General → Tap Restrictions (Enter passcode) → Scroll down the screen to last until you appear Game Center...
Read more >
Fix: iOS 15 Screen Recording Not Working on iPhone iPad
For iOS 11 or earlier: Go to Settings > General > Restrictions > Game Center and turned off-screen recording, restart your device, and...
Read more >
[Recording Not Working] How To Fix iOS 14/15 Screen ...
How-To Steps To Fix Screen Recording Not Working On iPhone After Update iOS 15: ; 1. Step 1: Force Restart Your iPhone. ;...
Read more >
9 Ways to fix Screen Recording not working on iPhone and iPad
To fix Screen Recording not working on iPhone or iPad, 1. Turn Screen Recording on in Control Center, 2. Force restart your device,...
Read more >
Top 4 Ways to Fix iOS 16/15 Screen Recording Not Working
Method 1 Make Sure Screen Recorder Opened in Control Center · Method 2 Force Restart Your iPhone to Solve Screen Recording Error ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found