Closed Released #5 in 0.25.3, #6 in 0.25.3 bug report

pup render leg fails on macOS: empty "error" treated as failure, screenshot path read from _cacheHint, capture narrower than #hero

Drew Owens · ·closed by Colby Knox

hero-studio 0.25.2 · pup bridge 3.0.8 · adom-wiki 1.8.31 · Node v18.19.1 · aarch64 container (no local Chrome, so Generate renders via pup) · macOS host (MacBook Air), webview surface

@kyle: macOS-specific (the pup capture size), please check on a Mac.

Generate fails every time on the pup render leg. Three separate bugs in render-pup.mjs / bridge.mjs / pose.mjs, each hiding the next.

What I did

hero-studio --ai-thread "streams-av" pose drew715/drew-streams-skillpack --surface webview --type skill, loaded a showcase, the human walked the wizard and clicked Generate hero PNG. doctor said renderer ready via pup fallback.

1. An empty "error": "" counts as an error

The first click failed with:

Generate failed: pup: pup renderer: Adom Desktop did not answer browser_status; the host relay is not reachable from this container.

The relay was fine. Current bridges put "error": "" in every successful reply, and three checks treat any reply containing the text "error" as a failure:

  • render-pup.mjs:33 if (!status.ok || status.out.includes('"error"'))
  • bridge.mjs:53 bridgeTrouble(): text.includes('"error"')
  • pose.mjs:433 looksOk: !r.out.includes('"error"')

Fix I applied locally, in all three: only a non-empty error counts. /"error"\s*:\s*(?=\S)(?!""|null|false)/.test(text)

2. The screenshot path is read from the _cacheHint text

Next click:

Generate failed: pup: "_cacheHint": "Pulled screenshots live in /home/adom/project/screenshots/adom-bridge/window/ (bucketed by kind: ...). Filenames are human)

pup_screenshot now starts its reply with _cacheHint, which contains example filenames (<YYYY-MM-DDThh-mm-ss.mmm>[-<hwnd>].png). render-pup takes the first /[^"\s]+\.png/ match, which is that example, existsSync is false, there is no base64, so it dies with the raw head.

Fix: parse the JSON and use localFullPath / localSafePath / filePath first, then fall back to the first regex match that exists on disk.

3. The capture is narrower than the hero (macOS)

Then: pup renderer: cropped 1568x789, not 16:10 within 0.03.

  • window.resizeTo(1720, 1180) does nothing in a pup window (the real window stayed 1450 pt wide).
  • pup_screenshot (captureVisibleTab) only captures the real window's visible area: 1568x1076 here, while #hero measures 1600x1000 at x=0, y=46.5. The hero's right edge is cut off.
  • Even with pup_set_viewport {width:1720,height:1180}, pup_screenshot still returns 1568 wide (cropped 1568x1000). pup_screenshot_full_res does capture the emulated viewport (1720x1180).

Fix (render-pup.mjs step 4 and step 6):

  • pin the viewport with <prefix>_set_viewport {sessionId, width:1720, height:1180, deviceScaleFactor:2} (it persists across navigations), and keep resizeTo only as the fallback when that verb is missing;
  • when the pin worked, take the shot with <prefix>_screenshot_full_res, falling back to the old screenshot.

Result: OK test-render.png (3200x2000 via host browser), the full hero with nothing clipped, comfortably above the 1600 px floor (no upscale in finalize).

Testing

I ran node render-pup.mjs "http://127.0.0.1:8846/?render=1" out.png directly against the open studio (an unstamped test render, not a Generate). It now renders cleanly; before the fixes it failed at each step above in turn. The patched files are in the local install (originals kept as *.orig). A package update will overwrite them, so please ship the fixes upstream.

1 Reply

Drew Owens mentioned this in pull request #5 ·
Drew Owens linked pull request #6, which closes this when it merges ·
Colby Knox closed this in pull request #6 ·
Colby Knox ·

Fixed in hero-studio 0.25.3 (now latest; adom-wiki pkg install adom/hero-studio to update), via PR 6.

Tested on a Windows host (pup through Adom Bridge): 0.25.2 failed there too, on the same empty "error" check, so this was not Mac-only. With 0.25.3 a compose through pup renders 3200x2000.

One addition on top of the PR: in the render view #hero sits at (0,0), right under render-pup's 16 px magenta sentinel. With the pinned viewport, the sentinel ended up in the hero's top-left corner. The page now moves down 24 px before it is measured, so the sentinel stays outside the crop.

Log in to reply.