Bug 78043 - Make it possible to create JavaScriptAudioNode-based Web Audio nodes
Summary: Make it possible to create JavaScriptAudioNode-based Web Audio nodes
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Audio (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
Depends on:
Reported: 2012-02-07 14:45 PST by Boris Smus
Modified: 2013-05-10 17:48 PDT (History)
3 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Boris Smus 2012-02-07 14:45:06 PST
I'm trying to create a custom node based on the JavaScriptAudioNode by extending its prototype with a custom function, and then plugging it into the audio graph. Unfortunately, doing this causes a "SyntaxError: Invalid destination node" error, and the audio graph rejects the custom node.

Here's what I'm doing:

1. I extend the context with a createCustomNode call, as follows:

// Augment the context with a createMeterNode call that returns an augmented
// JavaScriptAudioNode.

function registerCustomWebAudioNode(context, constructorName, classObject) {
  // Get the webkitAudioContext and extend its prototype.
  webkitAudioContext.prototype[constructorName] = function() {
    var customNode = new classObject(this);
    customNode.prototype = context.createJavaScriptNode(2048, 1, 1);
    return customNode;

function MeterNode(context) {

MeterNode.prototype.onClip = function(callback) {
  // ...

2. Then, I'm using the custom node as follows:

    // Assuming context, source are initialized earlier.
    meter = context.createMeterNode();
    // Connect source to meter node to destination.

3. I get an error: SyntaxError: Invalid destination node

This sounds like something at the JavaScript - C++ bindings layer.
Comment 1 Raymond 2012-04-05 01:03:09 PDT
Interesting, just curious on your implementation. Do you have full source code on how you call registerCustomWebAudioNode and use MeterNode etc.?
Comment 2 Chris Rogers 2013-05-10 17:48:21 PDT
It appears that extending the prototype like this is very hard or impossible to do given the way the JS bindings system works