Skip to content

[Bug] - Hang on loading screen when WebCodecs hardware decode never completes (1.19.0) #923

Open

Description

@davehope

Existing Resources

  • Please search the existing issues for related problems
  • Consult the product documentation : Docs
  • Consult the FAQ : FAQ
  • Consult the Troubleshooting Guide : Guide
  • Reviewed existing training videos: Youtube

Describe the bug
Since 1.19.0 (kasmweb/brave:1.19.0; 1.18.0 worked), the web client gets stuck on the loading screen in Microsoft Edge 156.0.4314.50 on Windows 11 26H2. The console shows no errors and no /websockify request is ever made. Firefox on the same machine works.

It looks like on first load the client probes codecs in _tryDecode(), decoding a test frame with VideoDecoder and hardwareAcceleration "prefer-hardware". It waits for either an output frame or an error, with no timeout. On this machine the hardware decoder returns neither, so the promise never resolves and the connection never starts.

I can pre-populate local storage, and then things work:

localStorage.setItem('kasm_video_codecs_v1', JSON.stringify({capabilities:{AVC:false,HEVC:false,AV1:false},hwAcceleration:{}}))

To Reproduce
Described above

Expected behavior
Behavior as-per 1.18.0

Screenshots
N/A

Workspaces Version
1.19.0

Workspaces Installation Method
Docker container, kasmweb/brave:1.19.0

Client Browser (please complete the following information):

  • OS: Windows 11 26H2
  • Browser Edge
  • Version 156.0.4314.50

Workspace Server Information (please provide the output of the following commands):

  • uname -a
    Linux SRVDCK01 6.12.113+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.113-1 (2026-10-15) x86_64 GNU/Linux
  • cat /etc/os-release
    PRETTY_NAME="Debian GNU/Linux 13 (trixie)"
    NAME="Debian GNU/Linux"
    VERSION_ID="13"
    VERSION="13 (trixie)"
    VERSION_CODENAME=trixie
    DEBIAN_VERSION_FULL=13.7
    ID=debian
    HOME_URL="https://www.debian.org/"
    SUPPORT_URL="https://www.debian.org/support"
    BUG_REPORT_URL="https://bugs.debian.org/"
    
  • sudo docker info
     Client: Docker Engine - Community
     Version:    29.9.2
     Context:    default
     Debug Mode: false
     Plugins:
       buildx: Docker Buildx (Docker Inc.)
         Version:  v0.38.1
         Path:     /usr/libexec/docker/cli-plugins/docker-buildx
       compose: Docker Compose (Docker Inc.)
         Version:  v5.6.1
         Path:     /usr/libexec/docker/cli-plugins/docker-compose
    
     Server:
     Containers: 13
       Running: 12
       Paused: 0
       Stopped: 1
     Images: 14
     Server Version: 29.9.2
     Storage Driver: overlay2
       Backing Filesystem: extfs
       Supports d_type: true
       Using metacopy: false
       Native Overlay Diff: true
       userxattr: false
     Logging Driver: journald
     Cgroup Driver: systemd
     Cgroup Version: 2
     Plugins:
       Volume: local
       Network: bridge host ipvlan macvlan null overlay
       Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
     CDI spec directories:
       /etc/cdi
       /var/run/cdi
     Swarm: inactive
     Runtimes: runc io.containerd.runc.v2
     Default Runtime: runc
     Init Binary: docker-init
     containerd version: b7a25261e029d68978bbf290df0a62fc819b3c51
     runc version: v1.5.2-0-g29dd3dc2
     init version: de40ad0
     Security Options:
       apparmor
       Profile: default
       seccomp
       Profile: builtin
       cgroupns
       no-new-privileges
     Kernel Version: 6.12.113+deb13-amd64
     Operating System: Debian GNU/Linux 13 (trixie)
     OSType: linux
     Architecture: x86_64
     CPUs: 4
     Total Memory: 7.654GiB
     Name: SRVDCK01
     ID: BTWS:I75F:3CK3:M6EV:4MFD:QDHR:AU7L:HOOJ:UOTR:D7K2:LPLT:HAKO
     Docker Root Dir: /var/lib/docker
     Debug Mode: false
     Experimental: false
     Insecure Registries:
       127.0.0.0/8
       ::1/128
     Live Restore Enabled: true
     Firewall Backend: iptables
    
  • sudo docker ps | grep kasm
    3ec6a2beea85   kasmweb/brave:1.19.0                                    "/dockerstartup/kasm…"   20 hours ago   Up 18 hours (healthy)     4901/tcp, 5901/tcp, 6901/tcp
          browser
    

Additional context

  # sslOnly=0 is used since traefik is in front of kasmweb
- VNCOPTIONS=-PreferBandwidth -DynamicQualityMin=4 -DynamicQualityMax=7 -DLP_ClipDelay=0 -sslOnly=0
- APP_ARGS=--start-maximized --disable-gpu
- LAUNCH_URL=about:blank
- KASM_SVC_AUDIO=0
- KASM_SVC_AUDIO_INPUT=0
- KASM_SVC_GAMEPAD=0
- KASM_SVC_PRINTER=0
- KASM_SVC_SMARTCARD=0
- KASM_SVC_UPLOADS=0
- KASM_SVC_WEBCAM=0

Activity

  1. added
    bug
    on Oct 29, 2026
  2. Dylan-Bs commented on Nov 30, 2026

    @Dylan-Bs

    Same problem here, reproduced on a second machine with a different Windows build, so it is not specific to one setup. I traced it to the same place and have a proposed fix below.

    Environment

    • Client: Microsoft Edge 156.0.4314.98, Windows 11 23H2 (build 22631), NVIDIA GPU. edge://gpu reports Video Decode: Hardware accelerated.
    • Server: Workspaces 1.19.0 workspace images (KasmVNC 1.5.x web client), behind a reverse proxy.
    • The same deployment works from other machines, including a VM running the same Edge version.

    What I observed

    • The session is created, and vnc.html, assets/ui-*.js and app/locale/fr.json are all served with a 200. After that, the client sends no further request: no package.json and no /websockify. There is nothing in the console or in DevTools > Issues, even with &logging=debug.
    • In the reverse-proxy logs, a working session requests package.json about one second after the locale file, then opens /websockify. The client therefore stops somewhere between the l10n step and UI.start().
    • Pre-populating the cache, as in the workaround above, fixes it at once:
      localStorage.setItem('kasm_video_codecs_v1', JSON.stringify({capabilities:{AVC:false,HEVC:false,AV1:false},hwAcceleration:{}}))

    Root cause (core/codecs.js on master)

    1. UI.prime() awaits new CodecDetector().detect() before calling UI.start(). The surrounding try/catch only handles a rejection. A promise that never settles blocks UI.start() forever, so UI.connect() is never called.
    2. _tryDecode() only resolves from the decoder's output or error callback, or from a rejected flush(). There is no timeout, so nothing settles the promise in two cases:
      • the hardware decoder never calls either callback (this machine);
      • flush() resolves without any output. The WebCodecs spec emits every output before flush() resolves, so this case means the frame was not decoded.
    3. The result is only written to localStorage once detect() completes. An affected browser therefore hangs again on every load. The manual cache entry works because detect() returns early on a cache hit.
    4. A related bug on the same path: the fallback _tryDetect(codec) passes the codec string to VideoDecoder.isConfigSupported(), which expects a VideoDecoderConfig dictionary ({codec}), so it rejects with a TypeError. That rejection escapes the catch in the loop, detect() rejects, and nothing is cached.

    Proposed fix

    The patch below bounds each test decode to 2 s, treats a flush() that resolves without output as "not supported", and always closes the decoder. It also passes {codec} to isConfigSupported() and catches its errors. On an affected machine, the hardware probe now times out, the existing software retry runs, and the result is cached (prefer-software when software decoding works). The worst case is about 6 s on the first load only, if the hardware probe hangs for all three codecs.

    I tested it against a mocked VideoDecoder covering the hang, flush-without-output, error, configure-throws and success cases:

    • On master, _tryDecode() stays pending in the first two cases, and _tryDetect() rejects with a TypeError.
    • With the patch, every case settles within 2 s and detect() writes the cache.

    I have not been able to test it in a real browser on the affected machine yet.

    --- a/core/codecs.js
    +++ b/core/codecs.js
    @@ -67,6 +67,12 @@
     
     const CACHE_CODECS_KEY = 'kasm_video_codecs_v1';
     
    +// Upper bound for a single test decode. Some hardware decoders never call
    +// output() nor error() (seen with Edge 156 on Windows 11 with NVIDIA GPUs):
    +// without a bound, detect() never settles and UI.prime() never reaches
    +// UI.start(), so the session stays on the loading screen.
    +const CODEC_TEST_TIMEOUT_MS = 2000;
    +
     const CODEC_TEST_FRAMES = {
         AVC: {url: avcUrl, codec: CODECS[CODEC_NAMES.AVC], w: 128, h: 128},
         HEVC: {url: hevcUrl, codec: CODECS[CODEC_NAMES.HEVC], w: 128, h: 128},
    @@ -158,39 +164,60 @@
             return this;
         }
     
    -    async _tryDetect(config) {
    -        let support = await VideoDecoder.isConfigSupported(config);
    -        return support.supported;
    +    async _tryDetect(codec) {
    +        try {
    +            // isConfigSupported() takes a VideoDecoderConfig, not a codec string
    +            const support = await VideoDecoder.isConfigSupported({codec});
    +            return support.supported;
    +        } catch (e) {
    +            Log.Warn(`isConfigSupported failed for ${codec}:`, e);
    +            return false;
    +        }
         }
     
         async _tryDecode(data, config, name) {
             return new Promise((resolve) => {
    -            const decoder = new VideoDecoder({
    -                output: frame => {
    -                    frame.close();
    -                    if (decoder.state !== 'closed')
    -                        decoder.close();
    -                    resolve(true);
    -                },
    -                error: e => {
    -                    if (decoder.state !== 'closed')
    +            let settled = false;
    +            let decoder = null;
    +            let timer = null;
    +
    +            const finish = (supported, reason) => {
    +                if (settled)
    +                    return;
    +                settled = true;
    +                clearTimeout(timer);
    +                if (reason !== undefined)
    +                    Log.Warn(`Error decoding ${name} using ${config.hardwareAcceleration}:`, reason);
    +                try {
    +                    if (decoder && decoder.state !== 'closed')
                             decoder.close();
    -                    Log.Warn(`Error decoding ${name} using ${config.hardwareAcceleration}:`, e);
    -                    resolve(false);
    -                },
    -            });
    +                } catch (e) {
    +                    // A wedged decoder must not keep the UI from starting
    +                }
    +                resolve(supported);
    +            };
    +
    +            timer = setTimeout(
    +                () => finish(false, `no output after ${CODEC_TEST_TIMEOUT_MS} ms`),
    +                CODEC_TEST_TIMEOUT_MS);
    +
                 try {
    +                decoder = new VideoDecoder({
    +                    output: (frame) => {
    +                        frame.close();
    +                        finish(true);
    +                    },
    +                    error: e => finish(false, e),
    +                });
                     decoder.configure(config);
                     decoder.decode(new EncodedVideoChunk({type: 'key', timestamp: 0, data: data}));
    -                decoder.flush().catch(e => {
    -                    resolve(false);
    -                });
    -
    +                // All outputs are emitted before flush() resolves, so a flush
    +                // that resolves without any output means the frame was not decoded.
    +                decoder.flush()
    +                    .then(() => finish(false, 'flush completed without output'))
    +                    .catch(e => finish(false, e));
                 } catch (e) {
    -                Log.Warn(`Error decoding ${name} using ${config.hardwareAcceleration}:`, e);
    -                if (decoder.state !== 'closed')
    -                    decoder.close();
    -                resolve(false);
    +                finish(false, e);
                 }
             });
         }

    As an additional safeguard, UI.prime() could race detect() against a timeout, so that a codec probe can never keep the client from connecting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions