Skip to content

Audio Context gets closed and cannot be resumed #1655

@indexds

Description

@indexds

Describe the bug

Hello,

I consistently get an issue that only occurs when using a headset. Everything will work perfectly for a few minutes after a call was started, until a certain point where the AudioContext gets closed by the browser(?) at which point I am screwed because it cannot be resumed. I assume livekit is trying to do that automatically because we get the following error in the logs:

Error trying to auto-resume audio context DOMException: Can't resume if the control thread state is "closed".

I tried setting webAudioMix to both true and false and the error remained.

My application is running on Firefox 142.0.1 and was also tested on Chromium with the same results.

Any insight is appreciated as this makes the application completely unusable.

Related issues: #1116 #1445

Reproduction

  • Plug in a headset
  • Wait for many(?) minutes
  • Alt-tab out of the application(?)
  • Eventually the AudioContext will be force closed by the browser at which point the only way to fix it is to close and reopen the browser.

Logs

Error trying to auto-resume audio context DOMException: Can't resume if the control thread state is "closed"
    handleResume http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:10333
    __awaiter http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5765
    __awaiter http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5747
    handleResume http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:10329
    getNewAudioContext http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:10340
    detectSilence http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:10300
    __awaiter http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5765
    __awaiter http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5747
    detectSilence http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:10297
    checkForSilence http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:14375
    __awaiter http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5765
    __awaiter http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5747
    checkForSilence http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:14374
    onLocalTrackPublished http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:21332
    __awaiter http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5765
    __awaiter http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5747
    onLocalTrackPublished http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:21325
    emit http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5897
    publish http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:19538
    fulfilled http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5750
    promise callback*step http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5763
    __awaiter http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5765
    __awaiter http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5747
    publish http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:19308
    publishPromise http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:19260
    fulfilled http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5750
    promise callback*step http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5763
    __awaiter http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5765
    __awaiter http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5747
    publishPromise http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:19249
    publishOrRepublishTrack http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:19249
    fulfilled http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5750
    promise callback*step http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5763
    __awaiter http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5765
    __awaiter http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5747
    publishOrRepublishTrack http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:19158
    publishTrack http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:19154
    __awaiter http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5765
    __awaiter http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5747
    publishTrack http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:19153
    setTrackEnabled http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:19002
    fulfilled http://localhost:3000/node_modules/.vite/deps/chunk-673D7ERD.js?v=3e4507ff:5750
<anonymous code>:1:145535

System Info

System:
    OS: Linux 6.16 Fedora Linux 41 (Container Image)
    CPU: (20) x64 Intel(R) Core(TM) Ultra 9 185H
    Memory: 40.08 GB / 62.24 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 22.19.0 - /usr/bin/node
    npm: 10.9.3 - /usr/bin/npm
    pnpm: 10.9.0 - /usr/bin/pnpm
    bun: 1.2.15 - /usr/bin/bun
  npmPackages:
    livekit-client: 2.15.7 => 2.15.7

Severity

blocking all usage of LiveKit

Additional Information

No response

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