Skip to content

Skia: hold image Blob alongside cached image shader - #77

Merged
nicoburns merged 1 commit into
mainfrom
devin/1785853487-image-shader-blob
Aug 4, 2026
Merged

Skia: hold image Blob alongside cached image shader#77
nicoburns merged 1 commit into
mainfrom
devin/1785853487-image-shader-blob

Conversation

@nicoburns

Copy link
Copy Markdown
Member

Summary

shader_from_image_brush builds the Skia image via unsafe { SkData::new_bytes(...) }, which references the peniko Blob's pixel bytes without owning them. The resulting shader is stored in the generational image_shader cache, which outlives the set_paint_brush call — so if the caller drops the ImageData after painting, the cached shader dangles (UB).

Fix: change the cache value from Shader to (Shader, peniko::Blob<u8>) and store a clone of the image blob (a cheap Arc clone) alongside the shader, tying the pixel data's lifetime to the cache entry.

Note: the cache key still ignores brush_transform/sampler (audit item 1.2); that's a separate issue not addressed here.

Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/b0ca09237beb462e9ea6b7be54018019
Requested by: @nicoburns

The cached shader references the image pixels without owning them
(SkData::new_bytes), so keep the Blob alive for the cache entry's
lifetime.
@nicoburns nicoburns self-assigned this Aug 4, 2026
@staging-devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@nicoburns
nicoburns merged commit d2b3a4e into main Aug 4, 2026
9 checks passed
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