diff options
| author | Adam Soltys <[email protected]> | 2026-11-18 08:39:50 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-11-18 08:39:50 -0700 |
| commit | d9f680517fc557f3be66d7197b07ea0cc19ab668 (patch) | |
| tree | 9c9d32051983b5cd636127ba3f93f87b7a00d177 | |
| parent | cf45b6ea2daa0237f54e7b74ab0f07d47722d354 (diff) | |
| download | coinosv3-d9f680517fc557f3be66d7197b07ea0cc19ab668.tar.gz coinosv3-d9f680517fc557f3be66d7197b07ea0cc19ab668.zip | |
Pictures in a post's grid are painted from sharp tile copies. "the thumbs came out grainy i don't think they scaled down very well" (Adam, 2026-11-18). Gallery tiles used the 1100px column copy, and the browser shrank it about eight times into a 140px row, which came out grainy. They now use the Images feed's tile copy: 360px tall, cut with a high-quality resize, made in the same worker pass as the column copy, and read back from disk with it. A picture without a tile copy yet asks for one. feed-picture-pager-test (gallery tiles painted from tile copies), feed-media-views, feed-media-cache and features-smoke pass.HEADmaster
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VMan6TV6sjEZSpqqBen9T5
| -rw-r--r-- | src/features/messages.js | 15 | ||||
| -rw-r--r-- | tools/feed-picture-pager-test.js | 5 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/features/messages.js b/src/features/messages.js index a254295..245e1ce 100644 --- a/src/features/messages.js +++ b/src/features/messages.js @@ -7036,9 +7036,12 @@ export function messagesFeature(ctx) { // make it): the server makes one if (!got && (noCorsHost(url) || corsRefused.has(url) || typeof OffscreenCanvas === 'undefined')) got = await serverMediaThumb(url).catch(() => null); if (got) { + // the grid tile made alongside it, for a post's run of pictures + // (see pictureRuns): looked up from disk when the copy was + await warmTileThumbs([url]).catch(() => {}); // no copy (small already, or a GIF): the original is what paints, // so it's the one decoded ahead — the row mustn't decode it on sight - await decodeAhead(got.thumb || url); + await Promise.all([decodeAhead(got.thumb || url), tileThumbs.has(url) ? decodeAhead(tileThumbs.get(url)) : null]); mediaReady.set(url, got); return; } @@ -10954,7 +10957,7 @@ export function messagesFeature(ctx) { // height-capped: see .note-img) const known = size || mediaReady.get(url); return h('img', { - src: mediaSrc(url, known), class: 'note-img clickable', loading: feedPaint || known ? 'eager' : 'lazy', alt: label || '', + src: mediaSrc(url, known), 'data-pic': url, class: 'note-img clickable', loading: feedPaint || known ? 'eager' : 'lazy', alt: label || '', // a few-ms decode of the copy paints with the page; an original never holds the page for its decode decoding: known && known.thumb ? 'sync' : 'async', width: size?.width, height: size?.height, @@ -11404,6 +11407,14 @@ export function messagesFeature(ctx) { break; } if (run.length < 2) { out.push(nodes[i]); continue; } + // A tile is painted from the Images feed's tile copy (360px, cut with a + // proper resize), not the 1100px column copy: shrunk eight times by the + // browser, that came out grainy (Adam, 2026-11-18). + for (const img of run) { + const url = img.getAttribute('data-pic'), tile = url && tileThumbs.get(url); + if (tile) img.setAttribute(img.hasAttribute('data-lazy-src') ? 'data-lazy-src' : 'src', tile); + else if (url && /^https?:/i.test(url)) queueTileThumbs([url]); + } out.push(h('div', { class: 'note-gallery' }, ...run)); i = last; } diff --git a/tools/feed-picture-pager-test.js b/tools/feed-picture-pager-test.js index 7578e01..947c6aa 100644 --- a/tools/feed-picture-pager-test.js +++ b/tools/feed-picture-pager-test.js @@ -93,6 +93,11 @@ try { }); check('two pictures in a post: one gallery, side by side, one height', gal.n === 2 && gal.sameRow && gal.h > 50 && gal.h < 300, JSON.stringify(gal)); check('a lone picture is not put in a gallery', gal.lone); + // painted from the tile copy (a proper resize), not the column copy shrunk by the browser + check('gallery tiles are painted from the tile copies', await waitFor(() => { + const g = document.querySelector('.notes-feed .note-gallery'); + return !!g && [...g.querySelectorAll('img')].every((i) => /^blob:/.test(i.currentSrc || i.src) && i.naturalHeight > 0 && i.naturalHeight <= 360); + }, null, 5000)); console.log('\n[a tap on the picture that opened it shows its details; the next closes it]'); const y0 = await openPic('two pictures'); |
