perf(screens): track remaining startup, relay/NAT, and low-latency decode optimizations

Open
#8,366 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
12/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active

Research direction

This is an umbrella tracking issue spanning the whole remote screen stack, not a single change — pick one bullet and split it out before touching code. Start by reading station/src/screens/win-desktop.ts (#start) or station/src/screens/desktop.ts (open()/refresh) if you take the cold-start items, cloud/src/relay-worker.ts for the relay path, or station/src/mesh/screens.ts for the KIND.input/KIND.ack/KIND.setClipboard stream split. Each item names its current behaviour and a proposal; done means the described latency gap is measurably closed and validated on a real link, which needs profiling access most newcomers will not have.

Written by the indexing model from the issue text.

Description

After auditing the current remote screen stack on main (95f976d6c3), several major latency improvements have already landed recently—including QUIC datagrams with adaptive RS-FEC and zero-JSI pointer tap (#7422), link-aware initial bitrate, moving-screen sharpening, and binary cursor frames (#7402), Opus system audio with 1-back RED (#6481, #6497, #7422), macOS single-window capture, full-chroma 4:4:4, and noq-proto BBR fixes (noq#852, noq#802).

This tracking issue collects the remaining startup, transport, and decode latency gaps verified on 95f976d6c3 so they can be evaluated and split into focused PRs:

1. First-frame & cold-start latency
  • Keep Windows stillfail-screen.exe as a persistent daemon
    • Current: station/src/screens/win-desktop.ts (#start) spawns a new stillfail-screen.exe view subprocess for every view, re-initializing COM, D3D11, Windows.Graphics.Capture, and Media Foundation hardware encoders on each open/reconnect.
    • Proposal: Mirror the persistent macOS still.fail Helper daemon model so GPU and capture contexts stay warm across view opens and reconnects.
  • Avoid blocking permission refresh and cold encoder setup on macOS
    • Current: station/src/screens/desktop.ts blocks open() on await this.refresh(true) every time, and station/native/helper/Sources/StillfailHelper/ScreenView.swift cold-creates VTCompressionSession per view.
    • Proposal: Use a short TTL cache for permission status (start the stream optimistically and refresh/prompt only on failure), and consider pooling/pre-warming VTCompressionSession to cut first-frame and resolution-switch stalls.
  • Hot-switch control, quality, and fps in-stream instead of reopening
    • Current: client/core-ts/src/screens.ts triggers reopen on control() and bounds() changes, tearing down and recreating the view stream, capture pipeline, and encoder.
    • Proposal: Apply control, quality, and fps changes via in-stream control frames (similar to look and rate) to avoid reconnect glitches and cold starts.
  • Optional local encrypted last-frame placeholder on clients
    • Current: apps/mbui/src/sfpages/screen.mbt keeps the last frame in memory across background/foreground transitions, but reopening a closed screen waits for stream setup and the first decoded frame.
    • Proposal: Optionally cache an encrypted local thumbnail of each screen's latest frame (keyed in Apple Keychain / Android Keystore, device-only, never uploaded, toggleable with TTL eviction) to show immediately on tap and fade out once the first live frame renders.
2. Transport, NAT traversal & relay tail latency
  • Evaluate promoting the fixed BBR3 congestion controller to default (or for screen views)
    • Current: station/native/mesh/src/lib.rs already builds noq-proto with fixes for n0-computer/noq#852 (idle max_bw collapse), noq#802 (initial startup pacing rate), and loss_thresh(0.30), yet defaults to cubic, which halves congestion window on random packet loss.
    • Proposal: Benchmark and validate the patched BBR3 on real WAN/cross-border links and evaluate making it the default (or enabling it for screen traffic).
  • Add a UDP relay path alongside WebSocket fallback
    • Current: cloud/src/relay-worker.ts only accepts WebSocket (TCP) upgrades. Whenever P2P hole-punching falls back to relay, #7422's QUIC datagrams + RS-FEC are encapsulated over TCP WebSockets, reintroducing TCP-over-TCP recovery and high tail latency under packet loss.
    • Proposal: Support a UDP relay transport with automatic fallback to WebSocket where UDP 443 is blocked.
  • Bind physical interfaces / exclude VPN & TUN adapters for direct probing
    • Current: Many developer machines run always-on TUN/VPN proxies (e.g., Clash, Surge, Mihomo), which frequently intercept UDP hole-punching probes and force traffic onto relays.
    • Proposal: Support excluding virtual TUN/VPN adapters and probing/binding physical network interfaces in station/native/mesh and mobile direct discovery to raise LAN and WAN P2P success rates.
3. Decode, input isolation & host frame path
  • Broaden Android MediaCodec low-latency vendor keys and operating rate
    • Current: libs/ui/android/app/src/main/java/dev/mbui/Streams.java sets Qualcomm vendor keys (vendor.qti-ext-dec-picture-order.enable, vendor.qti-ext-dec-low-latency.enable) for c2.qti.* / OMX.qcom.*, but does not configure HiSilicon (vendor.hisi-ext-low-latency-video-dec.*), generic/MTK low-latency keys (vendor.rtc-ext-dec-low-latency.enable, vendor.low-latency.enable), or MediaFormat.KEY_OPERATING_RATE.
    • Proposal: Add vendor-gated low-latency keys and KEY_OPERATING_RATE on supported API levels / codecs.
  • Isolate large clipboard transfers from input / ack
    • Current: In station/src/mesh/screens.ts, KIND.input (16), KIND.ack (17), and KIND.setClipboard (19, up to 8 MB PNG) share the same ordered stream, so pasting a large image can briefly block input events and frame ACKs.
    • Proposal: Move large clipboard payloads off the control stream, or give input / ack a dedicated high-priority stream (and/or datagrams for high-frequency pointer moves).
  • Shorten host frame forwarding path & evaluate 144 fps
    • Current: On the TS station path, encoded frames traverse Helper / stillfail-screen → Unix socket/pipe → Node.js Buffer → N-API → Rust mesh.node (where screen-pace.ts LoopStall has observed 40–140 ms Node event-loop stalls); FPS_CHOICES / MAX_FPS caps at 120 fps.
    • Proposal: As the native/MoonBit station matures, consider forwarding media frames more directly between the capture helper and the Rust mesh transport to eliminate extra copies and event-loop jitter, and evaluate adding a 144 fps tier for direct high-refresh displays.
Dominant language
MoonBit
Stars
68
Forks
22
Avg merge
1h 52m
Merged PRs (30d)
934

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AFK-surf/monoid

All issues in AFK-surf/monoid

Similar issues

More Networking issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.