Skip to content

Failed to execute 'appendBuffer' on 'SourceBuffer': This SourceBuffer is still processing an 'appendBuffer' or 'remove' operation. #14

@ItzDerock

Description

@ItzDerock

I'm using SFMediaStream for a proximity chat mod for Among Us. I ran into an issue when trying to use it. The issues is:

sfmediastream@latest:8 Uncaught DOMException: Failed to execute 'appendBuffer' on 'SourceBuffer': This SourceBuffer is still processing an 'appendBuffer' or 'remove' operation.
    at l.a.append (https://cdn.jsdelivr.net/npm/sfmediastream@latest:8:4518)
    at d.t.receiveBuffer (https://cdn.jsdelivr.net/npm/sfmediastream@latest:8:3385)
    at f.<anonymous> (https://amongus.derock.dev/play.html?u=UEQXAJ&p=Derock:263:39)
    at f.r.emit (https://cdn.socket.io/socket.io-3.0.1.min.js:6:2341)
    at f.value (https://cdn.socket.io/socket.io-3.0.1.min.js:6:30320)
    at f.value (https://cdn.socket.io/socket.io-3.0.1.min.js:6:30041)
    at f.value (https://cdn.socket.io/socket.io-3.0.1.min.js:6:29648)
    at b.<anonymous> (https://cdn.socket.io/socket.io-3.0.1.min.js:6:33736)
    at b.r.emit (https://cdn.socket.io/socket.io-3.0.1.min.js:6:2341)
    at b.value (https://cdn.socket.io/socket.io-3.0.1.min.js:6:17782)

Here's the code I use for the client:

        socket.on('newBufferHeader', (data) => {
            if(!otherStreams[data.id])
                otherStreams[data.id] = new ScarletsAudioStreamer(200);
            otherStreams[data.id].playStream();
            otherStreams[data.id].setBufferHeader(data.data);
            console.log('[WS] Got headers for ' + data.id)
            // otherStreams[data.id].audioConnect(ScarletsMedia.audioContext.destination);

            if(nextUp) //handleNextBuffer(nextUp, otherStreams[data.id], data.id)
                otherStreams[data.id].receiveBuffer(nextUp);
        })
    
        socket.on('data', (data) => {
            console.log('[AUDIO] Got audio for ' + data.id)
            if(otherStreams[data.id])
                //handleNextBuffer(data.data, otherStreams[data.id], data.id)
                otherStreams[data.id].receiveBuffer(data.data);
            else {
                console.error('[AUDIO] Missing headers for ' + data.id)
                console.log('[WS] Asked for headers')
                socket.emit('requestBuffer', {need: data.id});
                nextUp = data.data;
            }
        })

The client acts like a presenter and a streamer, both delays are synced up (200ms).
For streamer I use the following:

        const presenter = new ScarletsMediaPresenter({
            audio: {
                channelCount: 1,
                echoCancellation: false
            }
        }, 200);

        presenter.onRecordingReady = (packet) => {
            console.log('[AUDIO] Ready to stream audio');
            headers = packet;
            socket.emit('bufferHeader', packet);
            console.log("[WS] Sent headers");
        }
        presenter.onBufferProcess = (packet) => {
            socket.emit('data', packet);
            console.log('[SEND] Audio Sent')
        }

Sometimes it'll work for a few seconds, other times it errors after receiving one chunk.

Any help would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions