<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>232981</bug_id>
          
          <creation_ts>2021-11-10 20:06:28 -0800</creation_ts>
          <short_desc>MediaRecorder API onstop callback doesn&apos;t get called</short_desc>
          <delta_ts>2022-02-12 19:33:42 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebRTC</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>iPhone / iPad</rep_platform>
          <op_sys>iOS 15</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>HTML5, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Raja">rajaaluri66</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>ggaren</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1813894</commentid>
    <comment_count>0</comment_count>
    <who name="Raja">rajaaluri66</who>
    <bug_when>2021-11-10 20:06:28 -0800</bug_when>
    <thetext>Hi,

I&apos;m using MediaRecorder for screen recording of canvas , along with audio.

simplified code to implement screen recorder
/* code starts here */
//intialise stream
const canvas = document.querySelector(&apos;.main-canvas&apos;);
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 }) =&gt; {
    if (data) chunks.push(data);
};


recorder.start();

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

/* code ends here */
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&apos;s , it occurs randomly 40% of the times.

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

Thanks in advance</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1815869</commentid>
    <comment_count>1</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2021-11-17 01:45:54 -0800</bug_when>
    <thetext>Hi Raja, do you have any potential repro steps, even if not working 100% of the time?
Do you know if this is iOS specific or also happening in MacOS?

If you can reproduce the issue, can you send me a sysdiagnose (youenn@apple.com) with the information of when the bug did happen?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1816288</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-11-17 20:07:37 -0800</bug_when>
    <thetext>&lt;rdar://problem/85532501&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1816314</commentid>
    <comment_count>3</comment_count>
    <who name="Raja">rajaaluri66</who>
    <bug_when>2021-11-17 22:15:46 -0800</bug_when>
    <thetext>Hi youenn,

this iOS specific issue(only in iOS 15), this not happening in macOs or other iOS version. I&apos;ve checked in all device&apos;s.

I&apos;ll send you playground link to test in few minutes</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1821091</commentid>
    <comment_count>4</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2021-12-07 10:05:23 -0800</bug_when>
    <thetext>Raja, can you provide that test case?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1821129</commentid>
    <comment_count>5</comment_count>
    <who name="Raja">rajaaluri66</who>
    <bug_when>2021-12-07 11:32:02 -0800</bug_when>
    <thetext>Hi Geoffrey,

Sorry for the delay 
I didn&apos;t add code snippet because this issue didn&apos;t reproduce in my ipad, after i updated it iOS 15.2, I&apos;ll check once again and verify it

For your reference, i adding code file earlier in which I faced issue.

code link- 
https://stackblitz.com/edit/web-platform-gklpub?file=index.html

hosted link - 
https://media-recorder-test.netlify.app/

you can check this in iOS 15.0 or 15.1
ISSUE - onStopEvent function is not called after recording is stopped



Thanks for instant response, &amp; being helpful</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1824296</commentid>
    <comment_count>6</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2021-12-15 02:18:52 -0800</bug_when>
    <thetext>@raja, can you confirm whether you cannot reproduce anymore in iOS 15.2?
If so, can we mark it as configuration changed?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1840806</commentid>
    <comment_count>7</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2022-02-12 19:33:42 -0800</bug_when>
    <thetext>This should now be fixed in STP 139, iOS 15.4 Beta, and macOS 12.3 Beta.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>