<?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>258567</bug_id>
          
          <creation_ts>2023-06-27 07:09:46 -0700</creation_ts>
          <short_desc>REGRESSION (Safari 16.x?): MediaRecorder ondataavailable outputs Blobs with size:0 type:&quot;&quot;</short_desc>
          <delta_ts>2023-07-18 08:52:55 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Media</component>
          <version>Safari 16</version>
          <rep_platform>Mac (Apple Silicon)</rep_platform>
          <op_sys>macOS 13</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Blocker</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Omer Okcuoglu">omerokcuoglu</reporter>
          <assigned_to name="youenn fablet">youennf</assigned_to>
          <cc>chrisguttandin</cc>
    
    <cc>eric.carlson</cc>
    
    <cc>jer.noble</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1963797</commentid>
    <comment_count>0</comment_count>
      <attachid>466831</attachid>
    <who name="Omer Okcuoglu">omerokcuoglu</who>
    <bug_when>2023-06-27 07:09:46 -0700</bug_when>
    <thetext>Created attachment 466831
Example js file to test bug.

Hi,

MediaRecorder ondataavailable outputs Blobs with size:0 type:&quot;&quot;

This issue is introduced with Safari 16. I can not pin point the version. MediaRecorder works flawlessly with Safari 15 on Intel and in any other browser.

Problem is consistent with both of these streams:
1- audioContext.createMediaStreamDestination
2- navigator.mediaDevices.getUserMedia({ audio: true }) 


I am attaching a js file for you to test. It only requires you to insert a button in your html. It will output ondataavailable Blobs every second upon click.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1963826</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-06-27 08:49:13 -0700</bug_when>
    <thetext>&lt;rdar://problem/111393489&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1963894</commentid>
    <comment_count>2</comment_count>
    <who name="Omer Okcuoglu">omerokcuoglu</who>
    <bug_when>2023-06-27 14:45:52 -0700</bug_when>
    <thetext>iPadOS webkit seems to be working as expected; so this seems to be an osX Safari specific issue.

Made the following test via using StreamDestination, triggering sounds during recording.

If no sound is played following the initial playback;

1) Chrome reports a consistent Blob size of 238, each second.

2) Firefox reports a Blob size of 0 that spikes at 1047 in every 3-4 seconds.

3) iPad test is done within &quot;Koder App&quot;. Assuming it uses webkit, it reports fluctuating Blob sizes of 0 - 604 - 1148 - 544 - 1208. Seems to be the least stable. Perhaps this report does not effect the recorded audio output, I was simply checking the signal flow for this test. Also during sound playback, block size is reported as 0 many times.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1964423</commentid>
    <comment_count>3</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2023-06-30 01:53:19 -0700</bug_when>
    <thetext>Here is a jsfiddle that should show the issue: https://jsfiddle.net/m80q97yn/
@Omer, can you confirm you are able to reproduce this issue?
Which platform do you have issues with? Testing locally on my macStudio, it seems to work fine.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1964432</commentid>
    <comment_count>4</comment_count>
    <who name="Omer Okcuoglu">omerokcuoglu</who>
    <bug_when>2023-06-30 02:23:31 -0700</bug_when>
    <thetext>@Youenn issue is still the same. Blob return is 0.

Below is the output until I hit stop:

starting
mimeType: audio/mp4
data captured size: 0
data captured size: 0
data captured size: 0
data captured size: 0
data captured size: 0
captured: NaN

I am on 
Hardware: m1 Pro Macbook Pro 16&quot;
osX: Ventura 13.4.1
Safari: 16.4

https://jsfiddle.net/m80q97yn/ works fine on iOS.

If I recall correctly, I did not experience this issue with Safari 16.2.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1964435</commentid>
    <comment_count>5</comment_count>
    <who name="Omer Okcuoglu">omerokcuoglu</who>
    <bug_when>2023-06-30 02:30:13 -0700</bug_when>
    <thetext>Edit:

using Safari version 16.5.1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1964437</commentid>
    <comment_count>6</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2023-06-30 02:34:29 -0700</bug_when>
    <thetext>(In reply to Omer Okcuoglu from comment #4)
&gt; @Youenn issue is still the same. Blob return is 0.
&gt; 
&gt; Below is the output until I hit stop:
&gt; 
&gt; starting
&gt; mimeType: audio/mp4
&gt; data captured size: 0
&gt; data captured size: 0
&gt; data captured size: 0
&gt; data captured size: 0
&gt; data captured size: 0
&gt; captured: NaN
&gt; 
&gt; I am on 
&gt; Hardware: m1 Pro Macbook Pro 16&quot;
&gt; osX: Ventura 13.4.1
&gt; Safari: 16.4
&gt; 
&gt; https://jsfiddle.net/m80q97yn/ works fine on iOS.
&gt; 
&gt; If I recall correctly, I did not experience this issue with Safari 16.2.

Can you try on latest Safari Tech Preview.
I am not able to reproduce on my macBookPro, but Sonoma...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1964439</commentid>
    <comment_count>7</comment_count>
    <who name="Omer Okcuoglu">omerokcuoglu</who>
    <bug_when>2023-06-30 02:40:21 -0700</bug_when>
    <thetext>Problem continues with Safari Tech Preview version 173.

I will try your link in an Apple Store that are likely to have m2 macbook pros with Ventura with whatever Safari version they have.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1964669</commentid>
    <comment_count>8</comment_count>
    <who name="Omer Okcuoglu">omerokcuoglu</who>
    <bug_when>2023-07-01 23:51:33 -0700</bug_when>
    <thetext>Problem solved!

It is about the system Sampling Rate. Mine was set to 96kHz and switching back to 48kHz has made  the MediaRecorder stream working again as expected. 

Apparently this also solves my other previously submitted bug: https://bugs.webkit.org/show_bug.cgi?id=249970

With Safari 16.4 these pops started to happen more often rather than just the initial pops. Keeping sample rate at 48kHz has eliminated the pops too!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1965107</commentid>
    <comment_count>9</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2023-07-05 06:23:43 -0700</bug_when>
    <thetext>The issue is that we are not able to create a AudioConverterNew:
2023-06-30 12:46:29.299606+0300 0x364661   Error     0x0                  57221  com.apple.WebKit.GPU: (WebCore) [com.apple.WebKit:MediaStream] AudioSampleBufferCompressor AudioConverterNew failed with 1718449215

I tried switching to 96KHz on my setup and media recorder works for me. Maybe OS support is different.

@Omer, how did you change to 96KHz and back to 48KHz?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1965303</commentid>
    <comment_count>10</comment_count>
    <who name="Omer Okcuoglu">omerokcuoglu</who>
    <bug_when>2023-07-06 04:47:53 -0700</bug_when>
    <thetext>Once I set the Sampling Rate on Audio MIDI Setup from 96k to 48k and vice versa; I reload the page. Then the 48k works and 96k does not work. If I change the sampling rate and not reload the page, the MediaRecorder keeps its respective behaviour.


My OS is 13.4.1
Safari: 16.5.1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1965824</commentid>
    <comment_count>11</comment_count>
    <who name="Omer Okcuoglu">omerokcuoglu</who>
    <bug_when>2023-07-09 01:57:41 -0700</bug_when>
    <thetext>I can add one more note which might be important. The sampling rate change in Audio/MIDI setup needs be made on Audio Output like MacbookPro Speakers. Interestingly changing Sampling rate on Microphone Input has no effect. System Output sampling rate determines whether it works or not.

I have checked this problem and same approach with Intel Macbook Pro on Safari 15 and managed to reproduce the problem.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1967015</commentid>
    <comment_count>12</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2023-07-17 01:56:53 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/15880</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1967188</commentid>
    <comment_count>13</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-07-18 08:52:52 -0700</bug_when>
    <thetext>Committed 266130@main (8c01a9fbfd35): &lt;https://commits.webkit.org/266130@main&gt;

Reviewed commits have been landed. Closing PR #15880 and removing active labels.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>466831</attachid>
            <date>2023-06-27 07:09:46 -0700</date>
            <delta_ts>2023-06-27 07:09:46 -0700</delta_ts>
            <desc>Example js file to test bug.</desc>
            <filename>testRecorder_mic.js</filename>
            <type>application/x-javascript</type>
            <size>1301</size>
            <attacher name="Omer Okcuoglu">omerokcuoglu</attacher>
            
              <data encoding="base64">InVzZSBzdHJpY3QiOwoKCmxldCBhdWRpb0NhcHR1cmVEZXN0aW5hdGlvbjsKbGV0IG1lZGlhUmVj
b3JkZXI7CmxldCBjYXB0dXJlZERhdGEgPSBbXTsKCgovLy0tLSAxIC0tLSBBZGQgdGhlIGZvbGxv
d2luZyByZWNvcmQgYnV0dG9uIGluIHlvdXIgaHRtbDogPGJ1dHRvbiBuYW1lPSJyZWNvcmQiIHR5
cGU9ImJ1dHRvbiI+UmVjb3JkPC9idXR0b24+CgoKCmxldCByZWNvcmRCdXR0b24gPSBkb2N1bWVu
dC5xdWVyeVNlbGVjdG9yKCdidXR0b25bbmFtZT0icmVjb3JkIl0nKTsKCQpsZXQgcmVjb3JkU3Rh
dGUgPSBmYWxzZTsKCnJlY29yZEJ1dHRvbi5hZGRFdmVudExpc3RlbmVyKCdjbGljaycsIGFzeW5j
IGZ1bmN0aW9uKGV2ZW50KSB7CgkKCWlmICghcmVjb3JkU3RhdGUpIHsKCQkKCQlhdWRpb0NhcHR1
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