Skip to content

[flutter_webrtc] Fix data channel map race, key derivation option, and setParameters encodings - #1208

Open
seungsoo47 wants to merge 3 commits into
flutter-tizen:mainfrom
seungsoo47:upstream-plugins-webrtc-data-channel-lock
Open

seungsoo47 wants to merge 3 commits into
flutter-tizen:mainfrom
seungsoo47:upstream-plugins-webrtc-data-channel-lock

Conversation

@seungsoo47

Copy link
Copy Markdown
Contributor

Port three fixes from the upstream common C++ implementation:

Integration tests are added for the last two fixes. All 13 tests passed 3 times each on RPi4, TV 10.0, and the TV 9.0 / 10.0 emulators.

Data channel observers are added to data_channel_observers_ under the base
lock, and one of those inserts runs on the WebRTC signaling thread
(OnDataChannel). DataChannelClose and DataChannelForId read and erase the
map on the platform thread without the lock, which is a data race on
std::map. Take the lock around those accesses too.

Upstream flutter_webrtc has the same code in common/cpp and fixed it the
same way in flutter-webrtc/flutter-webrtc#2194
(8ecd2e526fd1cf6d3ad0fd4fe53696e0c0f210ec, 1.6.2+hotfix.4).
…ovider

FrameCryptorFactoryCreateKeyProvider did not read keyDerivationAlgorithm
from KeyProviderOptions, so libwebrtc always used PBKDF2 even when HKDF
was requested. Parse the option into key_derivation_algorithm.

The helper in flutter_data_packet_cryptor.cc named
KeyDerivationAlgorithmFromInt actually mapped the cipher algorithm, so it
is replaced by AlgorithmFromInt from flutter_frame_cryptor.cc. The mapping
is unchanged.

Ported from flutter-webrtc/flutter-webrtc#2049
(bcf08738e576f988312e1d7c46b9eff1489daf70).
updateRtpParameters modified the objects returned by
RTCRtpParameters::encodings(), but libwebrtc returns copies, so every
change to encodings (maxBitrate, maxFramerate, active, ...) was dropped
and setParameters still returned true. Write the encodings back with
set_encodings().

Once the encodings are written back, two placeholder values that
rtpParametersToMap reports for unset fields come back from Dart and are
rejected by libwebrtc: an empty scalabilityMode, and ssrc 0 before
negotiation. setParameters then returned false for the usual
read-modify-write call, so skip these two values.

Ported from flutter-webrtc/flutter-webrtc#2211
(db81cea2730ae65b53fd3ffa97f45ad71200344a).
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T10:55:53.912438Z 265d367 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant