MediaRecorder onstop callback doesn't get called in iOS15

Hi,

I'm using MediaRecorder for screen recording of canvas , along with audio.

simplified code to implement screen recorder

//intialise stream
const canvas = document.querySelector('.main-canvas');
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });

for (let track of canvas.captureStream().getTracks()) {
    stream.addTrack(track);
}
recorder = new MediaRecorder(stream);
chunks = [];
recorder.ondataavailable = ({ data }) => {
    if (data) chunks.push(data);
};


recorder.start();

recorder.onstop = () => {
   const videoBlob =  new Blob(chunks, {
      type: 'video/mp4'
    });
   chunks = []
   //stop mic access after use
   try{
        for (let track of stream.getTracks()) {
            track?.stop();
        }
    }catch(e){}
    return videoBlob;
}

so when i call recorder.stop() , the recorder.onstop method is not getting called sometimes randomly.

And also in case when recorder.onstop is not called , recorder.ondataavailable is not called even a single time,So it returns empty Blob output.

This only occurs in iOS 15 device's , it occurs randomly 40% of the times.

Is there any workaround for this, or what is cause of this issue?

Thanks in advance

I am also experiencing this issue. Would be great to know if there is a fix.

I’ve been experiencing the same thing. It’s seemingly random And I haven’t been able to pinpoint why.

Can anyone from Apple chime in?

Did you ever find a solution?

I just submitted for a Code-level technical support on this so I will let you both know what they tell me

I am also experiencing this issue. Would be great to know if there is a fix.

Anybody got an update on this? The problem still exists.

MediaRecorder onstop callback doesn't get called in iOS15
 
 
Q