fix: fixed pc close/dispose race - #70
Merged
Merged
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
A `createCallFactory()` queued during two-phase teardown can reuse a factory that the pending teardown then destroys. Concurrent creates replacing a bare-fork default can likewise destroy the first successful create's factory. Queue factory lifecycle requests until teardown completes, preserving request order and allowing peer-connection callbacks to drain between phases. Centralize the five success-callback disposal checks in `runWithPeerConnection()`. The helper checks the connection inside the executor task and passes it to the callback. Also share peer-connection disposal, observer removal, and factory unbinding between the explicit and factory teardown paths. This draft targets `pc-dispose-race`, the branch of #70. Validation: - Android Java/Kotlin compilation passed with Gradle 9.4.1, AGP 9.2.1, and React Native 0.87.0 using a temporary host project. - Eight local JVM regression scenarios passed using the production lifecycle methods, registry, and executor with native dependencies stubbed: overlapping dispose/create, concurrent default replacement, reference counts, FIFO request completion, close callback draining, disposed/live callback handling, and cleanup after a PC disposal exception. - `git diff --check` passed. The regression harness was local; no Android device runtime test was performed.
santhoshvai
approved these changes
Sep 22, 2026
|
🎉 This PR is included in version 145.3.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
5 tasks
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.
A fix for a race, when peer-connection events were added to execution queue during disposal process, which lead to addressing already freed memory.
Implementation details
Previously, shutdown could happen in this order:
This is a race condition as the result depends on unpredictable timing.
The PR changes shutdown to:
Close connection
↓
Process already queued events
↓
Dispose connection and free memory
↓
Dispose tracks and factory
It also adds several safety measures: