Bug 172261 - createMediaStreamSource only works when called shortly after stream is created
Summary: createMediaStreamSource only works when called shortly after stream is created
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Audio (show other bugs)
Version: WebKit Local Build
Hardware: Mac macOS 10.12
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-05-17 22:19 PDT by Andrew Morris
Modified: 2022-02-12 18:36 PST (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Morris 2017-05-17 22:19:47 PDT
WebKit's createMediaStreamSource has a bug which requires it to be called very soon after the stream is created. If called after a delay it appears to produce a silent webaudio node.
navigator.mediaDevices.getUserMedia({ audio: true }).then((stream) => {
  cleanupJobs.push(() => stream.getTracks().forEach(track => track.stop()));

  if (useDelay) {
    // Bug occurs
    return delay(500).then(() => stream);
  }

  // Bug does not occur
  return stream;
}).then((stream) => {
  const source = audioCtx.createMediaStreamSource(stream);

  // ... Visualize audio data from source

};

Super easy repro here:
https://output.jsbin.com/hegijaz

Built from github hash 141b0ddff819d52e6e8ceeed29dc72fba5d4b1a6, git-svn-id: http://svn.webkit.org/repository/webkit/trunk@216354 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Comment 1 Radar WebKit Bug Importer 2017-05-17 23:50:26 PDT
<rdar://problem/32266432>
Comment 2 Andrew Morris 2017-05-23 18:00:08 PDT
The jsbin doesn't repro the issue for me anymore in a more recent build (git b54ca7d). However I suspect the issue is still there for remote streams. Please get in touch for more details if needed.
Comment 3 Daniel Rossi 2021-03-12 06:48:29 PST
The problem is evident here merely changing streams and setting up a new mediastreamsource. on IOS

https://jsfiddle.net/danrossi303/gsLy96hc/3/