This maintenance phase corrects connection and media recovery after startup deadlines, congestion and packet loss. Route selection remains a bounded operation; Pion and LiveKit continue to own congestion control, adaptation and retransmission. Changes stay within existing owners: - Preserve an untried SFU fallback when a connected P2P candidate produces no first frame before its deadline. Retire expired native preparations using the current edge identity. - Correct paced output, probe accounting and partial-recovery demand. Negotiate RTX consistently for native forwarding and SFU publication, including repaired stream identifiers for simulcast. - Return working IPv4 mappings without waiting for optional IPv6 work, and separate NAT observations by the local socket/address that produced them. - Keep optional App availability separate from basic source selection; stabilize nickname/chat layouts and restore volume from zero correctly. - Retry complete Gitee reads, including response bodies and hash verification. Ambiguous uploads remain single attempts and are reconciled against the remote inventory before rerunning. Related: #468, #464, #471. The repairs affect paths discussed in these reports; incomplete field diagnostics do not establish that each report has the same cause, so this PR does not automatically close them. ## Validation - Web type checks, production build and 1,624 tests passed. Go core, formatting, vet and local target builds passed. - Delayed RTX recovery reproduced the defect before the fix; the repaired-SSRC mutation also fails the focused regression. Real Windows H.264 and VP8 capture passed the SFU gates, including settings, reload recovery and retirement. - The media lifecycle gate passed all 14 trials across Browser/App pairings and P2P/SFU handoffs. Native connectivity, paced forwarding and negative-control checks passed. - Responsive UI and current website architecture links were checked; Gitee's current release was independently downloaded and matched against the GitHub originals. - [Platform candidate](https://github.com/TNTcraftHIM/Piik/actions/runs/38669095115): all five Apps, both Server architectures and container checks passed at `c534573b`. Subsequent tracked changes only update documentation, the complete-matrix CI budget and race-test coverage. - [Full network comparison](https://github.com/TNTcraftHIM/Piik/actions/runs/38667624364) completed 70 trials before the batch's 45-minute limit. The [remaining scenario](https://github.com/TNTcraftHIM/Piik/actions/runs/38672805155) passed three paired repetitions; all 71 scenario/setting variants are covered, with 58 media and 13 expected/observed unavailable outcomes. Six negative controls passed, and owned resources were cleaned up. These are controlled observations, not a public success rate. - The final validation also includes the shared forwarder under the Go race detector. The separate sole-active-output publication experiment still shows inconsistent recovery: two of four current-code repeats did not pass its recovery observation, so the limitation below remains open. The native SFU allocator still has a measured recovery limitation when only its lowest rate-controlled encoding is active. Fixing that requires a supported upstream demand input; no second controller or allocator fork is introduced. Unmatched capture-failure reports and physical-platform coverage retain their documented evidence limits. ## Release notes ### 中文 这是一次连接与播放稳定性更新,重点改善重连、弱网后的画质恢复和下载镜像可靠性。与 Piik 2.0.0 保持兼容。 - 修复连接等待超时后过早跳过备用线路的问题,保留尚未尝试的媒体服务器兜底机会。 - 改善原生分享在网络拥塞后的画质恢复,并修复转发和媒体服务器发布链路上的视频重传协商遗漏。 - 修复原生观看准备超时后的清理与重试,以及音量从零恢复时的异常。 - 避免可选的 IPv6 端口映射拖慢 IPv4 准备,并修正多网卡环境下的 NAT 预测观测归属。 - 修复昵称编辑、聊天字数变化引起的布局移动;保持 App 提示简洁,并为更新提示补充官网备用下载入口。 - 修复 Gitee 镜像同步在传输中途断开时未重试的问题,校验通过后才完成镜像发布。 仍在跟进:部分原生媒体服务器链路的弱网后恢复仍可能偏慢;尚缺匹配诊断的采集失败反馈不能确认已解决。 ### English This maintenance update improves connection and playback recovery after interruptions and congestion, along with download-mirror reliability. It remains compatible with Piik 2.0.0. - Preserve untried media-server fallback routes when a connection reaches its waiting deadline. - Improve native sharing quality recovery after congestion and fix missing video retransmission negotiation in forwarding and media-server publication paths. - Correct cleanup and retry after native viewing preparation expires, and restore playback volume correctly from zero. - Prevent optional IPv6 port mapping from delaying IPv4 preparation, and associate NAT-prediction observations with the correct local interface. - Stabilize nickname editing and chat counters, keep App guidance unobtrusive, and add the website's alternate downloads to update notices. - Retry interrupted Gitee mirror transfers and complete publication only after verification succeeds. Still under investigation: recovery after congestion can remain slow on some native media-server paths. Capture-failure reports without matching diagnostics are not claimed as resolved.
234 lines
9.1 KiB
JavaScript
234 lines
9.1 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import { spawnSync } from "node:child_process";
|
|
import {
|
|
existsSync,
|
|
mkdirSync,
|
|
realpathSync,
|
|
} from "node:fs";
|
|
import { basename, dirname, join, resolve } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
import { APP_PACKAGE_TARGETS, goBuildEnvironment } from "./app-package-targets.mjs";
|
|
import { SERVER_PACKAGE_TARGETS } from "./server-package-targets.mjs";
|
|
|
|
// Every Go command embeds the Vite output, so the build, vet and test steps all
|
|
// fail without it. The Server binary is cross-built for its deployment target.
|
|
const WEB_INDEX = join("internal", "server", "webassets", "dist", "index.html");
|
|
// Local dependency repairs retain upstream tests, including PCPv6 composition.
|
|
// Nested modules need explicit test patterns; remove these with the replacements.
|
|
// Go source lives here; ./... would also scan downloaded SDKs and build probes.
|
|
const GO_TEST_PACKAGES = ["./cmd/...", "./internal/...", "github.com/netbirdio/go-nat/...", "github.com/jackpal/go-nat-pmp"];
|
|
|
|
const root = realpathSync(resolve(dirname(fileURLToPath(import.meta.url)), ".."));
|
|
const captureRoot = join(root, "native", "capture");
|
|
const mode = process.argv[2] ?? "--all";
|
|
|
|
if (!["--all", "--core", "--capture-only", "--race"].includes(mode)) {
|
|
throw new Error("Usage: node scripts/check-go.mjs [--all|--core|--capture-only|--race]");
|
|
}
|
|
|
|
function run(command, args, options = {}) {
|
|
const result = spawnSync(command, args, {
|
|
cwd: options.cwd ?? root,
|
|
env: options.env ?? process.env,
|
|
encoding: "utf8",
|
|
stdio: options.capture ? ["ignore", "pipe", "pipe"] : "inherit",
|
|
});
|
|
if (result.error) throw result.error;
|
|
if (result.status !== 0) {
|
|
const detail = options.capture
|
|
? [result.stdout, result.stderr].filter(Boolean).join("\n").trim()
|
|
: "";
|
|
throw new Error(`${basename(command)} failed${detail ? `: ${detail}` : ""}`);
|
|
}
|
|
return options.capture ? result.stdout.trim() : "";
|
|
}
|
|
|
|
function buildWebAssets() {
|
|
if (existsSync(join(root, WEB_INDEX))) return;
|
|
if (process.platform === "win32") {
|
|
run(process.env.ComSpec || "cmd.exe", ["/d", "/s", "/c", "npm run build:web"]);
|
|
return;
|
|
}
|
|
run("npm", ["run", "build:web"]);
|
|
}
|
|
|
|
function checkCore() {
|
|
buildWebAssets();
|
|
const go = process.env.PIIK_GO?.trim() || "go";
|
|
const goRoot = run(go, ["env", "GOROOT"], { capture: true });
|
|
const gofmt = process.env.PIIK_GOFMT?.trim() ||
|
|
join(goRoot, "bin", process.platform === "win32" ? "gofmt.exe" : "gofmt");
|
|
const unformatted = run(gofmt, ["-l", "cmd", "internal"], { capture: true });
|
|
if (unformatted) {
|
|
throw new Error(`Go source is not formatted:\n${unformatted}`);
|
|
}
|
|
runGoTests(go);
|
|
run(go, ["vet", ...GO_TEST_PACKAGES]);
|
|
|
|
const buildRoot = join(root, "build", "go-check");
|
|
mkdirSync(buildRoot, { recursive: true });
|
|
const buildTargets = APP_PACKAGE_TARGETS.filter((target) => {
|
|
if (target.cgo && process.platform !== target.nodePlatform) {
|
|
process.stderr.write(`Skipped ${target.id}: its cgo dependencies require a native macOS runner and SDK; Darwin acceptance remains pending.\n`);
|
|
return false;
|
|
}
|
|
return true;
|
|
});
|
|
const builds = buildTargets.flatMap((target) =>
|
|
["piik-app", "piik-peer-gate"].map((command) => ({ target, command })),
|
|
);
|
|
builds.push(...SERVER_PACKAGE_TARGETS.map(target => ({
|
|
target: { ...target, id: `linux-${target.goarch}`, cgo: false }, command: "piik-server",
|
|
})));
|
|
for (const { target, command } of builds) {
|
|
const outputName = target.goos === "windows"
|
|
? `${command}.exe`
|
|
: `${command}-${target.id}`;
|
|
run(go, ["build", "-trimpath", "-o", join(buildRoot, outputName), `./cmd/${command}`], {
|
|
env: goBuildEnvironment(target),
|
|
});
|
|
}
|
|
}
|
|
|
|
function runGoTests(go, packagesToTest = GO_TEST_PACKAGES, flags = []) {
|
|
if (process.platform !== "win32") {
|
|
run(go, ["test", ...flags, ...packagesToTest.filter((entry) => entry.startsWith("./"))]);
|
|
// PCP and NAT-PMP both require port 5351. Serialize only their fixture
|
|
// packages, keeping ordinary Piik tests parallel and using portable loopback.
|
|
run(go, ["test", ...flags, "-p=1", ...packagesToTest.filter((entry) => !entry.startsWith("./"))]);
|
|
return;
|
|
}
|
|
|
|
// Windows firewall permissions follow executable paths, including tests that
|
|
// open sockets indirectly. Never execute a test from Go's temporary directory.
|
|
const packages = run(go, ["list", "-f", '{{if or .TestGoFiles .XTestGoFiles}}[{{printf "%q" .ImportPath}},{{printf "%q" .Dir}}]{{end}}', ...packagesToTest], { capture: true })
|
|
.split(/\r?\n/)
|
|
.map((value) => value.trim())
|
|
.filter(Boolean)
|
|
.map((value) => JSON.parse(value));
|
|
const stableRoot = join(root, "build", "go-check");
|
|
mkdirSync(stableRoot, { recursive: true });
|
|
for (const [entry, directory] of packages) {
|
|
const binary = join(stableRoot, `${basename(entry)}.test.exe`);
|
|
run(go, ["test", ...flags, "-c", "-o", binary, entry]);
|
|
run(binary, flags.includes("-race") ? ["-test.timeout=2m"] : [], { cwd: directory });
|
|
}
|
|
}
|
|
|
|
function checkPlatformCapture() {
|
|
if (!["win32", "darwin", "linux"].includes(process.platform)) {
|
|
if (mode === "--capture-only") {
|
|
throw new Error("No native capture check exists for this platform");
|
|
}
|
|
return;
|
|
}
|
|
const buildRoot = join(root, "build", "go-check");
|
|
mkdirSync(buildRoot, { recursive: true });
|
|
let executable;
|
|
if (process.platform === "win32") {
|
|
const systemPowerShell = join(
|
|
process.env.SystemRoot || "C:\\Windows",
|
|
"System32",
|
|
"WindowsPowerShell",
|
|
"v1.0",
|
|
"powershell.exe",
|
|
);
|
|
const modernPowerShell = join(
|
|
process.env.ProgramFiles || "C:\\Program Files",
|
|
"PowerShell",
|
|
"7",
|
|
"pwsh.exe",
|
|
);
|
|
const powershell = process.env.PIIK_POWERSHELL?.trim() ||
|
|
(existsSync(modernPowerShell)
|
|
? modernPowerShell
|
|
: (existsSync(systemPowerShell) ? systemPowerShell : "pwsh"));
|
|
run(powershell, [
|
|
"-NoProfile",
|
|
"-ExecutionPolicy",
|
|
"Bypass",
|
|
"-File",
|
|
join(captureRoot, "windows", "build.ps1"),
|
|
"-OutputDirectory",
|
|
buildRoot,
|
|
"-Check",
|
|
]);
|
|
executable = join(buildRoot, "piik-capture.exe");
|
|
} else if (process.platform === "darwin") {
|
|
run("sh", [join(captureRoot, "darwin", "build.sh"), buildRoot]);
|
|
executable = join(buildRoot, "piik-capture");
|
|
} else {
|
|
run("sh", [join(captureRoot, "linux", "build.sh"), buildRoot, "--check"]);
|
|
executable = join(buildRoot, "piik-capture");
|
|
}
|
|
if (!existsSync(executable)) {
|
|
throw new Error("Native capture build did not produce its executable");
|
|
}
|
|
const raw = run(executable, ["--probe"], { capture: true });
|
|
const probe = JSON.parse(raw);
|
|
const expectedPlatform = process.platform === "win32" ? "windows" : process.platform;
|
|
if (
|
|
probe?.protocol !== 7 ||
|
|
probe.platform !== expectedPlatform ||
|
|
typeof probe.platformBuild !== "string" ||
|
|
typeof probe.videoCapture !== "boolean" ||
|
|
typeof probe.softwareVP8 !== "boolean" ||
|
|
typeof probe.processAudio !== "boolean" ||
|
|
typeof probe.systemAudio !== "boolean" ||
|
|
!Array.isArray(probe.adapters) ||
|
|
probe.adapters.some((adapter) =>
|
|
!Number.isInteger(adapter?.index) ||
|
|
typeof adapter?.name !== "string" ||
|
|
typeof adapter?.identity !== "string" ||
|
|
!Array.isArray(adapter?.hardwareH264) ||
|
|
adapter.hardwareH264.some((encoder) =>
|
|
!Number.isInteger(encoder?.index) ||
|
|
typeof encoder?.name !== "string" ||
|
|
typeof encoder?.identity !== "string"
|
|
)
|
|
)
|
|
) {
|
|
throw new Error("Native capture probe returned an invalid contract");
|
|
}
|
|
if (process.platform === "darwin") {
|
|
run(executable, ["--geometry-self-test"]);
|
|
if (probe.adapters.some(adapter => adapter.hardwareH264.length > 0)) {
|
|
run(executable, ["--self-test"]);
|
|
} else {
|
|
process.stderr.write("Skipped VideoToolbox frame self-test: this machine exposes no usable hardware H.264 encoder; physical capture acceptance remains pending.\n");
|
|
}
|
|
}
|
|
const sources = JSON.parse(run(executable, ["--list"], { capture: true }));
|
|
if (!Array.isArray(sources) || sources.some((target) =>
|
|
!["window", "display", "picker"].includes(target?.kind) ||
|
|
!/^[1-9][0-9]{0,19}$/.test(target?.sourceId) ||
|
|
typeof target?.title !== "string" ||
|
|
(target.kind === "window" &&
|
|
(!Number.isInteger(target?.pid) ||
|
|
!/^[1-9][0-9]{0,19}$/.test(target?.creationTime))) ||
|
|
(target.kind === "display" &&
|
|
(target?.pid !== undefined || target?.creationTime !== undefined)) ||
|
|
(target.kind === "picker" &&
|
|
(target?.pid !== undefined || target?.creationTime !== undefined))
|
|
)) {
|
|
throw new Error("Native capture process returned an invalid source list");
|
|
}
|
|
}
|
|
|
|
if (mode === "--race") {
|
|
buildWebAssets();
|
|
runGoTests(process.env.PIIK_GO?.trim() || "go", [
|
|
"./internal/app/portmapping", "./internal/app/mediaedge",
|
|
"./internal/app/nativecontrol", "./internal/app/loopback",
|
|
"./internal/media/forwarding",
|
|
"./internal/server/app",
|
|
"github.com/netbirdio/go-nat/...", "github.com/jackpal/go-nat-pmp",
|
|
], ["-race", "-count=1", "-timeout=2m"]);
|
|
} else {
|
|
if (mode !== "--capture-only") checkCore();
|
|
if (mode !== "--core") checkPlatformCapture();
|
|
}
|
|
process.stdout.write("Piik checks passed.\n");
|