<?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>113274</bug_id>
          
          <creation_ts>2013-03-25 21:52:30 -0700</creation_ts>
          <short_desc>ScriptProcessorNode should block when being rendered in OfflineAudioContexts</short_desc>
          <delta_ts>2022-05-07 10:11:19 -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>Web Audio</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>UNCONFIRMED</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>113121</dependson>
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Russell McClellan">russell.mcclellan</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>aldel</cc>
    
    <cc>brad</cc>
    
    <cc>crogers</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>863351</commentid>
    <comment_count>0</comment_count>
    <who name="Russell McClellan">russell.mcclellan</who>
    <bug_when>2013-03-25 21:52:30 -0700</bug_when>
    <thetext>The purpose of OfflineAudioContext is nominally to be able to &quot;mix down&quot; web audio sessions into a single audio buffer.  However, the current behavior with ScriptProcessorNodes isn&apos;t useful:

steps to reproduce: 
1) create OfflineAudioContext
2) create sine wave generator ScriptProcessorNode, attach to destination
3) attach an oncomplete and start rendering the offline audio context

wanted result:
The ScriptProcessorNode is called several times, creating a clean sine wave in the final buffer.

actual result:
the offline audio context renders at full speed on the audio thread, not blocking for the Script Processing on the main thread.  If the main thread isn&apos;t done by the time audio is needed, that buffer is dropped.  If you&apos;re lucky, a few buffers of sine wave here or there will get mixed down.

While the current behavior doesn&apos;t directly violate the spec, it does seem like it&apos;s neither useful nor intended.  I mentioned this to the public web audio list here:
http://lists.w3.org/Archives/Public/public-audio/2013JanMar/0396.html
But it seems there wasn&apos;t agreement that the current behavior was allowed by the current spec.

I have a patch for this (I simply added a condition variable to ScriptProcessorNode that is waited on during offline rendering) but it depends on https://bugs.webkit.org/show_bug.cgi?id=113121</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>863357</commentid>
    <comment_count>1</comment_count>
    <who name="Chris Rogers">crogers</who>
    <bug_when>2013-03-25 22:02:00 -0700</bug_when>
    <thetext>Sounds fine.  It&apos;s ok to synchronize with the main thread if it&apos;s an OfflineAudioContext (but not for the normal real-time AudioContext).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>863686</commentid>
    <comment_count>2</comment_count>
    <who name="Russell McClellan">russell.mcclellan</who>
    <bug_when>2013-03-26 08:16:59 -0700</bug_when>
    <thetext>Yeah, my patch doesn&apos;t affect the realtime case at all.  As I said, I&apos;m waiting to add a patch because I was working on top of the patch I made for https://bugs.webkit.org/show_bug.cgi?id=113121

As a complete newcomer here, I don&apos;t really have a sense for how long patches like that take to go through, or really any sense of what the process is supposed to be.  Let me know if there&apos;s anything I can do to expedite the process or any protocols that I missed :-).</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>