Truly independent web browser
LibWeb: Initialize AudioWorkletProcessor construction slots
Shannon Booth074f6740e705
diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_audio/audio_worklet_node.rs b/Libraries/LibWeb/Bindings/Rust/src/web_audio/audio_worklet_node.rsindex 73b0e1d9a65..4b400e11878 100644--- a/Libraries/LibWeb/Bindings/Rust/src/web_audio/audio_worklet_node.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/web_audio/audio_worklet_node.rs@@ -32,11 +32,14 @@ use super::audio_node::{};use super::audio_param::{AudioParam, AutomationRate, FixedAutomationRate};use super::audio_param_map::AudioParamMap;+use super::audio_worklet_processor::AudioWorkletProcessor;use super::base_audio_context::{AnyBaseAudioContext, BaseAudioContext};use crate::bindings::cpp_cell::CppCell;use crate::bindings::event_target::{CppEventTarget, GetTheParent};use crate::bindings::interface::{Inherits, Ref, Wrappable, Wrapped, allocate};-use crate::bindings::interface::{cell_into_abi, with_temporary_execution_context_and_callbacks};+use crate::bindings::interface::{+ cell_into_abi, implementation_if_wrapper, with_temporary_execution_context_and_callbacks, wrap,+};use crate::bindings::promise::{TaskSource, queue_a_global_task};use crate::bindings::{CallContext, Exception, WebIdlResult};use crate::html::message_port::MessagePort;@@ -55,8 +58,7 @@ pub(crate) struct AudioWorkletNode {parameter_names: Vec<Utf16String>, // descriptor order; keys for the `parameters` argumentport: Ref<MessagePort>,scope: CppCell,- processor: Cell<Option<Gc<Object>>>,- processor_errored: Cell<bool>,+ processor: Cell<Option<Ref<AudioWorkletProcessor>>>,#[gc(untraced)]pipe: RefCell<Option<Arc<AudioWorkletPipe>>>,}@@ -137,7 +139,11 @@ unsafe extern "C" {options: *mut c_void,) -> RawNativeFunctionResult;fn web_audio_worklet_processor_constructor(scope: *mut c_void, name: usize) -> *mut c_void;- fn web_audio_worklet_set_pending_port(scope: *mut c_void, port: *mut c_void);+ fn web_audio_worklet_set_pending_data(+ scope: *mut c_void,+ node_reference: *mut c_void,+ transferred_port: *mut c_void,+ );fn web_audio_worklet_clear_pending_data(scope: *mut c_void);fn web_audio_worklet_set_current_frame(scope: *mut c_void, current_frame: u64);fn web_audio_worklet_queue_processor_error(node: *mut c_void, target: *mut c_void, global: *mut c_void, error: u64);@@ -259,7 +265,6 @@ impl AudioWorkletNode {port: node_port,scope: scope.clone(),processor: Cell::new(None),- processor_errored: Cell::new(false),pipe: RefCell::new(None),});node.node.set_this(AnyAudioNode::AudioWorkletNode(node));@@ -490,9 +495,7 @@ impl AudioWorkletNode {Ok(node)}- // https://webaudio.github.io/web-audio-api/#instantiation-of-audioworkletprocessor- // "invoke processor constructor" — deferred to a queued task so the node constructor returns- // before user code runs (and pre-constructor port messages queue up for delivery afterwards).+ // https://webaudio.github.io/web-audio-api/#invoking-processor-constructorfn invoke_processor_constructor(&self,vm: &Vm,@@ -500,10 +503,17 @@ impl AudioWorkletNode {processor_port: Ref<MessagePort>,options_object: Gc<Object>,) {+ // 1. Let constructionData be the processor construction data transferred from the control thread.+ // 2. Let processorName, nodeReference and serializedPort be constructionData’s name, node, and port respectively.+ // 3. Let serializedOptions be constructionData’s options.+ // 4. Let deserializedPort be the result of StructuredDeserialize(serializedPort, the current Realm).+ // 5. Let deserializedOptions be the result of StructuredDeserialize(serializedOptions, the current Realm).+ // NB: The queued task carries the construction data with the port and options already deserialized.let worklet_realm: Gc<Realm> =unsafe { Gc::from_non_null(NonNull::new(web_audio_worklet_scope_realm(scope.as_ptr()).cast()).unwrap()) };with_temporary_execution_context_and_callbacks(worklet_realm, || {- let constructor: Gc<FunctionObject> = unsafe {+ // 6. Let processorCtor be the result of looking up processorName on the AudioWorkletGlobalScope’s node name to processor constructor map.+ let processor_ctor: Gc<FunctionObject> = unsafe {Gc::from_non_null(NonNull::new(web_audio_worklet_processor_constructor(scope.as_ptr(), self.name.raw_identity()).cast(),@@ -512,31 +522,47 @@ impl AudioWorkletNode {)};- // 1. Set the pending processor construction data: the processor-side port.- unsafe { web_audio_worklet_set_pending_port(scope.as_ptr(), cell_into_abi(processor_port)) };-- // 2. Construct the processor: Construct(processorCtor, « optionsObject »).- let processor_or_error = construct(vm, constructor, &[Value::from_object(options_object)], None);+ // 7. Store nodeReference and deserializedPort to node reference and transferred port of this AudioWorkletGlobalScope’s pending processor construction data respectively.+ unsafe {+ web_audio_worklet_set_pending_data(+ scope.as_ptr(),+ cell_into_abi(self.this()),+ cell_into_abi(processor_port),+ );+ };- // 3. Empty the pending processor construction data slot (a constructor that never chained to- // super() leaves it populated).- unsafe { web_audio_worklet_clear_pending_data(scope.as_ptr()) };- let processor = match processor_or_error {- Ok(processor) => processor,+ // 8. Construct a callback function from processorCtor with the argument of deserializedOptions. If any exceptions are thrown in the callback, queue a task to the control thread to fire an event named processorerror at nodeReference using ErrorEvent.+ // AD-HOC: A constructor that returns an object other than an AudioWorkletProcessor fails with a TypeError.+ let constructed =+ construct(vm, processor_ctor, &[Value::from_object(options_object)], None).and_then(|object| {+ implementation_if_wrapper::<AudioWorkletProcessor>(object).ok_or_else(|| {+ vm.throw_completion_with_message::<()>(+ ErrorKind::TypeError,+ "The processor constructor did not return an AudioWorkletProcessor".to_string(),+ )+ .unwrap_err()+ })+ });+ let processor = match constructed {+ Ok(processor) => Some(processor),Err(error) => {- self.processor_errored.set(true);self.pipe.borrow().as_ref().unwrap().set_state(WorkletPipeState::Failed);self.fire_processor_error(error.value());- return;+ None}};++ // 9. Empty the pending processor construction data slot.+ unsafe { web_audio_worklet_clear_pending_data(scope.as_ptr()) };+ let Some(processor) = processor else {+ return;+ };self.processor.set(Some(processor));self.node.context_value().add_audio_worklet_pipe(Arc::clone(self.pipe.borrow().as_ref().unwrap()));- // 4. Enable the processor-side port's message queue: pending messages posted since node construction- // are now delivered, after the constructor had its chance to register listeners.+ // NB: Defer incoming messages until the constructor can register listeners.MessagePort::enable(processor_port, vm);});}@@ -551,7 +577,7 @@ impl AudioWorkletNode {let Some(processor) = self.processor.get() else {return;};- if pipe.state() == WorkletPipeState::ShutDown || self.processor_errored.get() {+ if pipe.state() == WorkletPipeState::ShutDown || !processor.callable_process.get() {return;}@@ -561,13 +587,15 @@ impl AudioWorkletNode {// Keep one execution context for the batch so its microtask checkpoint runs after all available quanta.with_temporary_execution_context_and_callbacks(realm, || {+ // 4.4.4.2. Let O be the ECMAScript object corresponding to processor.+ let processor_object = wrap(&CallContext::new(vm, realm), processor);let config = &pipe.config;loop {if pipe.output_occupancy() == config.ring_capacity {break;}let mut processed_one = false;- let mut pump_failed = false;+ let mut pump_error = None;let mut output_full = false;let _ = unsafe {@@ -667,37 +695,42 @@ impl AudioWorkletNode {.expect("a new parameters object accepts a property");}- // Look up process on the instance each call (spec); a non-callable value fails the node.- let process_value = match processor.get(vm, &PropertyKey::from_utf8("process")) {+ // 4.4.4.7. Let getResult be Get(O, "process").+ let process_value = match processor_object.get(vm, &PropertyKey::from_utf8("process")) {Ok(value) if value.is_function() => value,Ok(_) => {- pump_failed = true;let error = vm.throw_completion_with_message::<()>(ErrorKind::TypeError,"AudioWorkletProcessor.process must be a function".to_string(),).unwrap_err();- self.fire_processor_error(error.value());+ pump_error = Some(error.value());return;}Err(error) => {- pump_failed = true;- self.fire_processor_error(error.value());+ pump_error = Some(error.value());return;}};+ // 4.4.4.11. Set [[callable process]] to true.+ processor.callable_process.set(true);+let process_arguments = [Value::from_object(inputs),Value::from_object(outputs),Value::from_object(parameters),];- let result = match call(vm, process_value, Value::from_object(processor), &process_arguments) {+ let result = match call(+ vm,+ process_value,+ Value::from_object(processor_object),+ &process_arguments,+ ) {Ok(result) => result,Err(error) => {- pump_failed = true;- self.fire_processor_error(error.value());+ pump_error = Some(error.value());return;}};@@ -749,9 +782,18 @@ impl AudioWorkletNode {})};- if pump_failed {- self.processor_errored.set(true);+ // 4.4.4.13.3. If completion is an abrupt completion:+ if let Some(error) = pump_error {+ // 4.4.4.13.3.1. Set [[callable process]] to false.+ processor.callable_process.set(false);++ // 4.4.4.13.3.2. Set processor’s active source flag to false.+ // 4.4.4.13.3.3. Make a silent output buffer available for reading.+ // NB: A failed pipe renders silence.pipe.set_state(WorkletPipeState::Failed);++ // 4.4.4.13.3.4. Queue a task to the control thread to fire an event named processorerror at the associated AudioWorkletNode using ErrorEvent.+ processor.node_reference.fire_processor_error(error);return;}if pipe.state() == WorkletPipeState::ShutDown {diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_audio/audio_worklet_processor.rs b/Libraries/LibWeb/Bindings/Rust/src/web_audio/audio_worklet_processor.rsindex b590491aad2..59f07a73ab6 100644--- a/Libraries/LibWeb/Bindings/Rust/src/web_audio/audio_worklet_processor.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/web_audio/audio_worklet_processor.rs@@ -4,11 +4,13 @@* SPDX-License-Identifier: BSD-2-Clause*/+use core::cell::Cell;use core::ffi::c_void;use core::ptr::NonNull;use libjs_rust::api::{Gc, Realm, Trace};+use super::audio_worklet_node::AudioWorkletNode;use crate::bindings::cpp_cell::CppCell;use crate::bindings::interface::{Ref, Wrappable, allocate, cell_from_abi};use crate::bindings::{CallContext, Exception, WebIdlResult};@@ -16,7 +18,9 @@ use crate::html::message_port::MessagePort;unsafe extern "C" {fn web_audio_processor_global_scope(realm: *mut c_void) -> *mut c_void;- fn web_audio_processor_take_pending_data(scope: *mut c_void, port: *mut *mut c_void) -> bool;+ fn web_audio_processor_pending_node_reference(scope: *mut c_void) -> *mut c_void;+ fn web_audio_processor_pending_transferred_port(scope: *mut c_void) -> *mut c_void;+ fn web_audio_worklet_clear_pending_data(scope: *mut c_void);fn web_audio_processor_scope_realm(scope: *mut c_void) -> *mut c_void;}@@ -25,6 +29,8 @@ unsafe extern "C" {#[gc(crate = libjs_rust)]pub(crate) struct AudioWorkletProcessor {global_scope: CppCell,+ pub(super) node_reference: Ref<AudioWorkletNode>,+ pub(super) callable_process: Cell<bool>,port: Ref<MessagePort>,}@@ -39,30 +45,43 @@ impl Wrappable for AudioWorkletProcessor {impl AudioWorkletProcessor {// https://webaudio.github.io/web-audio-api/#dom-audioworkletprocessor-audioworkletprocessor- // Runs when `super()` executes in a registered processor subclass during node instantiation.pub(crate) fn construct(cx: &mut CallContext) -> WebIdlResult<Ref<Self>> {- // 1. Let nodeName be the value of the current pending processor construction data's node name... (steps- // collapsed): When the constructor is invoked outside of AudioWorkletNode instantiation, there is no- // pending processor construction data, and a TypeError must be thrown.let global_scope = unsafe { web_audio_processor_global_scope(cx.realm().as_ptr().cast()) };if global_scope.is_null() {return Err(Exception::type_error("AudioWorkletProcessor can only be constructed in an AudioWorkletGlobalScope",));}- let mut port = core::ptr::null_mut();- if !unsafe { web_audio_processor_take_pending_data(global_scope, &raw mut port) } {+ // 1. Let nodeReference be the result of looking up node reference on the pending processor construction data of the current AudioWorkletGlobalScope. Throw a TypeError exception if the slot is empty.+ let node_reference = unsafe { web_audio_processor_pending_node_reference(global_scope) };+ if node_reference.is_null() {return Err(Exception::type_error("AudioWorkletProcessor cannot be constructed directly; it is instantiated by AudioWorkletNode",));}- let deserialized_port = unsafe { cell_from_abi::<MessagePort>(port) };+ let node_reference = unsafe { cell_from_abi::<AudioWorkletNode>(node_reference) };- // 2. Set this's port to the pending construction data's transferred port.+ // 2. Let processor be the this value.let processor = allocate(cx.vm(), |_| Self {global_scope: unsafe { CppCell::from_raw(global_scope) },- port: deserialized_port,++ // 3. Set processor’s [[node reference]] to nodeReference.+ node_reference,++ // 4. Set processor’s [[callable process]] to true.+ callable_process: Cell::new(true),++ // 5. Let deserializedPort be the result of looking up transferred port from the pending processor construction data.+ port: {+ let deserialized_port =+ unsafe { cell_from_abi::<MessagePort>(web_audio_processor_pending_transferred_port(global_scope)) };+ // 6. Set processor’s port to deserializedPort.+ deserialized_port+ },});++ // 7. Empty the pending processor construction data slot.+ unsafe { web_audio_worklet_clear_pending_data(global_scope) };Ok(processor)}diff --git a/Libraries/LibWeb/WebAudio/AudioWorkletGlobalScope.cpp b/Libraries/LibWeb/WebAudio/AudioWorkletGlobalScope.cppindex 816918d1853..b9fe328515c 100644--- a/Libraries/LibWeb/WebAudio/AudioWorkletGlobalScope.cpp+++ b/Libraries/LibWeb/WebAudio/AudioWorkletGlobalScope.cpp@@ -14,6 +14,7 @@#include <LibWeb/HTML/MessagePort.h>#include <LibWeb/WebAudio/AudioWorklet.h>#include <LibWeb/WebAudio/AudioWorkletGlobalScope.h>+#include <LibWeb/WebAudio/AudioWorkletNode.h>#include <LibWeb/WebIDL/AbstractOperations.h>#include <LibWeb/WebIDL/CallbackType.h>#include <LibWeb/WebIDL/DOMException.h>@@ -151,13 +152,6 @@ AudioWorkletGlobalScope::ProcessorDefinition const* AudioWorkletGlobalScope::finreturn &it->value;}-Optional<AudioWorkletGlobalScope::PendingProcessorConstructionData> AudioWorkletGlobalScope::take_pending_processor_construction_data()-{- if (!m_pending_processor_construction_data.has_value())- return {};- return m_pending_processor_construction_data.release_value();-}-void AudioWorkletGlobalScope::set_pending_processor_construction_data(PendingProcessorConstructionData data){m_pending_processor_construction_data = move(data);@@ -170,8 +164,10 @@ void AudioWorkletGlobalScope::visit_edges(Cell::Visitor& visitor)visitor.visit(m_port);for (auto& definition : m_processor_definitions)visitor.visit(definition.value.constructor);- if (m_pending_processor_construction_data.has_value())- visitor.visit(m_pending_processor_construction_data->port);+ if (m_pending_processor_construction_data.has_value()) {+ visitor.visit(m_pending_processor_construction_data->node_reference);+ visitor.visit(m_pending_processor_construction_data->transferred_port);+ }}}diff --git a/Libraries/LibWeb/WebAudio/AudioWorkletGlobalScope.h b/Libraries/LibWeb/WebAudio/AudioWorkletGlobalScope.hindex 1c0b2a28237..64e6c8eae32 100644--- a/Libraries/LibWeb/WebAudio/AudioWorkletGlobalScope.h+++ b/Libraries/LibWeb/WebAudio/AudioWorkletGlobalScope.h@@ -44,13 +44,13 @@ public:ProcessorDefinition const* find_definition(Utf16String const& name) const;// https://webaudio.github.io/web-audio-api/#pending-processor-construction-data- // Set by AudioWorkletNode instantiation immediately before invoking the processor constructor;- // consumed by AudioWorkletProcessor's constructor.struct PendingProcessorConstructionData {- GC::Ref<HTML::MessagePort> port;+ GC::Ref<AudioWorkletNode> node_reference;+ GC::Ref<HTML::MessagePort> transferred_port;};- Optional<PendingProcessorConstructionData> take_pending_processor_construction_data();+ Optional<PendingProcessorConstructionData> const& pending_processor_construction_data() const { return m_pending_processor_construction_data; }void set_pending_processor_construction_data(PendingProcessorConstructionData);+ void clear_pending_processor_construction_data() { m_pending_processor_construction_data.clear(); }// Advanced by the render pump as it processes quanta; read by the currentFrame/currentTime getters.void set_current_frame_and_time(u64 current_frame, double current_time)diff --git a/Libraries/LibWeb/WebAudio/AudioWorkletNode.cpp b/Libraries/LibWeb/WebAudio/AudioWorkletNode.cppindex 2dc563845a8..3bf39d0f6eb 100644--- a/Libraries/LibWeb/WebAudio/AudioWorkletNode.cpp+++ b/Libraries/LibWeb/WebAudio/AudioWorkletNode.cpp@@ -29,7 +29,7 @@ extern "C" AudioWorkletGlobalScope* web_audio_worklet_global_scope(AudioWorklet*extern "C" JS::Realm* web_audio_worklet_scope_realm(AudioWorkletGlobalScope*);extern "C" JSCompletion web_audio_worklet_clone_options(JSVM*, JS::Realm*, JS::Realm*, JS::Object*);extern "C" JS::FunctionObject* web_audio_worklet_processor_constructor(AudioWorkletGlobalScope*, FlatPtr);-extern "C" void web_audio_worklet_set_pending_port(AudioWorkletGlobalScope*, HTML::MessagePort*);+extern "C" void web_audio_worklet_set_pending_data(AudioWorkletGlobalScope*, AudioWorkletNode*, HTML::MessagePort*);extern "C" void web_audio_worklet_clear_pending_data(AudioWorkletGlobalScope*);extern "C" void web_audio_worklet_set_current_frame(AudioWorkletGlobalScope*, u64);extern "C" void web_audio_worklet_queue_processor_error(AudioWorkletNode*, DOM::EventTarget*, DOM::EventTarget*, JSValue);@@ -63,8 +63,11 @@ JS::FunctionObject* web_audio_worklet_processor_constructor(AudioWorkletGlobalScVERIFY(definition);return definition->constructor.ptr();}-void web_audio_worklet_set_pending_port(AudioWorkletGlobalScope* scope, HTML::MessagePort* port) { scope->set_pending_processor_construction_data({ *port }); }-void web_audio_worklet_clear_pending_data(AudioWorkletGlobalScope* scope) { (void)scope->take_pending_processor_construction_data(); }+void web_audio_worklet_set_pending_data(AudioWorkletGlobalScope* scope, AudioWorkletNode* node_reference, HTML::MessagePort* transferred_port)+{+ scope->set_pending_processor_construction_data({ *node_reference, *transferred_port });+}+void web_audio_worklet_clear_pending_data(AudioWorkletGlobalScope* scope) { scope->clear_pending_processor_construction_data(); }void web_audio_worklet_set_current_frame(AudioWorkletGlobalScope* scope, u64 current_frame) { scope->set_current_frame_and_time(current_frame, static_cast<double>(current_frame) / scope->sample_rate()); }void web_audio_worklet_queue_processor_error(AudioWorkletNode* node, DOM::EventTarget* target, DOM::EventTarget* global, JSValue error){diff --git a/Libraries/LibWeb/WebAudio/AudioWorkletProcessor.cpp b/Libraries/LibWeb/WebAudio/AudioWorkletProcessor.cppindex 4bc81f48aa5..6b5cd06d43f 100644--- a/Libraries/LibWeb/WebAudio/AudioWorkletProcessor.cpp+++ b/Libraries/LibWeb/WebAudio/AudioWorkletProcessor.cpp@@ -7,12 +7,14 @@#include <LibJS/Runtime/Realm.h>#include <LibWeb/HTML/MessagePort.h>#include <LibWeb/WebAudio/AudioWorkletGlobalScope.h>+#include <LibWeb/WebAudio/AudioWorkletNode.h>namespace Web::WebAudio {extern "C" {AudioWorkletGlobalScope* web_audio_processor_global_scope(JS::Realm*);-bool web_audio_processor_take_pending_data(AudioWorkletGlobalScope*, HTML::MessagePort**);+AudioWorkletNode* web_audio_processor_pending_node_reference(AudioWorkletGlobalScope*);+HTML::MessagePort* web_audio_processor_pending_transferred_port(AudioWorkletGlobalScope*);JS::Realm* web_audio_processor_scope_realm(AudioWorkletGlobalScope*);}@@ -21,13 +23,15 @@ AudioWorkletGlobalScope* web_audio_processor_global_scope(JS::Realm* realm)return Bindings::impl_from<AudioWorkletGlobalScope>(&realm->global_object());}-bool web_audio_processor_take_pending_data(AudioWorkletGlobalScope* scope, HTML::MessagePort** port)+AudioWorkletNode* web_audio_processor_pending_node_reference(AudioWorkletGlobalScope* scope){- auto pending_data = scope->take_pending_processor_construction_data();- if (!pending_data.has_value())- return false;- *port = pending_data->port.ptr();- return true;+ auto const& pending_data = scope->pending_processor_construction_data();+ return pending_data.has_value() ? pending_data->node_reference.ptr() : nullptr;+}++HTML::MessagePort* web_audio_processor_pending_transferred_port(AudioWorkletGlobalScope* scope)+{+ return scope->pending_processor_construction_data()->transferred_port.ptr();}JS::Realm* web_audio_processor_scope_realm(AudioWorkletGlobalScope* scope)diff --git a/Tests/LibWeb/Text/expected/WebAudio/AudioWorklet-rate-and-errors.txt b/Tests/LibWeb/Text/expected/WebAudio/AudioWorklet-rate-and-errors.txtindex 16c23321cbd..c9b04ae2c3f 100644--- a/Tests/LibWeb/Text/expected/WebAudio/AudioWorklet-rate-and-errors.txt+++ b/Tests/LibWeb/Text/expected/WebAudio/AudioWorklet-rate-and-errors.txt@@ -1,4 +1,5 @@unknown processor: InvalidStateErrorconstructor error reportedprocessor sample rate: 44100+second construction: TypeErrorprocess error reporteddiff --git a/Tests/LibWeb/Text/input/WebAudio/AudioWorklet-rate-and-errors.html b/Tests/LibWeb/Text/input/WebAudio/AudioWorklet-rate-and-errors.htmlindex eb31c130817..016fe72cb77 100644--- a/Tests/LibWeb/Text/input/WebAudio/AudioWorklet-rate-and-errors.html+++ b/Tests/LibWeb/Text/input/WebAudio/AudioWorklet-rate-and-errors.html@@ -5,7 +5,13 @@ asyncTest(async done => {const context = new AudioContext({ sampleRate: 44100 });const url = URL.createObjectURL(new Blob([`class RateProcessor extends AudioWorkletProcessor {- constructor() { super(); this.port.postMessage(sampleRate); }+ constructor() {+ super();+ let secondConstruction;+ try { new AudioWorkletProcessor(); }+ catch (error) { secondConstruction = error.name; }+ this.port.postMessage({ sampleRate, secondConstruction });+ }process() { throw new Error("processor failure"); }}registerProcessor("rate", RateProcessor);@@ -24,8 +30,9 @@ asyncTest(async done => {const node = new AudioWorkletNode(context, "rate");// A running context may process the node before it is connected, so listen before anything else happens.const failure = new Promise(resolve => node.onprocessorerror = resolve);- const rate = await new Promise(resolve => node.port.onmessage = event => resolve(event.data));- println(`processor sample rate: ${rate}`);+ const report = await new Promise(resolve => node.port.onmessage = event => resolve(event.data));+ println(`processor sample rate: ${report.sampleRate}`);+ println(`second construction: ${report.secondConstruction}`);node.connect(context.destination);await context.resume();await failure;