Skip to content
This repository was archived by the owner on Jun 28, 2026. It is now read-only.

Commit 4ca403c

Browse files
committed
fix(sfu): prevent repeated ICE restarts for same consumer stall
1 parent e41eac8 commit 4ca403c

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

frontend/src/utils/media/__tests__/stallDetector.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ describe("StallDetector", () => {
112112
expect(det.check([toSample(sample)])).toEqual(["c1"]);
113113
});
114114

115-
it("respects the per-consumer recovery cooldown", () => {
115+
it("reports a stall once until media resumes", () => {
116116
const det = detector();
117117
const sample = makeSample({ createdAt: now - 10_000, muted: true });
118118

@@ -125,6 +125,15 @@ describe("StallDetector", () => {
125125
expect(det.check([toSample(sample)])).toEqual([]);
126126

127127
now += 30_000;
128+
expect(det.check([toSample(sample)])).toEqual([]);
129+
130+
sample.muted = false;
131+
sample.bytes = 2000;
132+
expect(det.check([toSample(sample)])).toEqual([]);
133+
134+
sample.muted = true;
135+
expect(det.check([toSample(sample)])).toEqual([]);
136+
now += 6_000;
128137
expect(det.check([toSample(sample)])).toEqual(["c1"]);
129138
});
130139

frontend/src/utils/media/stallDetector.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ export class StallDetector {
162162
}
163163

164164
private shouldRecover(st: ConsumerState, now: number): boolean {
165+
if (
166+
st.lastRecoveredAt !== null &&
167+
st.stallStartedAt !== null &&
168+
st.lastRecoveredAt >= st.stallStartedAt
169+
) {
170+
return false;
171+
}
165172
if (
166173
st.lastRecoveredAt !== null &&
167174
now - st.lastRecoveredAt < this.recoveryCooldownMs

0 commit comments

Comments
 (0)