Files
piik/docs/project-memory.md
T
AAA 72ca6f2bc9 fix(media): improve sharing recovery and mobile picture controls
Windows capture-device errors could end an otherwise recoverable share, and reused Browser frames could arrive with the wrong orientation on receivers without the same orientation extension. Recover through the existing capture generation, start new encoded generations with an independent frame, and normalize orientation before shared encoding.

The maintenance scope also keeps compact headers aligned, cycles local rotation through four directions, accepts late coordinated UDP replies, requests Browser own-audio exclusion, and improves capture/input diagnostics. It preserves the published 2.x protocol and storage contracts.

Validation: 106 test files / 1878 tests, TypeScript, production Web/website builds, Windows Go core tests/vet and supported cross-builds passed. Candidate CI passed all 3 Server and 6 App targets, including native macOS builds, plus vulnerability and race checks. Controlled WGC/Pion recovery, retained-clock/first-frame checks, Browser orientation/SFU playback and responsive-header checks passed. The downloaded candidate set passed the existing publication dry-run: all 9 targets and 10 distribution packages share v2.5.2 and source 916baefa05, with matching checksums.

Original-device investigations remain open, including #502 and the reported low source frame rate. This PR does not claim those reports are resolved.

## Release notes

**Piik, now in your pocket.**

Piik App supports Android screen sharing, with touch controls for a friend's computer.

**手机,也能开播。**

Piik App 支持 Android 屏幕分享,也能用手机控制朋友的电脑。

### English

Piik v2.5.2 improves sharing recovery, picture orientation and mobile controls. It keeps the existing 2.x compatibility baseline.

- Improve Windows sharing recovery after graphics-device errors, and resume new encoder generations with a decodable picture.
- Preserve rotated and mirrored pictures when Browser encoding is shared across receivers, including SFU routes.
- Rotate the local picture in 90° steps; keep mobile header controls aligned and its connection indicator visible.
- Improve P2P establishment when coordinated UDP replies arrive late.
- Ask compatible browsers to exclude Piik's own playback from screen audio, and improve native capture and remote-input diagnostics.

Update the App and self-hosted site together to receive all fixes, then refresh open pages. Browser settings and existing room data are retained.

### 中文

Piik v2.5.2 改善分享恢复、画面方向与手机操作,沿用现有 2.x 兼容基线。

- 改善 Windows 图形设备异常后的分享恢复,新编码器接替时从可正常解码的画面开始。
- 修正浏览器共享编码时旋转或镜像画面的方向,覆盖 SFU 等接收线路。
- 本机画面每次旋转 90°;手机顶部工具栏保持对齐,连接状态清晰可见。
- 改善协同打洞时 UDP 回复较晚到达的 P2P 建连。
- 向支持的浏览器请求排除 Piik 页面自身播放的声音,并完善原生采集与远控输入的诊断信息。

请一起更新 App 与自部署站点,以获得全部修复,随后刷新已打开的页面。浏览器设置与已有房间数据保留。
2026-11-01 12:00:26 -04:00

7.6 KiB

Project Memory

Last updated: 2026-10-26

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. Browser hosting uses the capture capabilities available on the device. It is not a public broadcast service. Hosted and App run one shared Go core (ADR-0012); Node and Vite build the Browser UI and are not a runtime. Desktop and Android Apps run that same core in a self-contained Local deployment or supply native capability to explicitly approved Sites through the system Browser and shared Web UI. Each App's 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 desktop 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 owns room codes, invitations, code entry, credentials, room interactions and lightweight/SQLite persistence.
  • Routing and transport owns P2P-first distribution, endpoint capacity, SFU fallback, recovery, and privacy limits.
  • Capture and media quality owns Browser capture, profiles, codec selection, audio, and framework adaptation.
  • Presentation and lifecycle owns Host and Viewer workflows, playback authority, roster, state, and Browser lifecycle.

ADRs own architecture decisions; research owns measurements and platform limits. Engineering maps and 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. 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 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 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. Embedded SFU SDP/ICE and demand use the authenticated room WebSocket. Deployment owns rollback with matching Browser and App artifacts.

Unfinished work is owned by the TODO ledger. Status indexes delivery; verification status summarizes evidence boundaries. Configuration and self-hosting own environment and services. Release descriptors and deployment records own exact deployed identity; Git and pull requests own completed history.