Skip to content

fix(screenshot): resolve dev screenshot path instead of hardcoding .png - #1

Open
bruceharrison1984 wants to merge 1 commit into
danecodes:mainfrom
bruceharrison1984:fix/screenshot-jpeg-path
Open

fix(screenshot): resolve dev screenshot path instead of hardcoding .png#1
bruceharrison1984 wants to merge 1 commit into
danecodes:mainfrom
bruceharrison1984:fix/screenshot-jpeg-path

Conversation

@bruceharrison1984

Copy link
Copy Markdown

Problem

EcpClient.takeScreenshot() retrieves the capture from a hardcoded /pkgs/dev.png:

const png = await digestGet(`${devUrl}/pkgs/dev.png?time=${Date.now()}`, ...);

But the dev-mode screenshot format is device-dependent. HD (720p) Roku TVs write the capture as a JPEG at /pkgs/dev.jpg, while newer/4K models write a PNG at /pkgs/dev.png. On an HD TV the .png path does not exist, so the GET 404s and takeScreenshot() throws Digest GET failed: 404 — even though the capture succeeded and a dev channel is running. This makes roku_screenshot (via @danecodes/roku-mcp) unusable on that whole class of devices.

Reproduced on a Roku 24R2EX (720p, firmware 15.2.4)

POST /plugin_inspect (mysubmit=Screenshot)  -> HTTP 200, body: src="pkgs/dev.jpg?time=..."
GET  /pkgs/dev.png                           -> HTTP 404  (text/plain, 35 bytes)
GET  /pkgs/dev.jpg                           -> HTTP 200  image/jpeg, 70 KB, 1280x720

The /plugin_inspect POST response already advertises the real filename.

Fix

Read the actual path the device reports in the /plugin_inspect response HTML (src="pkgs/dev.jpg?time=...") and fetch that. If the response advertises no path, fall back to trying both .jpg and .png. This keeps working on PNG devices and fixes JPEG devices, with no configuration.

Tests

Adds takeScreenshot unit tests (fetch-level mocks) covering:

  • an HD TV that reports/serves .jpg (asserts .png is never requested)
  • reported .png that 404s, falling back to .jpg
  • no advertised path -> tries both extensions
  • all candidates 404 -> throws EcpScreenshotError

npm run build and npm test pass (93 tests).

takeScreenshot() fetched /pkgs/dev.png unconditionally, but the dev-mode
screenshot format is device-dependent: HD (720p) Roku TVs write the capture
as a JPEG at /pkgs/dev.jpg, while newer/4K models write a PNG at
/pkgs/dev.png. On HD TVs the hardcoded .png GET 404s ("Digest GET failed:
404") even though the capture succeeded and a dev channel is running.

Read the actual path the device advertises in the /plugin_inspect response
HTML (e.g. src="pkgs/dev.jpg?time=...") and fetch that, falling back to
trying both extensions if the response names none or the reported path is
missing. Verified against a Roku 24R2EX (720p, firmware 15.2.4), which serves
only /pkgs/dev.jpg.

Adds unit tests for the JPEG device, the .png->.jpg fallback, the
no-advertised-path default, and the all-404 failure case.
@bruceharrison1984

Copy link
Copy Markdown
Author

I stumbled on to this while using the MCP server, so fixing it here and re-rolling the MCP should fix it. The fix itself is straight-forward.

Claude was used for generating the PR as well, but seems like a given since I found it while consuming the MCP version.

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