yume-chan / ya-webadb

ADB in your browser
https://tangoapp.dev/
MIT License
2.15k stars 291 forks source link

Console Error: "Decoder not configured" #645

Open wushanchao opened 1 week ago

wushanchao commented 1 week ago

Issue Checklist

Library version

0.0.21

Environment

win10,ios,android,chrome106

Device

pc, iPhone 17 ,Android 13

Describe the bug

When I disconnect, that is, when I execute the code 'STATE.stop();', the console occasionally throws an error saying 'Decoder not configured'.

Steps to reproduce

other tips

  1. spawn options max_size=1280 max_fps=120 send_device_meta=false send_dummy_byte=false scid=43cac6b2 video_codec_options=profile=1,level=2048 video_encoder=OMX.google.h264.encoder audio=false audio_codec=aac
yume-chan commented 1 week ago

Error: "Decoder not configured" means a data packet has arrived before configuration packets.

https://github.com/yume-chan/ya-webadb/blob/7056feb3b1d709362fdad2908099d822fd85591a/libraries/scrcpy-decoder-tinyh264/src/decoder.ts#L83-L86

But I believe in this situation, it's a data packet arrived after dispose is called.

https://github.com/yume-chan/ya-webadb/blob/7056feb3b1d709362fdad2908099d822fd85591a/libraries/scrcpy-decoder-tinyh264/src/decoder.ts#L154-L160


It's safe to ignore the error, or stop the piping before disposing the decoder:

const abortController = new AbortController();
const decoder = new TinyH264Decoder();
videoStream
    // .pipeThrough inspect stream to get video size
    .pipeTo(decoder.writable, {
        signal: abortController.signal,
    })
    .catch((e) => {
        if (abortController.signal.aborted) {
            return;
        }
        console.error(e);
    });

// when stopping
abortController.abort();
decoder.dispose();