canvas: `image_src` is not on `ui.ElementOptions`, so apps cannot atlas and the 16-slot registry becomes the ceiling
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 85/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Tranquilla
- Stack tecnologico
- zig
- Ambito
- frontend
Direzione di ricerca
Inizia in src/primitives/canvas/ui.zig, su ElementOptions e sulla funzione image intorno alla riga 2103. Confronta come vengono inoltrati image_fit e image_sampling, quindi segui i riferimenti esistenti a widget e render in widgets.zig e widget_render.zig. Il lavoro è completato quando le opzioni rivolte all’applicazione possono fornire il rettangolo sorgente e il comportamento esistente di canvas lo gestisce senza modificare i limiti del registry.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The problem
ui.ElementOptions cannot set image_src, so an app cannot draw a sub-rectangle of a registered image. That makes a texture atlas impossible from app code, and the 16-slot registry becomes a hard ceiling on how many distinct images an app can show.
The renderer already supports it. Widget carries the field and the draw path consumes it:
src/primitives/canvas/widgets.zig:1206—image_src: ?geometry.RectF = nullon the widget optionssrc/primitives/canvas/widgets.zig:1289—.image_src = options.image_src, passed straight throughsrc/primitives/canvas/widget_render.zig:2696—.src = widget.image_srcon the emittedDrawImagesrc/primitives/canvas/widget_invalidation.zig:315— already compared for damage
The app-facing options struct exposes only the id:
src/primitives/canvas/ui.zig:581—image: canvas.ImageId = 0, and noimage_srcanywhere inElementOptionssrc/primitives/canvas/ui.zig:2103—pub fn image(self: *Self, options: ElementOptions) Node
So the capability exists end to end except for one field on the struct the app fills in.
The fix
Add image_src: ?geometry.RectF = null to ui.ElementOptions and forward it where the other image fields are already forwarded, alongside image_fit and image_sampling. As far as I can tell nothing else has to change: the widget field, the render path and the invalidation comparison are all in place.
Markup would want an attribute too, though the Zig-view path alone is enough to unblock this, and a rect in markup may not be worth the grammar.
Why it is worth doing
It lifts the practical image ceiling without touching the fixed-capacity design. canvas_limits.zig:107 sets max_registered_canvas_images = 16, sized in its own comment for "avatar and cover-art scale". With a source crop, one 512x512 slot holds 64 avatars at 64x64, so the same 16 slots cover roughly a thousand small images. The budget stays frozen, the preallocation stays predictable, and the loud-overflow behaviour is unchanged. Nothing about the philosophy moves; the same memory just goes further.
It is the difference between viable and not for one class of app. I am building a Nostr client. A social feed shows dozens of small images at once: a face on every row, a gallery in a note, an icon per community in a sidebar. Today those compete for 16 slots app-wide, so I run an LRU over them and faces still fall back to initials on a dense screen. The workarounds all cost something real. Splitting the budget by kind strands capacity, evicting aggressively makes avatars flicker as you scroll, and drawing letter tiles instead of pictures is just not showing the image. An atlas removes the problem rather than rationing it.
It is cheap for you and it composes with what already shipped. 0.9.2 made the per-image budget app-settable through app.zon (max_image_pixel_bytes, types.zig:666), which fixed the size half of this. This is the count half, and it needs no new budget, no new manifest key and no new platform code.
It also helps the cases you already target. Sprite sheets for a toolbar, a spritemap of state icons, frames of a small animation, nine-slice art: all of them are one registration and many draws rather than one registration each.
Not asking for
A bigger registry, a dynamic one, or any change to how overflow behaves. Just the field.
- Lingua principale
- Zig
- Stelle
- 7.9k
- Fork
- 335
- Merge medio
- 10h 33m
- PR unite (30g)
- 147
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di vercel-labs/native
-
Per-view widget layout budget (1024 nodes) drops whole frames on real multi-pane app viewsForse già presa @slicenferqin l’ha presa 100 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
vercel-labs/native#408 ·
I maintainer di solito rispondono entro 1 giorno
-
macOS: the window frame event reports the frame size where everything else expects the content sizeAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
vercel-labs/native#355 ·
I maintainer di solito rispondono entro 1 giorno
-
cef.zig: InstallResult.archive_path leaks on successForse già presa @versecafe l’ha presa 206 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
vercel-labs/native#32 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
vercel-labs/native#957 ·
I maintainer di solito rispondono entro 1 giorno
-
macOS updater: the download sheet never shows after Install Update, and the window stays greyAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
vercel-labs/native#952 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di vercel-labs/native
Issue simili
-
area: tests help wanted size/s
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
DahanItamar/DockNest#368 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 94/100
storytold/craft-libs#5594 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
听歌识曲历史跳转后对应音源界面无法返回Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
LingyunStudio/RustMusic#16 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100