Skip to content

fix(pdf): verify probe screenshot before skipping blank-SPA poll#838

Closed
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/critical-bug-investigation-d24f
Closed

fix(pdf): verify probe screenshot before skipping blank-SPA poll#838
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/critical-bug-investigation-d24f

Conversation

@cursor

@cursor cursor Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Bug and impact

PR #837 added a fast path in prepare() that skipped the white-screen screenshot poll when waitForReady reported painted content (visible images or 200+ chars of text). In-page DOM signals do not guarantee a non-white capture: SSR text or a hero image under a fixed white loading overlay passes the gate, skips the poll, and ships a blank PDF.

Root cause

The fast path equated DOM text/image presence with visual paint readiness. checkVisibility does not detect opaque fixed overlays covering the viewport.

Fix

When the gate reports painted content, take one cheap probe screenshot first. Only skip the poll loop when the probe is non-white; otherwise fall through to the existing blank-SPA poll.

Validation

  • Updated fast-path unit tests to expect one probe capture
  • Added regression test: DOM text + white probe falls through to poll + re-wait
  • All 10 test/pdf.js tests pass
  • All 8 wait-for-ready.js unit tests pass
Open in Web View Automation 

The #837 painted/text fast path trusted in-page DOM signals alone. A page
with 200+ chars of SSR text (or a decoded hero image) under a fixed white
loading overlay passed waitForReady and skipped the white-screen poll,
shipping a blank PDF.

Take one cheap probe capture when the gate reports painted content; only
skip the poll loop when that capture is non-white. Adds a regression test
for the overlay case.
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage is 82.326%cursor/critical-bug-investigation-d24f into master. No base build found for master.

@Kikobeats

Copy link
Copy Markdown
Member

Superseded by #839: same bug fixed inside the readiness snapshot (covered signal via hit-testing + root-level overlay scan, white-on-white text filtered), keeping #837's zero-screenshot fast path instead of paying a probe capture on every painted page.

@Kikobeats Kikobeats closed this Jul 16, 2026
Kikobeats added a commit that referenced this pull request Jul 16, 2026
…hot fast path (#839)

* fix(pdf): verify probe screenshot before skipping blank-SPA poll

The #837 painted/text fast path trusted in-page DOM signals alone. A page
with 200+ chars of SSR text (or a decoded hero image) under a fixed white
loading overlay passed waitForReady and skipped the white-screen poll,
shipping a blank PDF.

Take one cheap probe capture when the gate reports painted content; only
skip the poll loop when that capture is non-white. Adds a regression test
for the overlay case.

* fix(screenshot): detect covered content in readiness gate, keep zero-screenshot fast path

A fixed opaque overlay (or white-on-white text) passes every DOM paint
signal while a capture stays white, so PR #837's fast path could ship a
blank PDF. PR #838 fixed it with a probe screenshot on every painted
page, which pays a capture on the fast path and makes the branch
equivalent to the poll loop's first iteration.

Instead, detect the cover in the in-page snapshot itself:

- `covered`: hit-test the counted content samples for an unrelated
  opaque viewport-filling layer, plus a root-level scan for
  `pointer-events: none` overlays hit-testing can't see
- skip text whose color matches its effective background (invisible on
  capture) when counting the `text` paint signal
- pdf fast path requires `!ready.covered`; the probe screenshot is
  removed, so a clean painted page takes zero captures again

Covered or suspicious pages fall through to the existing blank-SPA
screenshot poll, where a capture verifies ground truth.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@Kikobeats
Kikobeats deleted the cursor/critical-bug-investigation-d24f branch July 16, 2026 14:57
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.

3 participants