Skip to content

Dartium does not support Web Audio API #1432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sethladd opened this issue Feb 1, 2012 · 10 comments
Closed

Dartium does not support Web Audio API #1432

sethladd opened this issue Feb 1, 2012 · 10 comments

Comments

@sethladd
Copy link
Contributor

sethladd commented Feb 1, 2012

The following Dart code:

import('dart:dom');

main() {

  var audioContext = new AudioContext();

  var source = audioContext.createBufferSource();
  source.connect(audioContext.destination);

  var xhr = new XMLHttpRequest();
  xhr.open("GET", "techno.mp3", true);
  xhr.responseType = "arraybuffer";
  xhr.addEventListener('load', () {
      var buffer = audioContext.createBuffer(xhr.response, false);
      source.buffer = buffer;
      source.noteOn(0);
  });
  xhr.send();

}

(which works fine in JavaScript) does not work in Dartium

Error:

Exception: NotImplementedException
Stack Trace: 0. Function: 'AudioContextImplementation._bind@1c3f8015' url: '/b/build/slave/dartium-mac-inc/build/src/xcodebuild/DerivedSources/Release/webkit/bindings/AudioContextImplementation.dart' line:61 col:3
 1. Function: 'AudioContextImplementation.AudioContextImplementation.' url: '/b/build/slave/dartium-mac-inc/build/src/xcodebuild/DerivedSources/Release/webkit/bindings/AudioContextImplementation.dart' line:57 col:15
 2. Function: '::main' url: 'http://localhost:8000/app.dart' line:5 col:20

Dartium version: 18.0.1023.0 (Developer Build 119649 Mac OS X)

See attachments for HTML and MP3


Attachments:
techno.mp3 (362.45 KB)
app.dart (448 Bytes)
index.html (325 Bytes)

@sethladd
Copy link
Contributor Author

sethladd commented Feb 1, 2012

A more reduced test case, which fails in Dartium:

#import('dart:dom');

main() {

  var audioContext = new AudioContext();

  var source = audioContext.createBufferSource();
  source.connect(audioContext.destination, 0, 0);

}

error:

Exception: NotImplementedException
Stack Trace: 0. Function: 'AudioContextImplementation._bind@1c3f8015' url: '/b/build/slave/dartium-mac-inc/build/src/xcodebuild/DerivedSources/Release/webkit/bindings/AudioContextImplementation.dart' line:61 col:3
 1. Function: 'AudioContextImplementation.AudioContextImplementation.' url: '/b/build/slave/dartium-mac-inc/build/src/xcodebuild/DerivedSources/Release/webkit/bindings/AudioContextImplementation.dart' line:57 col:15
 2. Function: '::main' url: 'http://localhost:8000/app.dart' line:5 col:22

@dgrove
Copy link
Contributor

dgrove commented Feb 1, 2012

Set owner to [email protected].
Added Area-Dartium, Triaged labels.

@DartBot
Copy link

DartBot commented Apr 2, 2012

This comment was originally written by [email protected]


Seth, that apparently works fine with the most recent Dartium.

May you double check?


Set owner to @sethladd.
Added NeedsInfo label.

@alextekartik
Copy link

It cannot be tested in Dartium yet due to issue: 1773 http://code.google.com/p/dart/issues/detail?id=1773
Currently xhr.response is not accessible (in Dartium only, fine in js) so the mp3 cannot be read

@DartBot
Copy link

DartBot commented Apr 28, 2012

This comment was originally written by [email protected]


Closing w/ assumed stale, please, reopen if still an issue.


Added AssumedStale label.

@alextekartik
Copy link

Below is a sample code that works in JS in Chrome but not in Dartium. It simply plays a simple generated sound. I don't know the proper way to re-open a bug...

    dom.AudioContext audioContext = new dom.AudioContext();
   
    final int SAMPLE_RATE = 44100;
    final double PI_2 = Math.PI * 2;
    final int BUFFER_SIZE = 4096;
    dom.AudioBuffer audioBuffer = audioContext.createBuffer(1, BUFFER_SIZE, SAMPLE_RATE);
    
    dom.Float32Array buf = audioBuffer.getChannelData(0);
    
    for (int i = 0; i < 4096; ++i) {
      buf[i] = Math.sin(440 * PI_2 * i / SAMPLE_RATE);
    }
    
    dom.AudioBufferSourceNode source = audioContext.createBufferSource();
    source.buffer = audioBuffer;
    source.connect(audioContext.destination, 0);
    source.noteOn(0);

In Chrome/JS we here a sound. In Dartium we get the following error:

Exception: UnsupportedOperationException: [info: ..\bindings\dart\custom\DartAudioBufferSourceNodeCustom.cpp:42]
Stack Trace: 0. Function: 'AudioBufferSourceNodeImplementation.set:buffer' url: 'e:\b\build\slave\dartium-win-full\build\src\build\Release\obj\global_intermediate\webkit\bindings\dart\dart\AudioBufferSourceNodeImplementation.dart' line:16 col:3

Tested on Windows DartEditor Build 7199 (as of 2012-05-01).

@sethladd
Copy link
Contributor Author

sethladd commented May 1, 2012

Thanks Alex. Re-opened.

We are moving away from the dart:dom libraries. Can you try with dart:html?


Added Triaged label.

@alextekartik
Copy link

Smae code using dart:html below works in Chrome/JS but failed in Dartium like for the DOM API:

Exception: UnsupportedOperationException: [info: ..\bindings\dart\custom\DartAudioBufferSourceNodeCustom.cpp:42]
Stack Trace: 0. Function: 'AudioBufferSourceNodeImplementation.set:buffer' url: 'e:\b\build\slave\dartium-win-full\build\src\build\Release\obj\global_intermediate\webkit\bindings\dart\dart\AudioBufferSourceNodeImplementation.dart' line:16 col:3
 1. Function: '[email protected]:buffer' url: 'e:\b\build\slave\dartium-win-full\build\src\build\Release\obj\global_intermediate\webkit\bindings\dart\html\dartium\AudioBufferSourceNode.dart' line:7 col:52
 
Source code:

    AudioContext audioContext = new AudioContext();
    
    final int SAMPLE_RATE = 44100;
    final double PI_2 = Math.PI * 2;
    final int BUFFER_SIZE = 4096;
    AudioBuffer audioBuffer = audioContext.createBuffer(1, BUFFER_SIZE, SAMPLE_RATE);
    
    Float32Array buf = audioBuffer.getChannelData(0);
    
    for (int i = 0; i < 4096; ++i) {
      buf[i] = Math.sin(440 * PI_2 * i / SAMPLE_RATE);
    }
    
    AudioBufferSourceNode source = audioContext.createBufferSource();
    source.buffer = audioBuffer;
    source.connect(audioContext.destination, 0);
    source.noteOn(0);

@DartBot
Copy link

DartBot commented May 4, 2012

This comment was originally written by [email protected]


Alex, thanks a lot for reporting and this issue should be fixed now.

General plea: please, let's not make this issue a catch all for troubles with Audio API---it's better to file a separate issue referencing potentionally related one.

Thanks in advance!


Set owner to [email protected].
Added Fixed label.

@alextekartik
Copy link

Great it is fixed as of build 7323. And yes I'll report API bugs one by one as I test them. I started with issue #2897 regarding AudioContext.decodeAudioData

copybara-service bot pushed a commit that referenced this issue Apr 9, 2025
Revisions updated by `dart tools/rev_sdk_deps.dart`.

core (https://github.com/dart-lang/core/compare/7a80178..af37fe5):
  af37fe54  2025-04-04  Lasse R.H. Nielsen  Adds `[Heap]PriorityQueue.of` constructor. (dart-lang/core#734)
  635dfa32  2025-04-03  Kevin Moore  [collection] explicitly make BoolList abstract interface (dart-lang/core#875)

ecosystem (https://github.com/dart-lang/ecosystem/compare/391a80c..7f6f1c1):
  7f6f1c1  2025-04-09  Daco Harkes  [firehose] Fix dart_apitool invocations with pub workspaces (dart-lang/ecosystem#355)
  0eb0349  2025-04-07  Moritz  Fix tagging in publishing workflow (again) (dart-lang/ecosystem#353)
  1ee8568  2025-04-07  Moritz  Update README.md (dart-lang/ecosystem#352)

http (https://github.com/dart-lang/http/compare/6fabf06..e4ddd3e):
  e4ddd3e  2025-04-07  Moritz  Merge pull request `#1750` from dart-lang/fixTags
  42b42e3  2025-04-07  Moritz  Fix tags
  54bf0f7  2025-04-07  Moritz  Merge pull request `#1748` from dart-lang/fixPublish
  84adca0  2025-04-04  Moritz  Merge pull request `#1432` from dart-lang/fixHealth
  8534a69  2025-04-04  Moritz  Remove ignore breaking
  b80436a  2025-04-04  Moritz  allow underscore
  949cd87  2025-04-04  Moritz  Fix publishing workflow
  996c5d1  2024-12-17  Moritz  ignore only for breaking changes
  e5321f7  2024-12-17  Moritz  Update .github/workflows/health.yaml
  f902d8a  2024-12-17  Moritz  typo
  35f6e9a  2024-12-17  Moritz  exclude websocket
  ca8caee  2024-12-17  Moritz  Ignore http
  621401e  2024-12-17  Moritz  remove ignore license
  ce20b2a  2024-12-17  Moritz  Fix health workflow

test (https://github.com/dart-lang/test/compare/c1fa1e6..8643fbf):
  8643fbf3  2025-04-09  Ömer Sinan Ağacan  Migrate from deprecated `dart:js`, `dart:js_util`, `package:js_util` to `dart:js_interop` (dart-lang/test#2478)

tools (https://github.com/dart-lang/tools/compare/b963bbf..d74f9e1):
  d74f9e13  2025-04-08  Loïc Sharma  [UA] Add a Flutter event for plugins injected into an iOS/macOS project. (dart-lang/tools#2062)
  f34228f8  2025-04-08  Kevin Moore  [graphs] fix readme CI badge (dart-lang/tools#2068)
  0102cd63  2025-04-08  Kevin Moore  [markdown] fix crash test (dart-lang/tools#2067)

webdev (https://github.com/dart-lang/webdev/compare/697f2f7..c8b1cfa):
  c8b1cfa9  2025-04-07  Srujan Gaddam  [dwds] Split hot reload callback into 2, disable breakpoints in changed files, and publish 24.3.10 (dart-lang/webdev#2606)
  8d8413f5  2025-04-04  Wdestroier  Support custom hostname and TLS options (dart-lang/webdev#2588)

Change-Id: Idbad02c2087ceb3c7d0f7efcf0721f4806475e8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421542
Reviewed-by: Konstantin Shcheglov <[email protected]>
Auto-Submit: Devon Carew <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants