Skip to content

ScreenCaptureManager ioDispatcher parameter name is misleading #8

Description

@rogue-socket

Summary

ScreenCaptureManager.kt line 29: the parameter is named ioDispatcher but defaults to Dispatchers.Default.

private val ioDispatcher: CoroutineDispatcher = Dispatchers.Default

Why Default is actually correct

The capture() method does:

  • I/O-bound waiting (non-blocking suspension via suspendCancellableCoroutine for frame callbacks) — doesn't block a thread
  • CPU-bound work (pixel buffer reading, bitmap copying/cropping in imageToBitmap())

Dispatchers.Default (sized to CPU core count) is the right choice. Dispatchers.IO would waste an IO pool slot on CPU-bound bitmap work, with no benefit for the non-blocking I/O waiting.

The risk

Someone reading the constructor sees ioDispatcher defaulting to Default and "fixes" it to Dispatchers.IO, thinking the name implies it should use IO. This would be a performance regression.

Fix

Rename the parameter to dispatcher or captureDispatcher.

Files

  • action-executor/src/main/java/com/scroller/agent/executor/ScreenCaptureManager.kt (line 29)

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions