fix(app): stabilize sharing startup and align shared controls
## Problem and outcome / 问题与结果 Windows Auto selection could spend its remaining startup budget on a probe that could not finish, recreate hardware after a successful probe, and discard the prepared codec on first relay activation. Preserve the proven encoder through the existing capture owner and keep VP8 fallback unchanged. Correct custom-port STUN survey membership without changing the published Hosted base preference or introducing a second route/retry owner. Reject queued minimize/resize frames that no longer match the current WGC target, replacing the one-shot restoration flag that could end an active H.264 share. Align shared controls, help and appearance across the product and website. macOS audio readiness follows successful platform startup rather than the arrival of non-silent samples. The optional editorial headline is shared with the website, with English-first bilingual release copy. Room voice and multiplayer input implementations remain outside this candidate. Related reports: #437 and #486. Their affected devices still need retesting; this does not establish that all reported driver or macOS failures have been resolved. ## Release notes **Play together. Your turn!** **远程同乐,轮到你啦!** ### English This maintenance update improves sharing startup and brings common controls and guidance into line. Existing 2.x App and Site compatibility is preserved. - Windows Auto reuses the H.264 encoder that passed its frame-rate probe, preserves it on first relay activation, and skips probes that cannot fit the remaining startup budget. Discard stale minimize/resize frames before they can end an active share. - Fix optional NAT survey selection with custom STUN ports while preserving existing Hosted selection. Include the upstream ICE candidate-priority correction. - Make macOS audio readiness follow successful capture startup, so a silent source does not have to produce samples before becoming ready. - Align shared buttons, selectors, keyboard labels and status colours, and refresh the README previews. Preserve explicit theme choices between the website and documentation. - Find the Web version, troubleshooting and browser diagnostics in Help; closing a nested hint keeps the menu actions available. - Put English first in update notes and simplify the website's release section around the same opening headline. ### 中文 这是一次分享启动与界面一致性的维护更新,保留现有 2.x App 和站点的兼容性。 - Windows 自动编码复用通过帧率探测的 H.264 编码器,在首次转发启用时保留该实例,并跳过剩余启动时间不足以完成的探测;丢弃最小化、恢复或缩放窗口时残留的旧尺寸帧,避免它们导致分享结束。 - 修复自定义 STUN 端口下的辅助打洞采样选择,保留已有自部署站点的选择行为,并同步上游 ICE 候选优先级修正。 - macOS 音频在平台确认启动成功后就绪,静默音源无需等待产生音频采样。 - 对齐共享按钮、选择控件、键盘说明与状态颜色,更新 README 界面预览;官网和文档中心之间保留用户明确选择的主题。 - 网页版本、问题排查和浏览器诊断统一收进「帮助」;内部提示关闭后,菜单操作仍然保留。 - 更新说明改为英文在前、中文在后;官网更新区以同一份开篇主题收敛呈现。 ## Verification / 验证 - Local Web type-check, unit tests and production build: passed. - Local Go tests, vet, Windows/Linux builds and Windows native compile/probe: passed. - Website/documentation build, repository hygiene and diff checks: passed. - Seven media-lifecycle cases passed: all Browser/App pairings, SFU-only, and Browser/Native fallback followed by direct recovery; restart, replacement and stale-signal retirement were included. - The first candidate CI exposed an asynchronous allocation-test wait gap. Its correction waits for the committed deficit, retaining the capacity assertion; focused repetition passed locally. - The native Host gate and benchmark now follow the current picture settings and stable codec name/value instead of removed UI structure or localized captions. - Non-publishing CI passed ondd208e83, including Windows, both macOS architectures, both Linux architectures and Server packages. The later Windows frame-admission correction passed the focused native suite, physical Auto/H.264 and manual VP8 window gates, and the H.264 display gate. The window checks include minimized/resize/fullscreen recovery; the display check preserves the same media through profile and source changes. - Final UI review covered narrow/desktop layouts, both themes, header/help, sharing controls, keyboard and interaction panels, packaged Local entry and website/docs preference handoff. The compact release entry passed 320/1280 px checks in both languages and themes, including metadata-request failure. - Final candidatee88cb236: [all-platform packages and the full paired NAT/weak-network comparison](https://github.com/TNTcraftHIM/Piik/actions/runs/39284032227). ## Impact / 影响 No signaling, native-control, capture-envelope or storage version changes. Route authority, consent, capacity and retry lifetimes remain with their existing owners. The CI allocation correction changes the test only, not production media policy. Physical macOS capture/permissions, the affected reporter GPUs and difficult external networks remain evidence limits. The owner authorized v2.2.2 after final acceptance; the non-publishing candidate checks must pass before the publishing squash merge. Room voice remains in its isolated experiment and is not a feature claim for this release.
This commit is contained in:
1 parent
6cb0ca1a34
commit
4bc0fd1e41
89 files changed
+1386
-569
No files matched your search
@@ -1235,20 +1235,58 @@ UINT32 CadenceLagFrames(UINT32 frame_rate) {
|
||||
return std::max<UINT32>(1, (frame_rate + 9) / 10);
|
||||
}
|
||||
|
||||
bool SustainsEncodedCadence(const AdaptiveEncoder::Factory& create, ID3D11Device* device,
|
||||
struct CadenceTiming final {
|
||||
explicit CadenceTiming(const VideoProfile& profile)
|
||||
: warmup_frames((profile.frame_rate + 1) / 2),
|
||||
sample_frames(profile.frame_rate),
|
||||
interval(profile.frame_duration_100ns() * 100) {}
|
||||
|
||||
std::chrono::nanoseconds MinimumDuration() const {
|
||||
// Each phase submits its first frame immediately; the measured phase
|
||||
// starts a fresh schedule after warmup.
|
||||
return interval * (warmup_frames + sample_frames - 2);
|
||||
}
|
||||
|
||||
UINT32 warmup_frames;
|
||||
UINT32 sample_frames;
|
||||
std::chrono::nanoseconds interval;
|
||||
};
|
||||
|
||||
// Only the probe borrows the hardware codec. Destroy its synthetic adaptation
|
||||
// history before the same codec moves into the ordinary live output pipeline.
|
||||
class ProbeEncoder final : public VideoEncoder {
|
||||
public:
|
||||
explicit ProbeEncoder(VideoEncoder& encoder)
|
||||
: VideoEncoder(encoder.kind, encoder.name, encoder.identity), encoder_(encoder) {}
|
||||
|
||||
EncodedAccessUnit Encode(ID3D11Texture2D* texture, UINT64 timestamp, bool key,
|
||||
EncoderClock::time_point deadline) override {
|
||||
return encoder_.Encode(texture, timestamp, key, deadline);
|
||||
}
|
||||
void SetBitrate(UINT32 bitrate) override { encoder_.SetBitrate(bitrate); }
|
||||
|
||||
private:
|
||||
VideoEncoder& encoder_;
|
||||
};
|
||||
|
||||
bool SustainsEncodedCadence(VideoEncoder& hardware, ID3D11Device* device,
|
||||
const VideoProfile& profile, EncoderClock::time_point deadline) {
|
||||
RequireEncoderTime(deadline);
|
||||
const UINT32 warmup_frames = (profile.frame_rate + 1) / 2;
|
||||
const UINT32 sample_frames = profile.frame_rate;
|
||||
const auto [warmup_frames, sample_frames, interval] = CadenceTiming(profile);
|
||||
const UINT32 lag = CadenceLagFrames(profile.frame_rate);
|
||||
// Synthesis is CPU work of the probe, not the encoder; prepare it before pacing.
|
||||
std::array<ComPtr<ID3D11Texture2D>, 8> textures;
|
||||
for (UINT32 index = 0; index < textures.size(); ++index) {
|
||||
textures[index] = CreateSyntheticTexture(device, index * 7, profile);
|
||||
}
|
||||
AdaptiveEncoder encoder(OutputKind::h264, profile, device, create);
|
||||
const auto interval = std::chrono::nanoseconds(
|
||||
static_cast<INT64>(profile.frame_duration_100ns()) * 100);
|
||||
AdaptiveEncoder encoder(OutputKind::h264, profile, device,
|
||||
[&](const VideoProfile& selected) -> std::unique_ptr<VideoEncoder> {
|
||||
if (selected.width != profile.width || selected.height != profile.height ||
|
||||
selected.frame_rate != profile.frame_rate)
|
||||
Fail("codec-probe-output", "encoder changed the probe profile");
|
||||
hardware.SetBitrate(selected.bit_rate);
|
||||
return std::make_unique<ProbeEncoder>(hardware);
|
||||
});
|
||||
auto start = EncoderClock::now();
|
||||
UINT32 delivered = 0;
|
||||
for (UINT32 frame = 0; frame < warmup_frames + sample_frames; ++frame) {
|
||||
@@ -1299,12 +1337,15 @@ void LogEncoderRejection(EncoderCandidate candidate, const GateFailure& error) {
|
||||
// keeps its selected device/encoder; source replacement owns any later change.
|
||||
template <typename Prepare>
|
||||
EncoderCandidate SelectEncoderCandidate(std::vector<EncoderCandidate> candidates,
|
||||
EncoderCandidate preferred, EncoderClock::time_point deadline, Prepare prepare) {
|
||||
EncoderCandidate preferred, EncoderClock::time_point deadline, Prepare prepare,
|
||||
EncoderClock::duration minimum_time = EncoderClock::duration::zero()) {
|
||||
const auto first = std::find(candidates.begin(), candidates.end(), preferred);
|
||||
if (first != candidates.end()) std::rotate(candidates.begin(), first, first + 1);
|
||||
std::exception_ptr failure;
|
||||
for (const auto& candidate : candidates) {
|
||||
RequireEncoderTime(deadline);
|
||||
// Do not enter synchronous device setup for a probe that cannot finish
|
||||
// its required measurement. Preserve the remaining startup time for VP8.
|
||||
RequireEncoderTime(deadline - minimum_time);
|
||||
try {
|
||||
prepare(candidate);
|
||||
RequireEncoderTime(deadline);
|
||||
@@ -1346,25 +1387,21 @@ VideoEncoderSelection SelectVideoEncoder(
|
||||
auto next_device = CreateDevice(adapter);
|
||||
try {
|
||||
const auto encoders = EnumerateHardwareEncoders(adapter);
|
||||
// Retire the Auto probe before preparing the live encoder, so selection
|
||||
// does not require two simultaneous hardware sessions on this device.
|
||||
auto selected = ActivateTransform(encoders, candidate.second, next_device.manager.Get());
|
||||
auto next = std::make_unique<LiveEncoder>(std::move(selected), arguments.profile);
|
||||
if (arguments.codec == "auto" && !SustainsEncodedCadence(
|
||||
[&](const VideoProfile& profile) -> std::unique_ptr<VideoEncoder> {
|
||||
auto activations = EnumerateHardwareEncoders(adapter);
|
||||
return std::make_unique<LiveEncoder>(ActivateTransform(
|
||||
activations, candidate.second, next_device.manager.Get()), profile);
|
||||
},
|
||||
*next,
|
||||
next_device.device.Get(), arguments.profile, deadline)) {
|
||||
Fail("codec-probe-cadence", "hardware H264 did not sustain the target frame rate");
|
||||
}
|
||||
RequireEncoderTime(deadline);
|
||||
auto selected = ActivateTransform(encoders, candidate.second, next_device.manager.Get());
|
||||
auto next = std::make_unique<LiveEncoder>(std::move(selected), arguments.profile);
|
||||
// Enumeration and activation alone do not prove usable H264 output.
|
||||
const auto texture = CreateSyntheticTexture(next_device.device.Get(), 0, arguments.profile);
|
||||
next->Encode(texture.Get(), 0, true, deadline);
|
||||
if (arguments.codec == "h264") {
|
||||
// Explicit H264 validates output without Auto's cadence measurement.
|
||||
const auto texture = CreateSyntheticTexture(next_device.device.Get(), 0, arguments.profile);
|
||||
next->Encode(texture.Get(), 0, true, deadline);
|
||||
}
|
||||
RequireEncoderTime(deadline);
|
||||
device = std::move(next_device);
|
||||
// Keep the proven hardware instance; the probe's VSE is already gone.
|
||||
hardware = std::move(next);
|
||||
} catch (const GateFailure& error) {
|
||||
// Query before destroying this candidate's device: the failing API
|
||||
@@ -1376,7 +1413,8 @@ VideoEncoderSelection SelectVideoEncoder(
|
||||
<< std::setfill('0') << std::setw(8) << static_cast<UINT32>(reason);
|
||||
throw GateFailure(error.stage(), detail.str(), error.result());
|
||||
}
|
||||
});
|
||||
}, arguments.codec == "auto" ? CadenceTiming(arguments.profile).MinimumDuration()
|
||||
: EncoderClock::duration::zero());
|
||||
arguments.adapter_index = chosen.first;
|
||||
arguments.mft_index = chosen.second;
|
||||
return {OutputKind::h264, std::move(hardware)};
|
||||
@@ -1459,7 +1497,6 @@ class OutputWorker final {
|
||||
const auto& input = work.input;
|
||||
if (codec_generation != work.generation) {
|
||||
encoder.reset();
|
||||
initial.reset();
|
||||
converter.reset();
|
||||
codec_generation = work.generation;
|
||||
}
|
||||
@@ -1952,10 +1989,7 @@ void RunVideoCapture(ProductArguments arguments) {
|
||||
const HANDLE window_waits[] = {
|
||||
process.get(), shutdown->get(), frame_ready->get()};
|
||||
const HANDLE display_waits[] = {shutdown->get(), frame_ready->get()};
|
||||
bool source_was_minimized = false;
|
||||
for (;;) {
|
||||
if (window_target && IsIconic(reinterpret_cast<HWND>(
|
||||
static_cast<UINT_PTR>(arguments.source_id)))) source_was_minimized = true;
|
||||
for (const auto& control : controls.Read()) {
|
||||
if (control.kind == 'Q') {
|
||||
cleanup();
|
||||
@@ -2007,21 +2041,12 @@ void RunVideoCapture(ProductArguments arguments) {
|
||||
latest = std::move(next);
|
||||
}
|
||||
if (!latest) continue;
|
||||
// Minimized content is a placeholder, including queued frames after
|
||||
// restoration. Retire that pool generation before admitting pictures.
|
||||
// A minimized window has no capturable picture.
|
||||
if (window_target && IsIconic(reinterpret_cast<HWND>(
|
||||
static_cast<UINT_PTR>(arguments.source_id)))) {
|
||||
source_was_minimized = true;
|
||||
latest.Close();
|
||||
continue;
|
||||
}
|
||||
if (source_was_minimized) {
|
||||
latest.Close();
|
||||
latest = nullptr;
|
||||
pool.Recreate(capture_device, static_cast<DirectXPixelFormat>(pool_format), 2, pool_size);
|
||||
source_was_minimized = false;
|
||||
continue;
|
||||
}
|
||||
INT64 signed_timestamp = latest.SystemRelativeTime().count();
|
||||
if (signed_timestamp <= 0) {
|
||||
Fail("capture-timestamp", "captured frame has no QPC timestamp");
|
||||
@@ -2035,6 +2060,15 @@ void RunVideoCapture(ProductArguments arguments) {
|
||||
}
|
||||
auto content_size = latest.ContentSize();
|
||||
if (content_size.Width <= 0 || content_size.Height <= 0) continue;
|
||||
// ContentSize belongs to the rendered frame; Size belongs to the current
|
||||
// target. Queued minimize/resize frames must not reconfigure the encoder
|
||||
// after the target has already changed again.
|
||||
const auto target_size = item.Size();
|
||||
if (content_size.Width != target_size.Width ||
|
||||
content_size.Height != target_size.Height) {
|
||||
latest.Close();
|
||||
continue;
|
||||
}
|
||||
const auto color = display_color.Resolve();
|
||||
if (content_size.Width != pool_size.Width ||
|
||||
content_size.Height != pool_size.Height || color.Format() != pool_format) {
|
||||
|
||||
Reference in new issue
Block a user