Skip to content

feat: photograph pages that are not gnoweb, and wait for the ones that draw themselves - #1

Merged
moul merged 1 commit into
mainfrom
settle-nongnoweb
Sep 23, 2026
Merged

moul merged 1 commit into
mainfrom
settle-nongnoweb

Conversation

@moul

@moul moul commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

The problem

Two of them, found while pointing this service at the apps people actually
build on gno.land rather than only at realms.

1. "No selector matched" means two different things, and the code knew only one.
On gnoweb it means an error page, which is what matched=status records and why
a placeholder tile is served instead of a screenshot. On somebody else's app it
means nothing at all: the chain is gnoweb's own class names. So every working
third-party site was classified as an error page and served a "NO PREVIEW" tile.

2. fonts.ready plus two frames is not a painted page.
It is enough for gnoweb, which server-renders and then hydrates. It is not
enough for a page that paints nothing until its JavaScript has fetched and
rendered. Measured 2026-09-23, page mode, all three answering 200 with real
content in a browser:

page master before after
gnoswap.io 228 bytes, a blank frame 452,420
gnolove.world 148,796, its loading spinner 403,682
kourt.xyz 96,136, "Reading the chain…" 349,942

A confident picture of a spinner is worse than no picture, because nothing
downstream can tell the two apart.

What this adds

-allow-site, a second host list, empty by default. A host on it skips the
selector chain, is photographed whole, and records matched=site. The ladder is
already derived from the page master when there is no render master, so
size=thumb and size=og answer normally with no further change.

A DOM-quiesce settle, after the existing font wait: resolve once there have
been no mutations for 400 ms, or at a 2,500 ms cap.

Three things worth reviewing

The settle is a quiesce, not a sleep or network idle. A fixed sleep taxes
every gnoweb capture for the handful that need it, and the sweep runs over every
realm on the chain. Network idle never arrives on a page holding a websocket or
a poll open, and several of these do. A quiesce returns in one quiet window on a
page that was already finished.

Verified it changes nothing for gnoweb. Same three pages, render mode,
before and after, byte-for-byte:

page master selector box
/r/gov/dao 74,154 both md-renderer.c-realm-view 816x1294
/r/gnoland/blog 351,912 both md-renderer.c-realm-view 816x3518
/p/moul/txlink 11,958 both article.b-directory 1200x241

The cost is the quiet window: 970 ms to 1.28 s on /r/gov/dao.

The two lists are kept apart on purpose. The operator states which kind of
page a host serves rather than the service guessing from what it found. A host
in both is a configuration mistake with a quiet failure mode (the picture
silently gets worse, because the whole-page path replaces a crop the chain would
have found), so gnoweb wins and there is a test on it.

The site path does not touch the page it photographs. resolveJS pads the
element it matches so the crop has breathing room; doing that to a third-party
document would be photographing something that never existed. The site path runs
a script that only reads the document height.

Verified end to end

Against a local serve with -allow-site adena.app,gnoswap.io,kourt.xyz: all
three return matched=site, a full rung ladder, and 200 on size=thumb and
size=og after the first capture drains the queue (202 with a tile before
that, as designed). adena.app thumb@2x is 3,946 bytes and og 20,616.

go test ./..., gofmt -l ., go vet ./... clean.

@moul
moul merged commit 48f2ded into main Sep 23, 2026
1 check passed
@moul
moul deleted the settle-nongnoweb branch September 23, 2026 14:26
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