fix: restore input mute after TeamSpeak flood rejection

This commit is contained in:
illusia committed 2026-10-03 14:06:07 +08:00
1 parent 2c49ee2599
commit 77fef3bed9
3 files changed
+94 -6

No files matched your search

+16 -4
View File
@@ -6,9 +6,10 @@
## 范围与依据
- 最新环境更新:用户确认上海节点恢复后,`203.0.113.10:9987` 实测为 TeamSpeak `6.0.0-beta13.1` / Linux,已补充下述 TS6 消息、媒体及静音恢复验收。此前旧 IP 超时仅作为历史记录,不再阻止该节点测试;`webspeak.example.invalid:9987` 的 TS3 结果仍保留。
- 记录日期:2026 年 10 月 3 日。
- 当前记录基线:`dev` 分支,`6616d0b544dab8442212d01e3172e704f20d8f26`;应用版本 `0.2.5-preview`。以下现状包含当前工作区,不能全部归为该提交的内容。
- 本批仅补充 02-C 实服多人混音及成员音量验收,没有修改生产代码或重复完整验证。上一批协商修复通过 423 项测试及前后端构建,远端 CI 的 verify 与 docker-smoke 均成功(运行 37086916608)。
- 当前记录基线:`dev` 分支,`7636235a87a44d1dfdf945476cb896dcc0f101b0`;应用版本 `0.2.5-preview`。以下现状包含当前工作区,不能全部归为该提交的内容。
- 本批仅修复 02-C 输入状态重复上报及服务端防刷拒绝后的恢复,新增 4 项回归。合并修改后一次 `npm run verify` 通过 427 项测试及前后端构建。基线远端 CI 的 verify 与 docker-smoke 均成功(运行 37087642532);本批新提交的 CI 另行核对。
- `6aa19c4` 的 CI、Docker 构建和健康检查已确认成功(运行 36896144974)。此前 `662dad3` 的手动发布工作流完整验证、Windows/Linux 打包启动及 Docker 健康检查通过(运行 36857782727);本批远端 CI 按新提交核对。
- 既有皮肤修复记录记载新增 23 项测试,以及 `npm run verify` 通过 385 项测试和前后端构建;其中 5 项先复现旧结果覆盖及失效归属问题。这些是此前批次的验证结果,不是本轮重新执行的结果。
- Android 从 `662dad3` 源码归档重新安装三套依赖并重建 SDK,在短路径完成 android:sync 和 assembleDebug,134 个 Gradle 任务执行,三个 ABI 包内容及 SHA-256 已检查。首次深层目录因原生工具路径限制失败,短路径重建通过;没有把构建成功写成设备或媒体验收。
@@ -51,8 +52,8 @@
| --- | --- | --- | --- | --- |
| 06-C 客户端验收 | P2 | 计划中的主要展示区域已提取;真实触屏拖动及原生离开/戳人输入框流程仍待验收 | 保留当前状态边界,在支持的浏览器/真机补齐实际交互证据;不为工具限制重写业务 | 触屏拖动及原生输入框完成操作、取消与结果均有记录 |
| 06-C 管理页 | P2 | 展示拆分、主要交互及诊断/备份实际下载已验收;内置浏览器和 Edge 的原生确认框操作均使工具超时,移除和断开会话的完整浏览器流程缺记录 | 保留确认与业务逻辑,工具恢复或人工检查时补验;同一工具阻塞不反复重试 | 移除、断开的确认与取消均有实际结果记录;状态及接口测试不能替代完整浏览器链路 |
| 03 | P2 | TS3 实服目录、双向私聊、离开与戳人消息通过共享解析器;省略可选 UID 的请求可用;真实旧客户端/旧网关版本矩阵未验收 | 保留实际样本的验证范围,指定旧版本后补交叉版本检查 | 两端解析一致;非法消息受控处理;旧格式请求不等于旧应用整体通过 |
| 02-C | P2 | TS3 实服双向媒体、网关协商失败后的 PCM、双人同时混音和单成员音量已验证;静音伴奏、下行编码连续性及不支持的编码被误协商成功已修复;完整音质、浏览器设备采集、TS6 及完整浏览器回退/共享仍缺验收 | 保留先前 27/30 帧异常及随后三轮 50/50 分段复查证据,不为未复现差值改代码;继续原计划的浏览器采集与场景矩阵,不额外添加容量压测完成门槛 | 记录服务器版本、浏览器、网络、设备、步骤及结果;网关与合成客户端验收不替代设备和完整音质 |
| 03 | P2 | TS3 与上海 TS6 实服目录、双向私聊、离开与戳人消息通过共享解析器;省略可选 UID 的请求可用;真实旧客户端/旧网关版本矩阵未验收 | 保留实际样本的验证范围,指定旧版本后补交叉版本检查 | 两端解析一致;非法消息受控处理;旧格式请求不等于旧应用整体通过 |
| 02-C | P2 | TS3/TS6 实服双向 PCM/WebRTC、静音伴奏及停止后 PCM 可用已验证;TS3 网关协商失败回退、双人混音和单成员音量已验证;已修复的媒体故障见下文,完整音质、浏览器设备采集、浏览器自动回退及 TS6 原生共享互通仍缺验收 | 上海地址 `203.0.113.10:9987` 现可用于 TS6 后续场景;保留此前帧差及复查边界,不为未复现差值改代码;继续原计划的设备与共享矩阵 | 记录服务器版本、浏览器、网络、设备、步骤及结果;网关与合成客户端验收不替代设备和完整音质 |
当前范围调整:07-A 全部 Android 运行时、真机和媒体事项,以及 09-A 的 Android 布局复验,按用户要求暂不纳入本轮修复和完成条件。已有 Android 构建及启动记录保留,不认定为这些剩余能力已通过。09-A 在本轮保留的 Windows/Linux/Docker 干净构建与启动要求已完成。
@@ -108,6 +109,17 @@
- 临时服务进程已终止并确认退出;工具未确认测试标签关闭,不标记为已关闭。没有接触真实管理配置或用户会话,也没有为了工具限制重写原生确认逻辑。内置浏览器与 Edge 均已留下阻塞证据,后续只在工具状态有明确变化或有人工结果时补验。
- 现有可自动执行的 TS3 媒体节点已有上述结果;剩余真实麦克风/扬声器及屏幕采集、触屏和原生弹窗流程需要可交互环境。旧应用版本矩阵与 TS6 端点仍等待明确。不能用再跑单元测试或合成音频替代这些验收,也不新增无关修复或容量目标。
### 上海 TS6 节点恢复与防刷期间静音恢复修复(2026-10-03)
- 用户确认节点更新后,以当前 SDK 和临时身份连接 `203.0.113.10:9987`,约 290 毫秒取得连接及版本:`6.0.0-beta13.1`、build `1790080330`、Linux,协议识别为 `ts6`;3 个频道、自身目录项存在,探测后正常断开。未修改部署、真实配置或持久身份。
- 首轮快速并行验收触发 `FLOOD_PROTECTION`,同时首个 RTC 上行数量断言未通过,不能据此归因于媒体实现。随后将临时脚本的控制命令间隔调为 1 秒、接入后等待 1.5 秒并串行验收;没有更改服务器防刷设置或音频帧节拍。
- 消息与 PCM 场景通过:目录互见、带 UID 与省略 UID 的双向私聊、离开/返回、测试身份间戳人、非法 PCM 拒绝;双向 PCM 和停止 WebRTC 后 PCM 均收到 50/50 帧,RMS 分别为 1268、1269、1259。全部实际 JSON 消息通过共享解析器。
- WebRTC 使用本机 werift 合成端点和真实 ICE/DTLS/SRTP。上行 50/50 帧到达;反向网关收到并提交 50 帧,队列丢弃和解码错误为 0;输出可解码。麦克风静音阻止音频、静音伴奏及取消静音伴奏各收到 30/30 帧(codec 5);停止伴奏恢复静音,活动 WebRTC 停止后 PCM 收到 50/50 帧。输出 RMS 计数包含编码过渡,不作为交付率。
- 第二次以初始静音加伴奏启动后,停止 WebRTC 未恢复对端可见静音。缩小为连续两次启停后稳定复现:第二次 `setAccompanimentActive(false)` 被服务端拒绝,明确返回 `client is flooding (id=524)`,对端仍显示 `inputMuted=false`。单次启停能正常恢复,故不是 TS6 完全不支持该状态。
- 输入状态队列现在只跳过已经成功确认且有效静音值不变的上报,同时仍记录逻辑麦克风/伴奏变化;连接重建和失败确认使缓存失效。仅对防刷错误增加最多两次重试,分别等待 1 秒、2 秒;每次重试检查原连接及代次,成功确认后才提交状态,权限等其他错误不重试。持续拒绝仍向调用方返回失败,不无限重试或承诺服务器总能接受。
- 新增 4 项回归覆盖相同有效静音值下的逻辑状态、恢复静音时防刷重试、重试上限及后续队列、连接替换后禁止旧重试。统一 427 项测试及前后端构建通过。修改后实服按相同两次启停复查,每次伴奏收到 30/30 帧,停止后对端均显示 `inputMuted=true`,传输返回 WebSocket;全部临时连接清理,活动会话归零。
- 本轮解决了 TS6 测试端点缺失和实际发现的输入状态恢复问题。仍未完成 TS6 原生客户端共享、真实浏览器采集/设备试听、触屏及原生弹窗、指定旧应用版本矩阵;不把本轮合成端点结果扩大为这些项目通过。
## 待修改事项的具体方向
### 04-D 前端媒体与连接编排
+58 -1
View File
@@ -46,7 +46,64 @@ test("accompaniment remains audible with the microphone muted and stopping resto
await f.client.setInputMuted(true);
await f.client.setAccompanimentActive(false);
await f.client.setInputMuted(false);
assert.deepEqual(f.sdk.inputCommands, [1, 0, 0, 1, 0].map(value => `clientupdate client_input_muted=${value}`));
assert.deepEqual(f.sdk.inputCommands, [1, 0, 1, 0].map(value => `clientupdate client_input_muted=${value}`));
});
test("unchanged wire mute still records microphone and accompaniment changes", async () => {
const f = fixture();
await f.client.setInputMuted(false);
await f.client.setAccompanimentActive(true);
await f.client.setInputMuted(true);
await f.client.setAccompanimentActive(false);
assert.deepEqual(f.sdk.inputCommands, ["clientupdate client_input_muted=0", "clientupdate client_input_muted=1"]);
});
test("stopping accompaniment retries flood rejection before committing restored mute", async t => {
const f = fixture();
await f.client.setInputMuted(true);
await f.client.setAccompanimentActive(true);
t.mock.timers.enable({ apis: ["setTimeout"] });
let attempts = 0;
f.sdk.inputUpdate = async () => { if (++attempts === 1) throw new Error("TeamSpeak server error: client is flooding (id=524)"); };
const pending = f.client.setAccompanimentActive(false);
await nextTurn();
assert.equal(attempts, 1);
t.mock.timers.tick(1000);
await pending;
await f.client.setInputMuted(true);
assert.equal(attempts, 2);
assert.deepEqual(f.sdk.inputCommands.slice(-2), ["clientupdate client_input_muted=1", "clientupdate client_input_muted=1"]);
});
test("input flood retries are bounded and a rejected update does not poison later changes", async t => {
const f = fixture();
t.mock.timers.enable({ apis: ["setTimeout"] });
const flooding = new Error("TeamSpeak server error: client is flooding (id=524)");
f.sdk.inputUpdate = async () => { throw flooding; };
const pending = assert.rejects(f.client.setInputMuted(true), error => error === flooding);
await nextTurn();
t.mock.timers.tick(1000);
await nextTurn();
t.mock.timers.tick(2000);
await pending;
assert.equal(f.sdk.inputCommands.length, 3);
f.sdk.inputUpdate = async () => {};
await f.client.setInputMuted(false);
assert.equal(f.sdk.inputCommands.at(-1), "clientupdate client_input_muted=0");
});
test("a flood retry cannot send into a replaced connection", async t => {
const f = fixture();
t.mock.timers.enable({ apis: ["setTimeout"] });
f.sdk.inputUpdate = async () => { throw new Error("TeamSpeak server error: client is flooding (id=524)"); };
const pending = assert.rejects(f.client.setInputMuted(true), /not ready/);
await nextTurn();
await f.client.disconnect();
f.state.client = f.sdk;
f.state.connected = true;
t.mock.timers.tick(1000);
await pending;
assert.equal(f.sdk.inputCommands.length, 1);
});
test("overlapping microphone and accompaniment changes use the last accepted input state", async () => {
+20 -1
View File
@@ -88,6 +88,7 @@ export class TSClient extends EventEmitter {
private connected = false;
private connectionGeneration = 0;
private inputState = { muted: false, accompaniment: false };
private syncedInputMuted: boolean | null = null;
private inputStateQueue: Promise<void> = Promise.resolve();
private preferredChannelId = 0n;
private accelerationClient: AccelerationRelayClient | null = null;
@@ -105,6 +106,7 @@ export class TSClient extends EventEmitter {
async connect(): Promise<void> {
this.connectionGeneration++;
this.inputState = { muted: false, accompaniment: false };
this.syncedInputMuted = null;
this.inputStateQueue = Promise.resolve();
this.selfLeaveReasonId = null;
if (!this.adapter || !this.client) {
@@ -375,10 +377,27 @@ export class TSClient extends EventEmitter {
const update = this.inputStateQueue.then(async () => {
if (!isCurrent()) throw new Error("TeamSpeak session is not ready");
const next = { ...this.inputState, ...change };
const muted = next.muted && !next.accompaniment;
// TeamSpeak discards all audio from an input-muted client, including
// music. The browser removes the microphone from its accompaniment mix.
await client!.execCommand(`clientupdate client_input_muted=${next.muted && !next.accompaniment ? 1 : 0}`);
if (this.syncedInputMuted !== muted) {
for (let attempt = 0; ; attempt++) {
if (!isCurrent()) throw new Error("TeamSpeak session is not ready");
try {
await client!.execCommand(`clientupdate client_input_muted=${muted ? 1 : 0}`);
break;
} catch (error: unknown) {
// A failed acknowledgement cannot justify skipping a later update.
if (isCurrent()) this.syncedInputMuted = null;
if (!isCurrent() || attempt >= 2 || normalizeTeamSpeakError(error).code !== "flooding") throw error;
// In particular, stopping accompaniment must get a chance to
// restore mute after the server's short flood-control window.
await new Promise<void>(resolve => setTimeout(resolve, (attempt + 1) * 1000));
}
}
}
if (!isCurrent()) throw new Error("TeamSpeak session changed while updating input state");
this.syncedInputMuted = muted;
this.inputState = next;
});
this.inputStateQueue = update.catch(() => undefined);