## Problem and outcome Stale ICE and transport callbacks, interrupted media ownership, and optional encoder capabilities could break otherwise recoverable sharing sessions. This maintenance phase corrects those owners across Web, Native and embedded SFU, improves current-state diagnostics, and finishes the affected UI and documentation animation paths. Android, QR invitations and App/Server headline presentation stay on their feature branch. This PR contains the accepted maintenance scope only. ## Release notes **Play together. Your turn!** Approved friends can play together with shared keyboard and mouse controls or optional gamepads. **远程同乐,轮到你啦!** 获准的朋友可以共用键鼠,或使用可选手柄,一起玩本地多人游戏。 ### English This maintenance update improves connection recovery, capture compatibility and troubleshooting for existing Piik rooms. - Keep ICE candidates and gathering completion tied to their current connection. Preserve Viewer route preferences through reconnection and retry newly available Peer opportunities after SFU fallback. - Correct picture and voice ownership during restart, source replacement and connection retirement. Report failed picture dependencies while keeping room voice available. - Separate capture and forwarding statistics and isolate pooled sender attachment failures. - Improve Windows H.264 compatibility with optional encoder properties, retain safe capture failure codes, and keep shared sound volume usable without microphone support. - Improve remote input continuity and mouse responsiveness after idle. - Fix fullscreen handling in some mobile browsers, source-picker refresh, delayed chat confirmations, starred-site startup and local App requests. Refine control motion and reduced-motion behavior. - Restore the mascot's face and shared animation lifecycle in the documentation header. - Include current connection and playback state in diagnostic exports, update Zod to 4.6.6 and simplify shared lifecycle code. Existing 2.x protocols, configuration and default quality settings are preserved. ### 中文 本次维护更新改善现有房间的连接恢复、采集兼容性和故障诊断。 - ICE 候选和收集结束事件跟随当前连接;重连保留观众线路偏好,SFU 兜底后出现新的可用 P2P 机会仍可尝试。 - 修正重启、换源和连接结束时的画面与语音生命周期;语音继续时,画面失败会明确反馈。 - 区分采集与转发统计,隔离编码池中单个输出连接的失败。 - 改善 Windows H.264 可选属性兼容性,保留有效的采集失败原因;没有麦克风能力时也能调整共享声音音量。 - 修复部分移动浏览器全屏、选源刷新、迟到聊天确认、收藏站点启动和本机 App 请求问题,打磨控件动效及减少动态效果行为。 - 修复文档导航 mascot 面部一直隐藏的问题,接回共用动画生命周期。 - 诊断导出补取当前连接与播放状态,升级 Zod 至 4.6.6,精简共用生命周期代码。 沿用现有 2.x 协议、配置和画质默认值。Android、二维码邀请及 App/Server 新增的 HEADLINE 展示留待后续版本。 ## Verification - `npm run check`: type-check, 98 test files / 1,765 tests, production Web build passed. - `npm run check:go-core`: Go formatting, tests, vet, Windows/Linux builds passed; Darwin builds require the native CI runners. - `npm run check:native`: current Windows capture compilation, fixtures and capability probe passed. - `npm run build:website`, TypeScript and repository hygiene checks passed after the documentation-brand fix. - Existing controlled media lifecycle and P2P/SFU voice acceptance covered the retained route/transport changes. Final local browser acceptance covered actual sharing and pause/resume, fullscreen, source refresh, voice/keyboard/settings, 320px to desktop layouts, both themes and all presentation modes. Documentation brand was reproduced broken, then verified on load, replay and reduced motion. - Independent scoped reviews found no integration blocker. ## Impact Patch release v2.4.1. Existing 2.x wire, configuration, authority, capacity and default quality contracts remain intact; no data migration. Source volume no longer depends on microphone availability. Zod 4.6.6 fixes GHSA-mrhx-c7xc-m3w5. The device-specific Windows reports #495 and #452 remain under investigation; this PR improves compatibility and diagnostics without claiming those reports fully resolved. Physical macOS acceptance remains with its native runner/device checks.
7.4 KiB
ADR-0013: Embedded Node-Local Media
- Status: Accepted; physical evidence and release boundaries are owned by status
- Date: 2026-09-07
Context
The owner accepts one self-contained Piik process for the current STUN and SFU services, and one shared encoded-media model for capable Native P2P nodes and the SFU. Bundling or supervising coturn/LiveKit executables does not meet this requirement. The existing product uses coturn only as STUN, not TURN.
The encoding comparison and decode comparison establish real unused-layer cost and codec lifecycle costs, but not complete network/hardware acceptance. Mature simulcast implementations provide the starting model.
Decision
- Every parent, including Host and the SFU, owns only its direct children's media demands. Keep the existing single room authority, committed route graph and serial route operation. Media layer changes are not topology operations.
- Forward a suitable existing encoding. Derive a missing lower output at its direct parent and share that encoded output among compatible children. Do not create an encoder per child. A forwarding-only healthy relay creates no decoder/encoder group just to manufacture unused fallback layers.
- An already-needed encoding group uses a finite highest-demand envelope: produce the highest required output and its lower fallbacks, and stop upper outputs no child needs. This is not a promise of a single Host encode under all conditions. Representation settings come from the chosen media component within Host ceilings, not a new Piik quality score or arbitrary ladder.
- Each child receives only its selected output. Multiple active encodings do not imply sending every output to every child. Preserve the original input, source clock and unaffected siblings. Playback quality, cadence and recovery take priority over reducing the number of encoders.
- Mature media components own bandwidth estimation, rate allocation, pacing, loss recovery and safe switching. The shared group owns representation lifetime and reuse. Do not add a second congestion controller, fine-grained warm cache, whole-tree demand scanner or periodic topology rebalancer.
- The SFU remains one Host publication with one-to-many distribution. For a forwarding SFU, its upstream demand is the maximum required by its direct subscribers; Host combines that demand with its direct P2P children's demand. This requests the highest needed representation, not a sum of encoding counts or a room-wide minimum. The aggregate publication must fit its own upstream congestion budget; requested quality is not a delivery guarantee.
- Shared group code must be reusable by the SFU and Native paths. A future transcoding SFU reports its actual input requirements instead of blindly forwarding every downstream request. Do not require server transcoding or recursive subtree demand to ship a forwarding SFU.
- Embed library-level STUN, preserving Binding and the three NAT-survey destinations without enabling TURN allocations. Embed Pion transport and LiveKit media-core components through the shared forwarding adapter. The library evaluation retains the candidate comparison and selection rationale.
- Pure Browser peers retain normal WebRTC capture/senders and can consume the same H264/VP8 output. No Browser encoded-passthrough promise, new codec family or application transport is introduced by this architecture.
For an SFU that forwards existing layers:
SFU upstream demand = max(SFU direct-subscriber demands)
Host output demand = max(Host direct-P2P demands, SFU upstream demand)
Indirect P2P descendants are not included in either aggregate. Native parents handle their own derivation. Framework estimates must distinguish desired, available and actually delivered output so missing high input cannot be mistaken for a healthy high-quality path.
Consequences And Release Boundary
The Native integration uses one complete stock WebRTC encoding/adaptation pipeline per shared local output. Its source adapter, rate correction, resource feedback and input dropping share that output's lifetime; they are not cloned per consumer behind an encoder cache. The existing Pion/LiveKit transport owns the input bitrate budget and forwarding. Ordinary encoder adaptation preserves the unadapted capture/received original, source timeline and route identity. This refines the implementation boundary, not the direct-child demand model or an acceptance claim. The encoder-pool evidence shows why sharing the codec alone loses reuse or churns under independent drops.
Incompatible direct-child budgets own separate adaptive outputs. Equal effective requests within the same source generation, codec, preference and ceiling may share; dimensions alone are not a compatibility key. Rates update an owned pipeline in place, not by recreating it for every bitrate sample. Membership changes wait for independent recovery, retain existing transport identity and stop the last unused codec slot. The original input is not lowered by a derived group. Physical codec slots are bounded by endpoint admission, not by LiveKit's three spatial-layer labels; each connection sees original plus its assigned adaptive output. SFU publication retains its aggregate allocation separately. No ancestor lookup, extra upstream layer subscription or new congestion policy is introduced.
- One media model can serve Native edges and embedded server forwarding without duplicating room authority. The adapter is not a second room policy.
- Extra low encodes, decoder work, frame copies and publication upload remain real costs. A fixed set of layers does not solve bandwidth below its lowest layer or CPU overload; those cases need framework adaptation and verification.
- An available lowest output owned by a live local rate-controlled codec uses the framework's non-pausing allocation policy at positive budgets; raw relay input and forwarding SFU outputs retain pausing. Cold codec preparation and existing estimation windows still impose transition cost, so eventual recovery does not establish low-bandwidth latency parity.
- Replacing the external SFU changes Browser signaling/media integration and deployment. Cut over one coordinated current contract, delete replaced paths in that boundary, and preserve active-share/rollback rules from CONTRIBUTING.
- Shared Pion/LiveKit media components implement this model; ADR-0007 retains the earlier production/runtime context and its unchanged Browser source/codec decisions. Status indexes published behavior and deployment evidence. Controlled implementation checks do not replace the remaining physical acceptance.
- TODO owns remaining implementation and acceptance. Research owns measurements and library-selection evidence; no production switch is added merely because a probe passes.