fix(input): recover control state after queue saturation
This commit is contained in:
1 parent
b9280a2e19
commit
82bdf76fe5
6 files changed
+123
-23
No files matched your search
@@ -12,7 +12,8 @@ Current implementation and evidence are on this branch; no public release.
|
||||
- **`992b0d1d`: accepted into the controlled lab only.** The retained socket,
|
||||
three measured targets, old-reader fallback and restricted pairings match the
|
||||
requested scope. The namespace control uses destination-dependent exits and
|
||||
filtering, and exercises survey through actual channel signaling. It is running.
|
||||
endpoint-dependent filtering through actual channel signaling. Its prepared
|
||||
control is complete; selected-path application traffic remains open.
|
||||
- **Shared diagnostic ring: fixed in `0e61a591`.** Default video samples have
|
||||
their own bounded typed FIFO and `video-admission.ndjson`; retirement stays
|
||||
in the event history. This keeps single-report retrospective analysis without
|
||||
@@ -32,12 +33,15 @@ Chrome preview covered failed preparation, independent preview, cancellation
|
||||
with the old video retained, and confirmation replacing it. Real member-site
|
||||
selection remains separate from that synthetic control.
|
||||
|
||||
The related Native queue audit found two candidates: source reply backpressure
|
||||
The related Native queue audit corrected two paths: source reply backpressure
|
||||
can leave the viewer's revoked-control state stale, and a dropped remote DCEP
|
||||
open can leave an input channel unclaimed. They reuse reply consumption and
|
||||
normal channel closure, respectively. The first path and its production routing
|
||||
hook pass; the second is awaiting its SDK regression. No generic event retry
|
||||
framework is proposed.
|
||||
normal channel closure, respectively. Both fixes pass the actual input routing
|
||||
and str0m regressions.
|
||||
Full input backpressure releases held keys and sends the current terminal state
|
||||
when the queue is consumed. Rejected channel announcements close only that
|
||||
unclaimed SCTP stream; the room still exchanges data and the established input
|
||||
lane can reopen while video continues.
|
||||
|
||||
## Study decision still open
|
||||
|
||||
@@ -73,4 +77,24 @@ renderer tasks below 15 ms in the synthetic three-video fixture. This does not
|
||||
clear the reporting WebView/OS-maximize path. No performance policy changed.
|
||||
|
||||
Maintenance #560 includes source-volume handoff repair at `1cc8ebb0`, remains
|
||||
draft and held, and keeps its earlier frozen candidate packages.
|
||||
draft and held, and keeps its earlier frozen candidate packages. Its new
|
||||
`998e9f50` also closes an input leg when Pion rejects a write. An injected real
|
||||
SCTP size rejection left the baseline waiting; the correction delivered lost
|
||||
readiness while a sibling and the shared association remained usable.
|
||||
|
||||
## Measured exits: kernel result
|
||||
|
||||
The draft's stable side first checked the first measured exit, then actively
|
||||
checked the second at about +99 ms with the same transaction ID. Packet capture
|
||||
contains both matching authenticated successes, and that side emitted Complete.
|
||||
With an unmeasured peer-facing exit it emitted Unavailable at about five seconds.
|
||||
The recorded survey socket used .11, .13 and .11 toward the three STUN targets.
|
||||
Independent calibration used other ports, so these mapping facts come from the
|
||||
actual preparation traffic. The fixture uses conntrack endpoint-dependent
|
||||
filtering, which is stricter than address-only filtering.
|
||||
|
||||
The baseline already connected through ordinary ICE. The positive run has no
|
||||
media flow and DTLS traffic on two port pairs, so Complete plus connected does
|
||||
not establish which prepared socket carried application data. We are extending
|
||||
the existing media fixture to correlate nomination, prepared tuple and decoded
|
||||
picture. No claim of a higher field success rate or production adoption yet.
|
||||
@@ -424,6 +424,16 @@ impl Source {
|
||||
.unwrap()
|
||||
.with_source(self.0.video, None, action)
|
||||
}
|
||||
pub(crate) fn reply_dequeued(&self) {
|
||||
let mut executor = self.0.desktop.0.lock().unwrap();
|
||||
let video = self.0.video;
|
||||
if executor.sources.get(&video).is_some_and(|source| {
|
||||
source.controllers.values().any(|controller| controller.reply_pending)
|
||||
}) {
|
||||
let _ = executor.with_source(video, None, |_, _| Ok(()));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn close(&self) {
|
||||
self.0.desktop.0.lock().unwrap().close(self.0.video);
|
||||
}
|
||||
@@ -612,6 +622,7 @@ impl Source {
|
||||
failed: false,
|
||||
reason: None,
|
||||
last: None,
|
||||
reply_pending: false,
|
||||
pad: None,
|
||||
pad_failed: false,
|
||||
},
|
||||
@@ -877,6 +888,7 @@ struct Controller {
|
||||
reason: Option<&'static str>,
|
||||
// Latest reply snapshot; its intent can name a retired request, never consent.
|
||||
last: Option<RemoteState>,
|
||||
reply_pending: bool,
|
||||
pad: Option<gamepad::Pad>,
|
||||
pad_failed: bool,
|
||||
}
|
||||
@@ -1322,23 +1334,22 @@ impl Executor {
|
||||
capabilities,
|
||||
input_failed: c.failed || (c.grant.is_some() && !self.releases.is_empty()),
|
||||
};
|
||||
if response.is_some() || c.last.as_ref() != Some(&state) {
|
||||
if response.is_some() || c.reply_pending || c.last.as_ref() != Some(&state) {
|
||||
let reply = serde_json::to_vec(&state)
|
||||
.map_err(anyhow::Error::from)
|
||||
.and_then(|bytes| c.cipher.seal(&bytes, c.flow));
|
||||
c.reply_pending = false;
|
||||
let sent = reply.is_ok_and(|data| {
|
||||
source
|
||||
.replies
|
||||
.try_send(Reply {
|
||||
publication: source.publication,
|
||||
controller: id,
|
||||
flow: c.flow,
|
||||
data,
|
||||
})
|
||||
.is_ok()
|
||||
let result = source.replies.try_send(Reply {
|
||||
publication: source.publication,
|
||||
controller: id,
|
||||
flow: c.flow,
|
||||
data,
|
||||
});
|
||||
c.reply_pending = matches!(result, Err(mpsc::error::TrySendError::Full(_)));
|
||||
result.is_ok()
|
||||
});
|
||||
// Keep correlation even when enqueue fails. Sync repeats current
|
||||
// state; it never revives the grant retired by backpressure.
|
||||
// Remember the intent even when capacity delays its terminal reply.
|
||||
c.last = Some(state);
|
||||
if !sent {
|
||||
self.release(source, &mut c);
|
||||
|
||||
@@ -1283,13 +1283,15 @@ fn local_stop_requires_fresh_consent_and_reply_backpressure_cleans_up_holds() {
|
||||
false
|
||||
))
|
||||
);
|
||||
while replies.try_recv().is_ok() {}
|
||||
c.send(&s, json!({"type":"sync"}));
|
||||
// Local stop changes the terminal snapshot while the reply queue is still full.
|
||||
d.revoke();
|
||||
replies.try_recv().unwrap();
|
||||
s.reply_dequeued();
|
||||
let state = c.state(&mut replies);
|
||||
assert_eq!(state["mode"], "ask");
|
||||
assert_eq!(state["state"], "ready");
|
||||
assert_eq!(state["intent"], intent.simple().to_string());
|
||||
assert!(state.get("grant").is_none());
|
||||
d.revoke();
|
||||
assert_eq!(view.borrow().mode, Mode::Ask);
|
||||
c.send(&s, json!({"type":"request","intent":Uuid::new_v4()}));
|
||||
assert_eq!(c.state(&mut replies)["state"], "pending");
|
||||
|
||||
@@ -278,9 +278,11 @@ impl Inputs {
|
||||
}
|
||||
|
||||
pub fn reply(&self, video: Uuid, reply: Reply) -> Option<Outgoing> {
|
||||
if self.sources.get(&reply.publication)?.video() != video {
|
||||
let source = self.sources.get(&reply.publication)?;
|
||||
if source.video() != video {
|
||||
return None;
|
||||
}
|
||||
source.reply_dequeued();
|
||||
let binding = self.bindings.get(&(reply.publication, reply.controller))?;
|
||||
if binding.route_id != reply.flow {
|
||||
return None;
|
||||
@@ -626,6 +628,19 @@ pub(super) mod tests {
|
||||
input.registrations(vec![registration.clone()]).is_empty(),
|
||||
"unchanged registration has no retry loop"
|
||||
);
|
||||
// Exhaust the source reply queue, then let the peer owner dequeue one.
|
||||
for _ in 0..40 {
|
||||
source.set_mode(crate::input::Mode::Room).unwrap();
|
||||
source.set_mode(crate::input::Mode::Ask).unwrap();
|
||||
}
|
||||
use futures_util::{FutureExt, StreamExt};
|
||||
let mut routed = 0;
|
||||
while let Some(Some((video, reply))) = input.replies.next().now_or_never() {
|
||||
assert!(input.reply(video, reply).is_some());
|
||||
routed += 1;
|
||||
assert!(routed <= 65);
|
||||
}
|
||||
assert_eq!(routed, 65, "one current state follows the 64 queued replies");
|
||||
source.set_mode(crate::input::Mode::Room).unwrap();
|
||||
for paused in [true, false] {
|
||||
snapshot.send_modify(|state| state.as_mut().unwrap().publications[0].paused = paused);
|
||||
|
||||
@@ -58,6 +58,40 @@ async fn established_input_lane_reopens_after_peer_close_while_video_is_playing(
|
||||
result
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn saturated_channel_announcement_closes_only_the_unclaimed_input() -> Result<()> {
|
||||
use crate::peer::tests::support::{endpoint, exchange, open};
|
||||
|
||||
let runtime = Runtime::ipv4_loopback();
|
||||
let result = async {
|
||||
let (left, _left_events) = endpoint(&runtime, Uuid::new_v4()).await?;
|
||||
let (right, mut events) = endpoint(&runtime, Uuid::new_v4()).await?;
|
||||
let (room, remote_room) = open(&left, &right, &mut events).await?;
|
||||
right.call(|engine| {
|
||||
let EventTarget::Peer(events) = &engine.events else { unreachable!() };
|
||||
while events.try_send(Event::Negotiate(engine.handle.pair)).is_ok() {}
|
||||
Ok(())
|
||||
}).await?;
|
||||
|
||||
let input = left.create_channel("piik-input").await?;
|
||||
ensure!(left.offer().await?.is_none());
|
||||
tokio::time::timeout(Duration::from_secs(5), async {
|
||||
ensure!(matches!(input.poll().await, Some(ChannelEvent::Open)));
|
||||
ensure!(matches!(input.poll().await, Some(ChannelEvent::Close)));
|
||||
Ok::<_, anyhow::Error>(())
|
||||
}).await.context("creator did not observe the rejected channel close")??;
|
||||
right.call(|engine| {
|
||||
ensure!(engine.channels.len() == 1);
|
||||
ensure!(!engine.overflow.load(Ordering::Acquire));
|
||||
Ok(())
|
||||
}).await?;
|
||||
exchange(&room, &remote_room, "room survived input rejection").await?;
|
||||
Ok(())
|
||||
}.await;
|
||||
runtime.close().await;
|
||||
result
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn source_ended_before_ready_fails_only_its_current_flow() -> Result<()> {
|
||||
use crate::{
|
||||
|
||||
@@ -2310,6 +2310,20 @@ impl Engine {
|
||||
if let Some(channel) = self.channels.values().find(|c| c.id == Some(id)) {
|
||||
let _ = channel.push(ChannelEvent::Open, &self.receive_memory);
|
||||
} else {
|
||||
// A remote DCEP open is announced once. Reset an unclaimed stream
|
||||
// so its creator observes closure and can reopen the lane.
|
||||
let EventTarget::Peer(events) = &self.events else {
|
||||
self.rtc.direct_api().close_data_channel(id);
|
||||
return;
|
||||
};
|
||||
let Ok(slot) = events.try_reserve() else {
|
||||
use crate::data::Lane;
|
||||
if matches!(Lane::from_label(&label), Some(Lane::Control | Lane::Bulk)) {
|
||||
self.overflow.store(true, Ordering::Release);
|
||||
}
|
||||
self.rtc.direct_api().close_data_channel(id);
|
||||
return;
|
||||
};
|
||||
let token = Uuid::new_v4();
|
||||
let (tx, rx) = mpsc::unbounded_channel();
|
||||
let low = Arc::new(Notify::new());
|
||||
@@ -2323,7 +2337,7 @@ impl Engine {
|
||||
};
|
||||
let _ = state.push(ChannelEvent::Open, &self.receive_memory);
|
||||
self.channels.insert(token, state);
|
||||
self.emit(Event::Channel(
|
||||
slot.send(Event::Channel(
|
||||
self.handle.pair,
|
||||
Arc::new(Channel {
|
||||
transport: self.handle.clone(),
|
||||
|
||||
Reference in new issue
Block a user