fix: Enable E2EE for VP9 codec - #953
Merged
Merged
Conversation
cloudwebrtc
requested changes
Jan 7, 2026
Contributor
There was a problem hiding this comment.
For reliability, please enable VP9 only in this PR since AV1 is marked as not yet supported in the JS SDK.
https://github.com/livekit/client-sdk-js/blob/main/src/e2ee/worker/FrameCryptor.ts#L669-L671
Contributor
Author
|
Thanks for the input. I have updated the PR to enable E2EE for VP9 only. Please check again. |
cloudwebrtc
approved these changes
Jan 7, 2026
| ..on<TrackSubscribedEvent>((event) async { | ||
| final codec = event.publication.mimeType.split('/')[1]; | ||
| if (event.publication.encryptionType == EncryptionType.kNone || isSVCCodec(codec)) { | ||
| if (event.publication.encryptionType == EncryptionType.kNone) { |
Contributor
There was a problem hiding this comment.
Suggested change
| if (event.publication.encryptionType == EncryptionType.kNone) { | |
| if (event.publication.encryptionType == EncryptionType.kNone || codec.toLowerCase() == 'av1') { |
| ..on<LocalTrackPublishedEvent>((event) async { | ||
| if (event.publication.encryptionType == EncryptionType.kNone || | ||
| isSVCCodec(event.publication.track?.codec ?? '')) { | ||
| if (event.publication.encryptionType == EncryptionType.kNone) { |
Contributor
There was a problem hiding this comment.
Suggested change
| if (event.publication.encryptionType == EncryptionType.kNone) { | |
| if (event.publication.encryptionType == EncryptionType.kNone || | |
| event.publication.track?.codec?.toLowerCase() == 'av1') { |
hiroshihorie
approved these changes
Jan 7, 2026
rokk4
added a commit
to rokk4/client-sdk-flutter
that referenced
this pull request
Jul 28, 2026
Brings 18 upstream commits, notably 42f6b14 "fix: allow selectAudioOutput on Android" (livekit#1121) — without it Hardware.selectAudioOutput early-returned with "only supported on Desktop", so the in-call output picker was inert on Android. selectAudioOutput now refuses only on Web/iOS. Conflict resolution: - lib/src/options.dart — both sides added a RoomOptions field in the same place. Kept both: our pendingTrackQueueMaxSize and upstream's networkOptions. - lib/src/core/room.dart — kept our prefixed pending_queue.PendingTrackQueue construction (metadataTimeout, not upstream's ttl) and added upstream's RpcClientManager/RpcServerManager init from the RPC v2 work (livekit#1087). Dropped the VP9 patch (cffd8a7 "vp9 experiment"): web/e2ee.frame_cryptor.dart is restored to upstream. That patch made getUnencryptedBytes return 0 for VP9 — encrypt the whole frame, header included — while every other peer (native libwebrtc, the JS SDK) uses the standard key=10 / delta=3 prefix. Since the same function runs on both encrypt and decrypt, the mismatch means a VP9 frame from mobile cannot be decrypted on web and vice versa, and with failureTolerance: -1 it fails silently rather than surfacing an error. It is also redundant: upstream fixed VP9 E2EE properly in b835995 (livekit#953), which narrowed the frame-cryptor skip from isSVCCodec to isAV1Codec, and that fix is already in this branch. Our patch predates it by a month and targeted the same symptom via the wrong mechanism. Verified: flutter analyze clean, all 70 tests in test/core pass, and the three patches the fork exists for are intact (pending_track_queue rejoin hardening, pendingTrackQueueMaxSize, iOS podspec 16.0).
rokk4
added a commit
to rokk4/client-sdk-flutter
that referenced
this pull request
Jul 29, 2026
Reverts the drop made during the upstream merge. getUnencryptedBytes returns 0 for VP9 so the web worker matches the native FrameCryptor, which encrypts the whole frame. Without it web and mobile disagree on where the ciphertext starts and cannot decrypt each other's VP9 video. Upstream livekit#953 enables VP9 E2EE but does not align the unencrypted-byte boundary.
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.
Problem
While using the Flutter SDK with JS SDK and with E2EE enabled, the video from Web can not be decrypted by the Flutter app.
Summary
Enables end-to-end encryption (E2EE) for VP9 codec. Previously, E2EE was skipped for all SVC codecs. This aligns the Flutter SDK with the JS SDK, where E2EE works with VP9 codec.
Changes
Removed
isSVCCodec()and useisAV1Codec()to enable E2EE setup for VP9 codec inLocalTrackPublishedEventhandlerRemoved
isSVCCodec()and useisAV1Codec()to enable E2EE setup for VP9 codec inTrackSubscribedEventhandlerIs there any specific reason why E2EE is disabled for SVC codecs?
I tried VP9 with this patch and the VP9 video from Web can be decrypted by Flutter app.