Files
piik/docs/project-memory.md
T
AAA 066e218d84 fix(media): improve connection recovery and capture compatibility (#498)
## 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.
2026-10-24 12:30:39 -04:00

124 lines
7.6 KiB
Markdown

# Project Memory
Last updated: 2026-10-24
Piik is private, low-latency screen sharing for one Host and up to 20
authenticated friends. The current product surface is Web Host, Web Viewer, and
Browser relay; desktop and mobile Browsers are Viewer targets, and camera-capable
mobile Browsers can also host. It is not a
public broadcast service. Hosted and App run one shared Go core
([ADR-0012](./adr/0012-shared-go-backend-core.md)); Node and Vite build the
Browser UI and are not a runtime. Source includes a cross-platform App that
runs that same core in a self-contained Local deployment or supplies native
capability to explicitly approved Sites through the system Browser. Its single Go
process starts the loopback capability service before room selection. The
persistent launcher offers Local and temporary public-link choices and manages
per-Site local approval and one starred startup Site. Site use can remain on
standby without a Local room service; native media still belongs to the participant's Web UI.
Room source and media implementation are independent: a topology may mix
Browser and Native peers without changing participant, signaling, capacity, or
route identity. Local is LAN-first; explicit one-link mode exposes that same
authority through a temporary public control tunnel while media remains P2P.
Host authority belongs to a tab, with one separate persistent origin resume
hint. The App admits two independent native control sessions under its one
loopback service.
The Hosted Go process embeds Binding-only STUN and optional SFU forwarding.
Native and SFU use one shared Pion/LiveKit media adapter. Native parents reuse
encoded outputs and derive missing lower outputs from direct-child demand;
adaptation preserves the source and higher sibling outputs. Eligible Browser
capture and relay share local WebRTC producers under ADR-0014, with ordinary
senders as fallback. Platform producers share the encoded-frame boundary and
Host quality controls. Source replacement preserves route and connection identity.
## Product Map
- [Rooms and access](./standards/rooms-access.md) owns room codes,
invitations, code entry, credentials, room interactions and lightweight/SQLite
persistence.
- [Routing and transport](./standards/routing-transport.md) owns P2P-first
distribution, endpoint capacity, SFU fallback, recovery, and privacy limits.
- [Capture and media quality](./standards/media-quality.md) owns Browser capture,
profiles, codec selection, audio, and framework adaptation.
- [Presentation and lifecycle](./standards/presentation-lifecycle.md) owns Host and
Viewer workflows, playback authority, roster, state, and Browser lifecycle.
[ADRs](./adr/) own architecture decisions; [research](./research/) owns measurements
and platform limits.
[Engineering maps and source index](./standards/engineering.md#source-index)
locate implementation owners and their module, interface and lifecycle boundaries.
## Core Invariants
- Rooms use random four-digit codes, exact Host ownership, room-scoped Viewer
invitations and independent `open | private` code entry. Room authority ends
through replacement/deletion, with separate invitation rotation or revocation.
Hosted operators may opt into empty-room expiry and capacity reclamation;
the default retains rooms indefinitely. Hosted defaults to SQLite, with explicit
process-memory opt-out; App Local remains process-only, with an optional site-access
password. Site access has a separate 24-hour idle
cookie lifetime within one service run. Production persists SQLite room
authority; live participants, routes, and media remain process-only.
- Media is automatic and distributed. Ordinary peers are STUN-only and prefer
direct/peer UDP. A deployment may enable same-host auxiliary STUN for bounded,
room-wide, connection-local NAT prediction; current pages use it automatically
when available, and anonymous provenance distinguishes ordinary from predicted
selected paths. The configuration default remains stock ICE. The only
application fallback is one bounded embedded SFU/UDP
publication; Piik configures no TURN or TCP media route. Hosted operators may
require SFU-only media through the same controller. On P2P-first sites, a
pre-share peer-only policy can exclude that SFU suffix for one share generation.
- Ordinary endpoints share one steady outbound-copy cap, default `2` and limited to
`1..3`; the explicit relay volunteer uses the
[capacity owner](./standards/routing-transport.md#endpoint-and-server-capacity).
One room controller owns one committed graph, one reconcile loop, and
one serial child operation. First decoded frame commits picture availability work;
accepted quality work adds native edge proof before commit in that operation.
- Browser WebRTC and the shared Pion/LiveKit media adapter own congestion control,
media adaptation, pacing and layer selection. Parent demand is local to direct
children and never a room-wide minimum or topology rebalance. Current source
defaults persistent native-edge local P2P convergence on, with a pre-share
Host opt-out. SFU quality work is limited to multi-root Host fanout relief;
each Viewer must prove candidate non-regression before commit. One bounded
same-parent regeneration may repair a persistently limited edge through
that same operation; the [routing owner](./standards/routing-transport.md)
defines its eligibility and damping.
No weighted score, all-pairs probe, general parent-wide prediction, or
periodic rebalance is accepted.
- Browser video uses `motion`; each share chooses H.264 with VP8 fallback through
an actual sender probe unless the Host explicitly selects VP8 or H264. Screen
audio retains its compact presets and 128 kbps default. The 2.0 contract
separates numeric bitrate requests from those UI shortcuts; implementation
limits and admission remain in the media-quality owner.
- Viewer playback uses one native video element. Presentation and recovery are
fenced by current route/media identity and current-frame proof; hidden-page
time alone is not media-failure evidence or a keepalive guarantee.
## Current Snapshot
Room voice shares room authority and one route controller with picture sharing.
Picture generations and explicitly joined voice publications have separate
lifetimes. Optional source commentary belongs to the share and runs independently
of room voice. [Room media](./standards/routing-transport.md#room-media) owns
these lifecycles.
Optional attended input follows the committed media route back to the native
Host. One grant covers keyboard/mouse and an optional gamepad. Control starts
with one grantee; the Host may allow simultaneous approved Viewers for that source.
Older published clients retain exclusive keyboard/mouse control. Source change, stop
and revocation retire the affected grants. It adds no separate connection planner
or listener.
Viewer playback preferences and the combined interaction window remain local
presentation owners under the existing 2.x compatibility boundary.
The current contract tuple is owned by [status](./status.md#accepted-release-contract).
Embedded SFU SDP/ICE and demand use the authenticated room WebSocket.
[Deployment](./deployment.md) owns rollback with matching Browser and App artifacts.
Unfinished work is owned by the [TODO ledger](./todo.md).
[Status](./status.md) indexes delivery; [verification status](./verification-status.md)
summarizes evidence boundaries. [Configuration](./standards/configuration.md)
and [self-hosting](./operations/self-hosting.md) own environment and services.
Release descriptors and deployment records own exact deployed identity;
Git and pull requests own completed history.