Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Support for WASM with +mutable-globals,+atomics target features

Đang mở
#656 3 bình luận 3 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
rust, wasm
Lĩnh vực
audio-video-rtc, backend

Hướng nghiên cứu

The report points to host/webaudio/mod.rs and shows a JavaScript shim in audio-shim.js that copies samples into owned memory before calling AudioBuffer.copyToChannel. Start by reading the WebAudio output stream code and its existing tests. Done means audio playback works in WASM builds with +atomics and +mutable-globals in Firefox and Chrome; the issue reports no test file or recent maintainer response.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

platform - web

I realise this is quite an obscure use-case, but currently if you try to play audio on WASM with the +atomics and +mutable-globals features enabled in Rust Nightly, Firefox and Chrome error out since AudioBuffer.copyToChannel doesn't support SharedArrayBuffers.

Error on Firefox:

panicked at 'Unable to write sample data into the audio context buffer: JsValue(TypeError: AudioBuffer.copyToChannel: Argument 1 can't be a SharedArrayBuffer or an ArrayBufferView backed by a SharedArrayBuffer

Error on Chrome:

web.js:446 panicked at 'Unable to write sample data into the audio context buffer: JsValue(TypeError: Failed to execute 'copyToChannel' on 'AudioBuffer': The provided Float32Array value must not be shared.
TypeError: Failed to execute 'copyToChannel' on 'AudioBuffer': The provided Float32Array value must not be shared.
init/imports.wbg.__wbg_copyToChannel_74f68c0678489450/<@http://localhost/web.js:1244:25
handleError@http://localhost/web.js:310:18
init/imports.wbg.__wbg_copyToChannel_74f68c0678489450@http://localhost/web.js:1243:76
web_sys::features::gen_AudioBuffer::AudioBuffer::copy_to_channel::ha856702a3af061e5@http://localhost/web_bg.wasm:wasm-function[6669]:0x71ba4f
<cpal::host::webaudio::Device as cpal::traits::DeviceTrait>::build_output_stream_raw::{{closure}}::ha128e8e549ebdafb@http://localhost/web_bg.wasm:wasm-function[669]:0x2bcd81

EDIT:

I have managed to get it working by modifying host\webaudio\mod.rs by adding an external javascript call

webaudio\mod.rs:

#[wasm_bindgen(module = "/audio-shim.js")]
extern "C" {
    fn copy_audio_buffer(dest: &AudioBuffer, src: &[f32], channel: i32);
}
// New, working version
copy_audio_buffer(&ctx_buffer, &temporary_channel_buffer, channel as i32);

// Previous, broken version
// ctx_buffer
//     .copy_to_channel(&mut temporary_channel_buffer, channel as i32)
//     .expect("Unable to write sample data into the audio context buffer");

audio-shim.js:

export function copy_audio_buffer(dest, src, channel) {
    // Turn the array view into owned memory.
    var standalone = [...src];
    // Make it a Float32Array.
    var buffer = new Float32Array(standalone);

    // Copy the data.
    dest.copyToChannel(buffer, channel);
}

( Many thanks to this webpage for that trick )

Ngôn ngữ chính
Rust
Star
4k
Fork
554
Merge trung bình
3 ngày 3 giờ
Pull request đã merge (30 ngày)
4

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của RustAudio/cpal

Tất cả issue của RustAudio/cpal

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.