Early video retransmissions could be rejected before an SFU publication admitted its primary stream. The shared RTP reader now restores the associated primary identity before admission. A repository audit also found ownership omissions in Viewer input retirement, queued route work, partially constructed connections and sender-evidence cleanup; each is corrected at its existing owner without changing routing or adaptation policy. The same phase fixes bounded Linux diagnostic encoding, picker/tooltip keyboard and touch behavior, and stale-language notices. Documentation now reflects current App, room and media lifecycles. Theme-role consolidation remains deferred. Validation: complete Web check (1,685 tests, type-check and build); Windows Go core tests/vet/cross-builds; Linux CI race/vulnerability checks and all seven package targets; native Linux diagnostic fixtures on both architectures; actual Chromium/Pion SFU decode, live settings, reload/recovery and resource-retirement gate; documentation and website builds. Confirmed defects were compared against their baseline and independently reviewed. No protocol, configuration or persistence migration is required. Physical device limits and unmatched field reports remain open. ## Release notes ### 中文 这是一次分享稳定性与交互细节维护更新,兼容现有 2.x 客户端和站点。 - 修复部分服务器中转开播失败:较早到达的视频重传包不再被误判,导致媒体发布提前结束。 - 修复停播后快速重新分享时,旧任务可能拖延新线路准备的问题。 - 撤销邀请或替换观众会话时,同步清理对应的远控输入身份,保留其他观众的正常使用。 - 改善连接失败、观众反复加入退出后的资源回收;避免 Linux 单路输出的错误信息意外中断整个分享。 - 修正选源、互动和线路提示的键盘/触屏操作;切换语言后,当前校验与错误提示会同步更新。 ### English This maintenance update improves sharing reliability and interaction details. It remains compatible with existing 2.x Apps and Sites. - Fix an SFU startup failure caused by video retransmissions arriving before the primary stream was admitted. - Prevent retired sharing tasks from delaying route preparation after a quick stop and restart. - Retire remote-input identities when invitations are revoked or Viewer sessions are replaced, while preserving other participants. - Release resources correctly after connection failures and repeated Viewer churn; prevent Linux output diagnostics from unexpectedly ending the whole share. - Improve keyboard and touch behavior in source selection, interactions and route help. Active validation and error messages now follow language changes.
318 lines
11 KiB
TypeScript
318 lines
11 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
invalidateSenderQualityEvidence,
|
|
retireSenderQualityEvidence,
|
|
retireSfuPublisherQualityEvidence,
|
|
senderQualityEvidenceFromSnapshot,
|
|
sfuPublisherQualityEvidenceFromMetrics,
|
|
} from "../src/client/media/sender-quality-evidence.ts";
|
|
import type { PeerSnapshot } from "../src/client/types.ts";
|
|
import { EMPTY_METRICS } from "../src/client/types.ts";
|
|
import {
|
|
collectConnectionMetricsFromReport,
|
|
collectNativeSenderQualityFromReport,
|
|
createNativeSenderQualityAccumulator,
|
|
createStatsAccumulator,
|
|
} from "../src/client/webrtc/stats.ts";
|
|
|
|
function report(
|
|
timestamp: number,
|
|
reason: "none" | "bandwidth" | "cpu",
|
|
durations: Record<"none" | "bandwidth" | "cpu" | "other", number>,
|
|
): RTCStatsReport {
|
|
return new Map([
|
|
[
|
|
"video",
|
|
{
|
|
id: "video",
|
|
type: "outbound-rtp",
|
|
kind: "video",
|
|
timestamp,
|
|
ssrc: 1,
|
|
bytesSent: timestamp * 100,
|
|
framesEncoded: timestamp / 20,
|
|
qualityLimitationReason: reason,
|
|
qualityLimitationDurations: durations,
|
|
},
|
|
],
|
|
]) as unknown as RTCStatsReport;
|
|
}
|
|
|
|
describe("native sender quality evidence", () => {
|
|
it.each(["failed", "closed"] as const)("does not retain a retired %s snapshot", (connectionState) => {
|
|
invalidateSenderQualityEvidence();
|
|
const snapshot: PeerSnapshot = {
|
|
peerId: "viewer_12345678", connectionId: "connection_12345678",
|
|
connectionState: "connected", iceConnectionState: "connected", error: null,
|
|
metrics: { ...EMPTY_METRICS },
|
|
};
|
|
expect(senderQualityEvidenceFromSnapshot(snapshot, 2)?.state).toBe("unknown");
|
|
expect(senderQualityEvidenceFromSnapshot({ ...snapshot, connectionState }, 2)).toBeNull();
|
|
expect(senderQualityEvidenceFromSnapshot(snapshot, 2)?.state).toBe("unknown");
|
|
});
|
|
|
|
it.each(["direct", "publication"])("retires only the released %s identity", (path) => {
|
|
invalidateSenderQualityEvidence();
|
|
const metrics = {
|
|
...EMPTY_METRICS, sampleTimestampMs: 1_000, sampleWindowMs: 2_000,
|
|
rtpStatsId: "outbound-1", trackIdentifier: "track-1", intervalFramesEncoded: 30,
|
|
nativeEdgeQualityState: "healthy" as const, qualityLimitationReason: "none",
|
|
};
|
|
const emit = (identity: string) => path === "direct"
|
|
? senderQualityEvidenceFromSnapshot({
|
|
peerId: "viewer_12345678", connectionId: identity,
|
|
connectionState: "connected", iceConnectionState: "connected", error: null, metrics,
|
|
}, 2)
|
|
: sfuPublisherQualityEvidenceFromMetrics(metrics, 2, identity);
|
|
const retired = "retired_12345678";
|
|
const live = "live_12345678";
|
|
expect(emit(retired)?.state).toBe("unknown");
|
|
expect(emit(live)?.state).toBe("unknown");
|
|
if (path === "direct") retireSenderQualityEvidence(retired);
|
|
else retireSfuPublisherQualityEvidence(retired);
|
|
expect(emit(retired)?.state).toBe("unknown");
|
|
expect(emit(live)).toBeNull();
|
|
metrics.sampleTimestampMs += 2_000;
|
|
expect(emit(live)?.state).toBe("healthy");
|
|
});
|
|
|
|
it.each(["direct", "publication"])("preserves %s observations independently of control evidence", (path) => {
|
|
invalidateSenderQualityEvidence();
|
|
const metrics = {
|
|
...EMPTY_METRICS, sampleTimestampMs: 1_000, sampleWindowMs: 2_000,
|
|
rtpStatsId: "outbound-1", trackIdentifier: "track-1", intervalFramesEncoded: 960,
|
|
nativeEdgeQualityState: "healthy" as const, qualityLimitationReason: "none",
|
|
availableOutgoingKbps: 1_000_000, bitrateKbps: 120_000, framesPerSecond: 480,
|
|
rttMs: NaN, packetLossPercent: 101,
|
|
};
|
|
const emit = () => path === "direct"
|
|
? senderQualityEvidenceFromSnapshot({
|
|
peerId: "viewer_12345678", connectionId: "connection_12345678",
|
|
connectionState: "connected", iceConnectionState: "connected", error: null, metrics,
|
|
}, 2)
|
|
: sfuPublisherQualityEvidenceFromMetrics(metrics, 2, "publication_12345678");
|
|
expect(emit()?.state).toBe("unknown");
|
|
metrics.sampleTimestampMs += 2_000;
|
|
expect(emit()).toMatchObject({ state: "healthy", diagnostics: {
|
|
availableOutgoingKbps: 1_000_000, bitrateKbps: 120_000, framesPerSecond: 480,
|
|
rttMs: null, packetLossPercent: null,
|
|
} });
|
|
metrics.sampleTimestampMs += 2_000;
|
|
metrics.intervalFramesEncoded = NaN;
|
|
expect(emit()?.state).toBe("unknown");
|
|
metrics.intervalFramesEncoded = 960;
|
|
metrics.sampleTimestampMs += 2_000;
|
|
expect(emit()?.state).toBe("healthy");
|
|
});
|
|
|
|
it("uses actual Native publication sent frames without inventing encoder work", () => {
|
|
invalidateSenderQualityEvidence();
|
|
const metrics = {
|
|
...EMPTY_METRICS,
|
|
sampleTimestampMs: 12_000,
|
|
sampleWindowMs: 2_000,
|
|
intervalFramesSent: 30,
|
|
framesPerSecond: 15,
|
|
nativeEdgeQualityState: "healthy" as const,
|
|
qualityLimitationReason: "none",
|
|
};
|
|
sfuPublisherQualityEvidenceFromMetrics(metrics, 3, "native_publication");
|
|
expect(
|
|
sfuPublisherQualityEvidenceFromMetrics(
|
|
{ ...metrics, sampleTimestampMs: 14_000 },
|
|
3,
|
|
"native_publication",
|
|
),
|
|
).toMatchObject({ state: "healthy", diagnostics: { framesPerSecond: 15 } });
|
|
expect(metrics.intervalFramesEncoded).toBeNull();
|
|
});
|
|
it("conservatively combines every active SFU publication encoding", () => {
|
|
const accumulator = createNativeSenderQualityAccumulator();
|
|
const multi = (
|
|
timestamp: number,
|
|
reasons: readonly ["none" | "bandwidth", "none" | "bandwidth"],
|
|
) => {
|
|
const entries: Array<[string, Record<string, unknown>]> = [
|
|
[
|
|
"source",
|
|
{
|
|
id: "source",
|
|
type: "media-source",
|
|
timestamp,
|
|
trackIdentifier: "track",
|
|
},
|
|
],
|
|
];
|
|
reasons.forEach((reason, index) =>
|
|
entries.push([
|
|
`video-${index}`,
|
|
{
|
|
id: `video-${index}`,
|
|
type: "outbound-rtp",
|
|
kind: "video",
|
|
timestamp,
|
|
framesEncoded: timestamp / 20 + index,
|
|
mediaSourceId: "source",
|
|
qualityLimitationReason: reason,
|
|
qualityLimitationDurations: {
|
|
none: reason === "none" ? timestamp / 1_000 : 3,
|
|
bandwidth: reason === "bandwidth" ? timestamp / 1_000 - 3 : 0,
|
|
cpu: 0,
|
|
other: 0,
|
|
},
|
|
},
|
|
]),
|
|
);
|
|
return new Map(entries) as unknown as RTCStatsReport;
|
|
};
|
|
|
|
expect(
|
|
collectNativeSenderQualityFromReport(
|
|
multi(1_000, ["none", "none"]),
|
|
"track",
|
|
accumulator,
|
|
).nativeEdgeQualityState,
|
|
).toBe("unknown");
|
|
expect(
|
|
collectNativeSenderQualityFromReport(
|
|
multi(3_000, ["none", "none"]),
|
|
"track",
|
|
accumulator,
|
|
).nativeEdgeQualityState,
|
|
).toBe("healthy");
|
|
expect(
|
|
collectNativeSenderQualityFromReport(
|
|
multi(5_000, ["bandwidth", "none"]),
|
|
"track",
|
|
accumulator,
|
|
).nativeEdgeQualityState,
|
|
).toBe("degraded");
|
|
});
|
|
|
|
it("derives categorical state only from one complete native duration delta", () => {
|
|
const accumulator = createStatsAccumulator();
|
|
const first = collectConnectionMetricsFromReport(
|
|
report(1_000, "none", { none: 1, bandwidth: 0, cpu: 0, other: 0 }),
|
|
"send",
|
|
accumulator,
|
|
);
|
|
expect(first.nativeEdgeQualityState).toBe("unknown");
|
|
|
|
const healthy = collectConnectionMetricsFromReport(
|
|
report(3_000, "none", { none: 3, bandwidth: 0, cpu: 0, other: 0 }),
|
|
"send",
|
|
accumulator,
|
|
);
|
|
expect(healthy.nativeEdgeQualityState).toBe("healthy");
|
|
|
|
const degraded = collectConnectionMetricsFromReport(
|
|
report(5_000, "bandwidth", {
|
|
none: 3,
|
|
bandwidth: 2,
|
|
cpu: 0,
|
|
other: 0,
|
|
}),
|
|
"send",
|
|
accumulator,
|
|
);
|
|
expect(degraded.nativeEdgeQualityState).toBe("degraded");
|
|
|
|
const mixed = collectConnectionMetricsFromReport(
|
|
report(7_000, "none", {
|
|
none: 4,
|
|
bandwidth: 3,
|
|
cpu: 0,
|
|
other: 0,
|
|
}),
|
|
"send",
|
|
accumulator,
|
|
);
|
|
expect(mixed.nativeEdgeQualityState).toBe("unknown");
|
|
});
|
|
|
|
it("serializes only exact healthy or degraded sender snapshots", () => {
|
|
const metrics = collectConnectionMetricsFromReport(
|
|
report(1_000, "none", { none: 1, bandwidth: 0, cpu: 0, other: 0 }),
|
|
"send",
|
|
createStatsAccumulator(),
|
|
);
|
|
const snapshot: PeerSnapshot = {
|
|
peerId: "viewer_12345678",
|
|
connectionId: "connection_12345678",
|
|
connectionState: "connected",
|
|
iceConnectionState: "connected",
|
|
metrics: {
|
|
...metrics,
|
|
rtpStatsId: "rtp-stats-1",
|
|
trackIdentifier: "track-1",
|
|
sampleWindowMs: 2_000,
|
|
intervalFramesEncoded: 100,
|
|
qualityLimitationReason: "none",
|
|
nativeEdgeQualityState: "healthy",
|
|
},
|
|
error: null,
|
|
};
|
|
expect(senderQualityEvidenceFromSnapshot(snapshot, 7)).toMatchObject({
|
|
state: "unknown",
|
|
});
|
|
expect(senderQualityEvidenceFromSnapshot(snapshot, 7)).toBeNull();
|
|
const nextSnapshot = {
|
|
...snapshot,
|
|
metrics: {
|
|
...snapshot.metrics,
|
|
sampleTimestampMs: 2_000,
|
|
},
|
|
};
|
|
expect(senderQualityEvidenceFromSnapshot(nextSnapshot, 7)).toMatchObject({
|
|
type: "sender-quality-evidence",
|
|
childPeerId: snapshot.peerId,
|
|
connectionId: snapshot.connectionId,
|
|
routeRevision: 7,
|
|
state: "healthy",
|
|
sampleTimestampMs: 2_000,
|
|
diagnostics: { natTraversalPath: "unknown" },
|
|
});
|
|
invalidateSenderQualityEvidence();
|
|
expect(senderQualityEvidenceFromSnapshot(nextSnapshot, 7)).toMatchObject({
|
|
state: "unknown",
|
|
});
|
|
expect(senderQualityEvidenceFromSnapshot(nextSnapshot, 7)).toBeNull();
|
|
});
|
|
|
|
it("waits for a new SFU publisher stats window after rebaseline", () => {
|
|
invalidateSenderQualityEvidence();
|
|
const metrics = {
|
|
...collectConnectionMetricsFromReport(
|
|
report(1_000, "none", {
|
|
none: 1,
|
|
bandwidth: 0,
|
|
cpu: 0,
|
|
other: 0,
|
|
}),
|
|
"send",
|
|
createStatsAccumulator(),
|
|
),
|
|
sampleTimestampMs: 1_000,
|
|
sampleWindowMs: 2_000,
|
|
intervalFramesEncoded: 100,
|
|
qualityLimitationReason: "none",
|
|
nativeEdgeQualityState: "healthy" as const,
|
|
};
|
|
const generation = "publication_generation_12345678";
|
|
expect(
|
|
sfuPublisherQualityEvidenceFromMetrics(metrics, 3, generation),
|
|
).toMatchObject({ state: "unknown" });
|
|
expect(
|
|
sfuPublisherQualityEvidenceFromMetrics(metrics, 3, generation),
|
|
).toBeNull();
|
|
expect(
|
|
sfuPublisherQualityEvidenceFromMetrics(
|
|
{ ...metrics, sampleTimestampMs: 3_000 },
|
|
3,
|
|
generation,
|
|
),
|
|
).toMatchObject({ state: "healthy", sampleTimestampMs: 3_000 });
|
|
});
|
|
});
|