Skip to content

perf(screenshot): offload white-image detection to worker#665

Open
Kikobeats wants to merge 4 commits intomasterfrom
codex/fix-white-screenshot-worker
Open

perf(screenshot): offload white-image detection to worker#665
Kikobeats wants to merge 4 commits intomasterfrom
codex/fix-white-screenshot-worker

Conversation

@Kikobeats
Copy link
Member

@Kikobeats Kikobeats commented Feb 26, 2026

Note

Medium Risk
Introduces a long-lived worker_threads worker with request tracking and lifecycle/error handling; bugs here could cause hangs or incorrect blank-screenshot detection under load despite added coverage.

Overview
Offloads is-white-screenshot image analysis to a dedicated worker_threads worker, extracting the Jimp-based sampling logic into is-white-screenshot-analyze.js and adding a message-based RPC layer with in-flight request tracking.

Adds worker lifecycle handling (reuse, unref, reject all pending on error/exit, reset on failure) and new tests that assert worker usage, proper rejection when the worker exits, and safe recovery after a crash; updates the sampling test to target analyze directly.

Written by Cursor Bugbot for commit 89ac764. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

A stale worker's `exit` handler could fire after a replacement worker
was already created, incorrectly rejecting the new worker's pending
promises and clearing its reference. Guard `error` and `exit` handlers
with an identity check so they become no-ops once replaced.

Made-with: Cursor
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