Repository navigation
fix(gui): read webp render sizes for the side and main views - #2463
Merged
Merged
Conversation
The image-size reader accepted only a PNG IHDR, while the catalog also ships renders as WebP. A WebP side render was dropped, so the variant lost its side view and the side buttons their hotspots; a WebP main view fell back to the metadata origin, which is the base model's size, and scaled its hotspots wrong. read_image_dimensions reads the size from the first 30 bytes of either format: PNG from IHDR, WebP from the VP8X canvas or the VP8 / VP8L bitstream header. No decoder runs. Fixes #2460
[Medium impact] The PR appears safe to merge.
|
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.
Summary
The asset resolver reads each render's pixel size from its file header, and the reader accepted only a PNG
IHDR. The catalog also ships renders as WebP, so:resolve_side_viewkeeps a candidate only when its size can be read. A WebP side render was dropped, and a variant with noside.pngfallback got no side view at all, so its side buttons got no hotspots in the Buttons tab.originas its size and logged "could not read PNG dimensions". The origin is calibrated against the base model's renders, not the variant's, so the hotspots were scaled against the wrong size.Checked against the catalog on 2026-11-08 (first 32 bytes of each file over HTTP Range): in
g502x_plus, theext2device_side(images/device/1b909bb1-…) anddevice_image(images/device/3253a30b-…) both startRIFF....WEBPVP8X, with canvases of 1157×2800 and 1662×2800. The depot'smetadata.jsonorigins are 936×2700 (side) and 1391×2700 (front). The base andext1renders are PNG.is_drawable_imagealready accepts WebP (#2379); only the size check rejected these files.Changes
openlogi-desktopservices/assets/images.rs:read_png_dimensionsbecomesread_image_dimensions. It reads the first 30 bytes and takes the size from a PNGIHDR, or from a WebPVP8Xcanvas,VP8key-frame header orVP8Lheader. The leading bytes pick the format, because many catalog renders have bare UUID names with no extension. No decoder runs.services/assets.rs: the side view, the main view and the standalone render all use it. The fallback warning now says "image dimensions".Why not
image::ImageReader::with_guessed_format()?.into_dimensions(): this crate declaresimagewith only thepngfeature (gpui enableswebpthrough feature unification), so it would need aCargo.tomlchange. Its PNG decoder also checks theIHDRCRC, so every PNG would go through a stricter check than it does today. A header-only reader keeps the PNG behaviour exactly as it is.The
png_width/png_heightfield names onResolvedAssetandSideVieware now inaccurate. They are used in 53 places, so renaming them is left out of this fix.Overlap with #2461: both PRs touch
resolve_side_view. #2461 changes the variant lookup and the path join, and this PR changes the size check on the next line. Whichever PR merges second rebases; the conflict is one line. With both merged, the G502 X PLUSext2gets its WebP front and side views.Testing
New regression tests in
services::assets::tests. With the WebP branch disabled, the first and third fail, which is the behaviour onmaster:render_sizes_are_read_from_png_and_webp_headers: PNG,VP8X(1157×2800, the ext2 side render), lossyVP8with the scale bits set, and losslessVP8L.a_render_without_a_readable_size_has_none: truncated PNG and WebP heads, a lossy frame without the start code, a lossless stream without its signature, an unknown first chunk, the G HUB encrypted blob, an empty file and a missing file.a_webp_colour_variant_gets_both_views_at_their_own_size: a depot sized like the G502 X PLUS ext2, with WebP front and side renders, noside.png, and the catalog's smaller metadata origins. Both views resolve at the renders' own sizes. The variant is keyed on the registry model id with flat names, so the test does not depend on fix(assets): fetch and draw depot renders stored under sub-directories #2461.Local gate (Linux; affected set is
openlogi-desktoponly, noCargo.tomlor lockfile change):Not run locally (left to CI): macOS and Windows clippy and tests, and MSRV. No cfg-gated code changed.
Not runtime-tested on hardware. To check (with #2461 also applied): connect a G502 X PLUS whose extended model id is 2 and start with an empty asset cache. The Buttons tab should show the ext2 render with its side view beside it, and the log should not say "could not read image dimensions".
Fixes #2460