Skip to content

Image watcher screenshots the whole virtual desktop 10 times a second #97

Closed

Description

@TMHSDigital

Why it matters

Image mode burns CPU and holds the GIL for about half of every poll, competing with the click thread for timing accuracy. It scales with total desktop size, so 4K multi-monitor users get the worst of it.

Evidence

  • autoclicker/core/image_match.py:68-72: ImageGrab.grab(bbox=..., all_screens=True). On Windows, Pillow's grabscreen_win32 captures the full virtual screen and then crops to the bbox.
  • Measured during review on a 3840x1080 desktop: ~52 ms per grab for a 300x200 region, against a 100 ms poll (_IMAGE_POLL_SECONDS).
  • find_template (image_match.py:26-41) also reconverts the needle to RGB and re-picks the anchor row on every call, though the template never changes.

Suggested approach

  • Capture only the search region (Win32 BitBlt from GetDC(0) into a region-sized bitmap via ctypes, or mss).
  • Precompute the template bytes and anchor row once in ImageTarget.
  • Add an image-search section to docs/PERFORMANCE.md with numbers at the default margin and at MAX_IMAGE_MARGIN.

Done when

  • Grab time for a 300x200 region is under ~5 ms on a multi-monitor desktop, and PERFORMANCE.md records before/after.

Activity

  1. added
    priority: medium
    performance
    on Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancepriority: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions