Skip to content

fix: e2ee setup hardening and tests - #2044

Open
lukasIO wants to merge 15 commits into
mainfrom
lukas/e2ee-follow-ups
Open

fix: e2ee setup hardening and tests#2044
lukasIO wants to merge 15 commits into
mainfrom
lukas/e2ee-follow-ups

Conversation

@lukasIO

@lukasIO lukasIO commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Follow up to #2043

Fixes E2EE subscribers rendering a permanently black tile with nothing logged.

Three independent defects, each of which could leave a subscribed, encrypted track with no live decrypt transform:

  • Transceiver reuse — a reused receiver keeps its already-transferred encoded streams (they can't be transferred twice, and createEncodedStreams() is once-per-receiver), so the new trackId used to spawn a fresh cryptor with no pipeline while the old one kept piping with no participant. Reuse now carries previousTrackId and re-points the existing cryptor, rebuilding its pipe if it died.
  • Decode failed open — with unknown encryption state the cryptor handed raw ciphertext to the decoder. It now drops instead, and reports it when the track is genuinely live (routine teardown stays quiet).
  • Silent failure — a watchdog reports an encrypted track left without a decrypt transform, so this class of bug is no longer invisible.

Also removes the now-dead isReuse flag and hardens pipeThrough against synchronous throws.

@changeset-bot

changeset-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 59e774e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
livekit-client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
dist/livekit-client.esm.mjs 109.38 KB (0%)
dist/livekit-client.umd.js 118.55 KB (+0.15% 🔺)

Base automatically changed from lukas/e2ee-setup-fix to main August 13, 2026 13:40
@lukasIO
lukasIO force-pushed the lukas/e2ee-follow-ups branch from 0469935 to aec3fdc Compare August 13, 2026 13:40
@lukasIO
lukasIO marked this pull request as ready for review August 21, 2026 09:41

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@1egoman 1egoman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally I can follow what's going on, but I've yet to dig really deep into e2ee so my review is fairly high level

// desync our bookkeeping from reality -- which previously let a later
// resubscribe skip setup while frames kept flowing through a cryptor with no
// participant assigned.
clearTimeout(this.undecryptedTrackTimeout);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: Maybe clear this.undecryptedTrackTimeout explictly here so there's not a no longer active timeout id stored? That could be a source of more bugs in the future.

There's another place in scheduleUndecryptedTrackWatchdog where I think it would be good to clear it too, before the if (operation !== 'decode') { early bail out.

Comment thread src/e2ee/E2eeManager.ts
Comment on lines +576 to +585
// @ts-ignore
previousTrackId: receiver[E2EE_TRACK_ID],
codec,
participantIdentity,
hasPacketTrailer,
},
};
this.worker.postMessage(msg);
// @ts-ignore
receiver[E2EE_TRACK_ID] = trackId;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: What's up with these @ts-ignores? Is it worth making the if condition earlier on if (E2EE_FLAG in receiver && E2EE_TRACK_ID in receiver) { to drop them?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants