Fix WebRTC callback shutdown deadlock - #2778
Open
voropaevv wants to merge 1 commit into
Open
Conversation
Dispatch event-loop initiated cleanup to a helper thread while keeping external close calls synchronous. Add deterministic lifecycle coverage for callback, startup-lock, concurrent, and failure schedules. Fixes roboflow#2777
voropaevv
marked this pull request as ready for review
August 10, 2026 18:47
voropaevv
requested review from
PawelPeczek-Roboflow,
dkosowski87,
grzegorz-roboflow,
hansent,
probicheaux,
rafel-roboflow and
yeldarby
as code owners
August 10, 2026 18:47
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.
Why
WebRTCSession.close()may be called byon_dataandon_errorcallbacks on the session event-loop thread. It previously submitted cleanup coroutines to that same loop and blocked onFuture.result(), preventing the loop from running them. The public state changed toCLOSEDbefore teardown, so a laterclose()call could not recover the pending cleanup.Fixes #2777
What changed
Verification
.venv/bin/python -m pytest tests/inference_sdk/unit_tests/webrtc/test_session_lifecycle.py -q— 32 passed.venv/bin/python -m pytest tests/inference_sdk/unit_tests/webrtc -q— 83 passed.venv/bin/python -m pytest tests/inference_sdk/unit_tests -q— 519 passed, 86 existing deprecation warningsPATH="$PWD/.venv/bin:$PATH" make check_code_quality— passedgit diff --check— passedNot verified
_init()assignsself._pcis separate pre-existing startup-failure behavior and remains outside this changeRisks / rollback
The change is isolated to the SDK close lifecycle. External
close()remains synchronous; only calls originating on the internal event loop are dispatched. Reverting commit7da042d9e08d30a367e505e89ba91a6429fad55frestores the previous behavior.Migrations / external effects
None.
Screenshots / preview
Not applicable; no UI changes.