Connection stability and E2EE key exchange improvements#3761
Draft
alisonjenkins wants to merge 6 commits intoelement-hq:livekitfrom
Draft
Connection stability and E2EE key exchange improvements#3761alisonjenkins wants to merge 6 commits intoelement-hq:livekitfrom
alisonjenkins wants to merge 6 commits intoelement-hq:livekitfrom
Conversation
The useTracks hook returns all audio tracks including the local participant's, but validIdentities intentionally excludes the local user (you shouldn't hear your own mic). This caused a spurious warning on every track update. Filter out local tracks early to resolve the existing TODO. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The /sync request occasionally aborts (AbortError), causing syncing$ to briefly go false. This cascaded through combined$ → tracks paused → "Reconnecting..." toast, even though the SDK auto-retries and sync resumes within seconds. - Add 8s debounce on syncing$ since sync errors are transient - Add 2s debounce on combined$ for membershipConnected$/certainlyConnected$ - Add per-condition diagnostic logging to identify which signal flaps Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Debounce reconnecting$ with 1.5s delay so brief disconnections don't flash the "Reconnecting..." toast to the user - Add distinctUntilChanged to localConnection$ to prevent redundant "Local connection updated" log spam (was firing 26+ times per event) - Add diagnostic logging on localConnectionState$ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Record a join timestamp when setRTCSession is called and log per-key timing on each EncryptionKeyChanged event: time since join (key delivery latency) and crypto.subtle.importKey duration. These diagnostics help identify whether slow media decryption after joining a call is caused by key delivery (Olm/sync) or key processing (Web Crypto). Filter console by [MatrixKeyProvider] to see the new logs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add use_key_delay_ms and key_rotation_grace_period_ms to the matrix_rtc_session config block, allowing operators to tune E2EE key exchange timing without code changes. - use_key_delay_ms: delay between sending a new key and encrypting with it, giving other participants time to receive the key (SDK default 1s) - key_rotation_grace_period_ms: grace period during which new joiners reuse the existing key instead of triggering another rotation (SDK default 10s) Both values are passed through to joinRTCSession and documented in the sample/devenv config files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When a user is in the call lobby with per-participant E2EE enabled, call CryptoApi.prepareToEncrypt(room) to trigger /keys/claim for any devices we don't yet have Olm sessions with. This moves the Olm session establishment cost from join-time to lobby-time, so encryption keys can be delivered immediately when the user clicks Join. In testing, key delivery to some participants took ~48s after join due to /keys/claim round-trips. With pre-warming, the Olm sessions are already established by the time the call is joined. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
toger5
reviewed
Mar 12, 2026
Comment on lines
+47
to
+49
| logger.info( | ||
| `Pre-warming Olm sessions for room ${room.roomId} (${memberships.length} call members)`, | ||
| ); |
Contributor
There was a problem hiding this comment.
The log is wrong. Or at least misleading. we are preparing for all room members. not just the N call members with this right?
toger5
reviewed
Mar 12, 2026
Comment on lines
80
to
83
| if (!isValid) { | ||
| // TODO make sure to also skip the warn logging for the local identity | ||
| // Log that there is an invalid identity, that means that someone is publishing audio that is not expected to be in the call. | ||
| prefixedLogger.warn( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
useKeyDelayandkeyRotationGracePeriodMsconfig options for fine-tuning E2EE behaviorTest plan
useKeyDelayandkeyRotationGracePeriodMsconfig options are respected🤖 Generated with Claude Code