Skip to content

Reduce shared controller and reader resource use without lowering update cadence - #5

Merged
FedyaLight merged 2 commits into
mainfrom
perf/resource-efficiency
Oct 11, 2026
Merged

FedyaLight merged 2 commits into
mainfrom
perf/resource-efficiency

Conversation

@FedyaLight

@FedyaLight FedyaLight commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

The shared controller and reader still perform work when the visible output has not changed: repeated screen-label writes during state delivery, repeated geometry signatures, Gamepad polling in hidden native WebViews, and a continuous homepage demo loop even under reduced motion or offscreen.

This change keeps frame-rate scrolling and the existing synchronization cadence while removing that redundant work:

  • Update secondary-screen metadata only when its content changes; restore the latest state when returning to a visible preview.
  • Cache layout signatures and preserve measured geometry for identical/appearance-only settings; continue remeasuring actual layout/font/text/viewport changes.
  • Keep profile and display identity in hello/presence and dedicated updates, and omit those redundant fields from high-rate reader state packets.
  • Suspend Gamepad polling while unfocused/hidden, including native visibility, preserving neutral arming and held-input release on return.
  • Stop the demo animation for reduced motion, an offscreen demo or a hidden page, and resume when appropriate. Avoid background connection-help UI work and updates to hidden HUD elements.

docs/performance-audit.md records the full startup-to-shutdown audit across the browser, macOS, Windows/Linux and Android, with preserved background tasks and measurement limits. Native server/shell optimizations are independent in #4; the homepage star button is independent in #3.

Measured with one controller and three Chromium readers, eight-second samples:

  • Unchanged screen-label DOM mutations: 1476 to 0 during scrolling, and 24 to 0 while paused/voice-settled.
  • Controller main-thread CPU: 9.23% baseline versus 7.86–8.50% in three changed samples. Timing is workload-dependent, not a guaranteed saving on every device.
  • Aggregate bytes sent by the four clients: 499523 baseline versus 449037 in the final measured changed sample, without reducing state cadence.
  • Hidden native controller with Gamepad enabled and reduced-motion demo: 36 callbacks to 0 per 600 ms; the offscreen demo also draws no continuous frames.

Validation:

  • Extended tests/performance.mjs passes; baseline code fails the intended label-churn and hidden-Gamepad regressions. The reduced-motion baseline likewise continues drawing.
  • Remote, browser, three-display and real PeerJS/WebRTC hosting suites pass. Existing preview error remains below one CSS pixel; local mode makes no external requests.
  • 2184 responsive checks pass across six languages, two themes, seven viewport sizes and all five platform/hosting adapters.
  • The multi-display test explicitly selects its named source after reconnect, avoiding an assumption about arrival order.
  • JavaScript syntax and whitespace checks pass.

These measurements use Chromium and production relays. Physical battery, native rendering engines and actual remote hardware are not certified by the browser suite. Keep-awake protection, voice recognition/transcript quality, scripts/backups, display calibration, smooth scrolling, heartbeats and reconnect remain intact.

@FedyaLight
FedyaLight merged commit 58a3c86 into main Oct 11, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant