Repository navigation
camera_livekit_bridge: validate each copy with the slot write generation - #1549
gareth-morgan-nv wants to merge 4 commits into
Conversation
camera_receiver rewrites a CUDA IPC slot ring_depth pictures after announcing it and never waits for a reader, and the replacement notice only arrives after the new write, so a reader could not tell that its copy overlapped a rewrite. The receiver now advances a shared per-slot write-generation marker for every eye before any GPU work touches the slot, waits for each worker's own CUDA stream, and announces that generation only once the write is complete. A failed attempt publishes nothing and keeps its generation. A reader copies into memory it owns, waits for its GPU reads to finish, and keeps the copy only if the marker still equals the notified generation. The example consumer does this and refuses a publisher that does not offer the feature. The marker is a small header-only native helper with a Python binding, shared by Python and C++ readers, in a new ipc_protocol component. Readers that ignore the marker are unchanged and outside the guarantee. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Gareth Morgan <gmorgan@nvidia.com>
…e generation The bridge now maps camera_receiver's shared per-slot write-generation markers through the same native helper the receiver uses, and refuses a publisher that does not provide them. After the GPU copy into the encoder input surface has completed it loads the slot's marker and encodes the picture only if the marker still equals the notified generation; otherwise it drops the picture, counts a slot overrun and prints a prominent error. The same check before the copy only saves work. The notification-age check, its flag, statistics and tests are removed, so there is a single integrity decision. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Gareth Morgan <gmorgan@nvidia.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
CUDA treats a read racing a write as undefined behavior, so the check is a stopgap that makes overlaps visible rather than a documented guarantee. The writer-side exclusion that would replace it is follow-up work. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Gareth Morgan <gmorgan@nvidia.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Gareth Morgan <gmorgan@nvidia.com>
|
Reviewed 787b9be. I have no blocking objection to the current bridge adoption of #1548 as interim protection. The code waits for the copy to finish, checks the marker, and drops a changed slot before encoding. The bridge-specific code and shared example helper are in appropriate directories. I accept the documented residual CUDA overlap risk for this temporary integration. A writer-honoured reservation mechanism and a deterministic test of the actual bridge's during-copy rejection can remain follow-ups; I am not requesting those changes before this PR lands. Keep the existing limitation and replacement notes, and proceed with the dependency/restack plan. Reviewed with Codex on behalf of Farbod; this is not a formal approval. |
|
Closing this together with the receiver-side detection PR (#1548). The bridge will adopt the slot-ownership protocol that replaces it. The branch is kept for reference. |
Summary
Makes the bridge validate every copy it takes from
camera_receiverwith the shared per-slot write-generation marker, so a picture whose slot the receiver rewrote after announcing it is dropped instead of encoded. This replaces the notification-age check as the integrity decision. It builds on the receiver-side change in #1548 and is based on the bridge PR (#1478), so the diff here is only the bridge change.What changed
slot_write_generation, maps the markers advertised insubscribedthrough the same native helper the receiver uses (camera_streamer/ipc_protocol), and exposesslot_unchanged(notice).encode. A changed marker drops the picture, releases the surface, counts a slot overrun and prints a prominentSLOT OVERWRITE DETECTEDerror (at most every 5 s per stream).--max-notice-age-ms, the stale and unchecked statistics and their tests. The newer-notice check is gone with it.Validation
Known limitations / follow-ups
Test plan
🤖 Generated with Claude Code