Repository navigation
Phase 27: Screenshot, the spatial view as a high-resolution PNG - #425
Merged
Merged
Conversation
A Screenshot button beside Share saves the main 2D view at 1x-8x, drawn again off screen: the image at the pyramid level the larger size needs, the deck.gl layers at that pixel density, and the scale bar, legend, axes and selections from their models. Decisions D1-D12, the drawing steps, tasks A-I with a spike first, risks, and the user's answers to the four open questions (every loaded cell, 2x to start, a failed tile fails with Retry, Copy later). PLAN.md gets the phase's row.
…xport-resolution-70299d
The canvas's tile caches already read a failed tile again after 1, 2 and 4 s (TILE_RETRY_DELAYS_MS; the early-timer fix in #426), then keep the error until the tile is evicted, with no way to forget one tile. So the screenshot gets its own TileCache and scheduler per channel: a Retry reads failed tiles again, and a read of hundreds of tiles does not push the canvas's tiles out of its cache. D4, the drawing steps, task C and the risks say so; the code map is rechecked at fe50d70.
A Screenshot button beside Share saves the main 2D view as a PNG at 1×, 2×, 4× or 8× its size on screen, drawn again off screen: - the image at the pyramid level the PNG's pixel size needs, through the screenshot's own tile caches (persist: false), retried after 1, 2 and 4 s, then failing with Retry; - every loaded cell, not the render cap's sample, from an off-screen Deck at useDevicePixels N, in tiles of at most 4,096 px; - the scale bar, legend, axes and selections as one SVG at N×; - pHYs for the dpi and tEXt chunks for the software, source, view and time. App owns a ScreenshotRunner, which ViewerCore connects to its view, so no layers or typed arrays go into props and the live DeckGL does not render again. Progress and Cancel show in the popover and the loading list; changing dataset cancels it. deck.gl applies layers given before its device is ready in an animation frame, which a hidden page never runs, so the renderer runs one itself. On the Mac's GPU a 4× PNG of the whole Xenium slide, all 1,414,155 cells, took 1.6 s. The plan records the spike and where the build differs from it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
Screenshotbutton for paper figures: it saves the main 2D view as a PNG at 1×, 2×, 4× or 8× its size on screen, drawn again off screen. The plan isdocs/plan/phases/27-screenshot.md; this PR holds the plan and its implementation (tasks A–I).Problem
The spatial view had no export; the only image the app saved was a plot's
Export PNG. A browser screenshot at a higher device pixel ratio falls short:toDataURLis blank).What it does
Screenshot, besideShare): scale (2× to start), a size line with µm per pixel and mm at a dpi,DPI,Scale bar,Legend,AxesandSelections, a background (Canvas,White,Transparent), notes when the screen samples cells or expression, shows transcripts as density squares or is still loading, andSave PNG. Scales over 16,384 px a side or 128 megapixels are disabled. Above 512 MiB of image tiles it asks first.bestLevel(2 ** zoom × N), read through the screenshot's ownTileCacheper channel withpersist: false, so the canvas's tiles and the byte-range cache are left as they were. A failed tile is read again after 1, 2 and 4 s; then the screenshot fails, names the channel and offersRetry.createOverviewLayerswithout the render cap's sample, in an off-screen Deck atuseDevicePixels: N, drawn in tiles of at most 4,096 px. It fails rather than stretch a drawing buffer the GPU shrank, and its WebGL context is lost as soon as it is done.CanvasandTransparent, white ones onWhite.{dataset}-screenshot.png, withpHYsfor the dpi andtEXtchunks:Software,Source(the dataset URL without credentials),Description(x and y ranges, µm per pixel, scale, z plane) andCreation Time.Cancelin the popover and the loading list; changing dataset cancels it.How
src/features/screenshot/:screenshotPlan(size, limits, grid, levels, notes),screenshotImage(the image composer),screenshotDeck(the off-screen renderer),screenshotOverlay(the SVG),pngChunks,screenshotRun(one screenshot, tile by tile),screenshotRunnerandScreenshotButton.ScreenshotRunnerand passes it to ViewerCore, which connects a function returning the snapshot of its view. No layers or typed arrays go into React props, and taking a screenshot does not render the live DeckGL again (ViewerCore's test checks it).onLoad.Spike (Mac GPU, production build, headless Chromium)
Where the build differs from the plan
screenshotRequestprop.TileRequestScheduler.Screenshotshows its label from 1,340 px and is an icon below that.Answered questions
Every loaded cell, not the screen's sample; 2× to start; a tile that cannot be read fails the screenshot with
Retry;Copyto the clipboard later.Checks
npx tsc --noEmit -p tsconfig.app.json, ESLint and Prettier on the changed files pass.App.test.tsxandcollectionApp.test.tsxpass (127).@smoketest saves a 2× PNG, checks its size,pHYsand text chunks, that the screenshot's WebGL context is gone with no loss on the page, and that the PNG halved matches the screen (mean difference 0.09 of 255). The axe test opens the popover; the baseline stays empty. The top bar popover test passes.@livetest, a 4× PNG of the whole Xenium slide, passed in 1.8 minutes, mostly the dataset's load.docs/ui-reference.md,docs/user-guide.md,docs/architecture.mdandPLAN.md.