Skip to content

Extreme Optimization: Native Win32 Migration and Footprint Reduction #52

@0xarchit

Description

@0xarchit

The current application architecture relies on several high-level dependencies (reqwest, tokio, dirs, winreg) that contribute significantly to binary bloat and idle memory overhead. Additionally, the event-driven system uses a polling-based message loop which introduces perceptible latency in UI interactions (Settings opening/closing) and resource transitions.

This issue tracks the migration to a "Pure Native" architecture to achieve a sub-600KB binary and instantaneous responsiveness.

Optimization Goals

1. Storage & Dependency Pruning

  • Remove reqwest and tokio (approx. 800KB saving).
  • Remove dirs and winreg crates.
  • Replace lazy_static with standard library OnceLock.
  • Implement a custom, minimalist file logger to replace env_logger.
  • Migrate to native WinHTTP for updates and asset syncing.
  • Migrate to SHGetKnownFolderPath for directory discovery.
  • Migrate to native Reg* APIs for registry management.

2. Memory (RAM) Efficiency

  • Downsampled Capture: Capture screen at 25% resolution to reduce transition buffers from ~66MB to ~4MB (16x saving).
  • Static Buffer Reuse: Implement reusable static buffers for the capture and blur engines to eliminate heap churn.
  • Idle Flushing: Explicitly shrink and clear heavy buffers to zero capacity when the application is idling in the tray.
  • Resource Streaming: Use SHCreateStreamOnFileEx to stream media assets to WebView2 instead of loading full files into memory.

3. Responsiveness & Reliability

  • Instant Wakeup: Implement PostThreadMessageW to wake the main message loop immediately when events occur, removing the 100ms-1s latency.
  • Networking Hardening: Add strict timeouts and larger redirect buffers to the WinHTTP stack to prevent "stuck" update checks.
  • Zero-Warning Build: Refactor code to meet strict compiler standards.

Technical Impact (Measured)

Metric Before After Change
Binary Size ~2,048 KB 528 KB -74%
Idle RAM ~4.5 MB ~3.5 MB -22%
UI Latency 100ms - 1s < 1ms Instant

Notes

These changes ensure that PauseCat remains a professional-grade workstation utility that provides high-end visual effects (Gaussian blur, Glassmorphism) with the footprint of a legacy system tool.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions