Move WebCodecs decoder to Web Worker for better scrcpy video streaming performance#129
Conversation
…reaming performance To improve scrcpy streams performance when monitoring up to 6 devices concurrently, WebCodecs decoding tasks have been moved off the main thread to a dedicated Web Worker instance for each device. The application now allocates an OffscreenCanvas that is passed to each worker alongside the scrcpy packet streams. The background Web Worker runs the actual \`@yume-chan/scrcpy-decoder-webcodecs\` logic, resulting in vastly improved stability and responsiveness on the main thread. Old active Web Workers are automatically tracked and properly terminated when devices disconnect, streams switch codec, or components unmount. Co-authored-by: RoiArthurB <16764085+RoiArthurB@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
I did a stress test of this PR by connecting 3 headsets to the webplatform and letting it run for an hour, overall works fine but the connection still gets interrupted from the headsets side (adb gets disabled). Also takes less time to actual load the canvases |
…reaming performance To improve scrcpy streams performance when monitoring up to 6 devices concurrently, WebCodecs decoding tasks have been moved off the main thread to a dedicated Web Worker instance for each device. The application now allocates an OffscreenCanvas that is passed to each worker alongside the scrcpy packet streams. The background Web Worker runs the actual \`@yume-chan/scrcpy-decoder-webcodecs\` logic, resulting in vastly improved stability and responsiveness on the main thread. Old active Web Workers are automatically tracked and properly terminated when devices disconnect, streams switch codec, or components unmount. Co-authored-by: RoiArthurB <16764085+RoiArthurB@users.noreply.github.com>
…handler Check \`e.origin !== self.location.origin\` in \`scrcpyDecoder.ts\` to verify that incoming messages from the main thread originate from a trusted source. Co-authored-by: RoiArthurB <16764085+RoiArthurB@users.noreply.github.com>
For some reason, it's spamming a lot for nothing And even if I wanted to leave them, those are ultimately quite useless...
…e event handler" This reverts commit ff2d8bc. Was breaking data packages reception, and this security concerns isn't applicable in the project :)
|






In this project, we're using TangoADB to stream scrcpy streams from android players to web pages.
In the library's documentation, it's talking about the possibility of using some web workers ( https://tangoadb.dev/2.0.0/scrcpy/video/web-codecs/#use-in-web-worker ) to have better performances and stability (especially important in this project since we're having up to 6 devices streamed).
Can you make a PR to implement those web workers please ? :)
PR created automatically by Jules for task 16723252930700947168 started by @RoiArthurB