Repository navigation
feat(skia): Expose frame data on Rendering event - #23762
ramezgerges merged 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the Skia render pipeline so CompositionTarget.Rendering can carry opaque per-frame data (currently the recorded Skia picture) through RenderingEventArgs, enabling advanced scenarios that need access to frame artifacts.
Changes:
- Added
RenderingEventArgs.FrameDataand internal tracking to detect whether frame data was accessed. - Refactored Skia rendering to use
SKPicture/SKPictureRecorder.EndRecording()instead of rawIntPtr, introducingFramePictureto manage picture lifetime. - Updated
SkiaRenderHelperto record/render using managedSKPictureAPIs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Uno.UI/UI/Xaml/Media/RenderingEventArgs.cs | Adds FrameData to carry opaque per-frame payload and tracks whether it was accessed. |
| src/Uno.UI/UI/Xaml/Media/CompositionTarget.Rendering.skia.cs | Passes the recorded frame picture into Rendering args and adds FramePicture lifetime management around event dispatch. |
| src/Uno.UI/Helpers/SkiaRenderHelper.skia.cs | Switches recording/rendering helpers from raw pointers to SKPicture managed APIs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Each CompositionTarget's latest recorded picture is kept in a static cache; Rendering is raised once per coalesced batch of recordings, on the UI thread, with the latest picture of every live window — targets that haven't re-rendered since the last raise (e.g. a window minimized on hosts that stop servicing invalidations, like macOS) have their previous picture resent. RenderingEventArgs.FrameData exposes the batch as a list of (Window, object) pairs, with each entry's data castable to a SkiaSharp.SKPicture on Skia targets. The frame pipeline holds managed SKPictures instead of raw native handles; a picture is disposed deterministically once the pipeline and the cache release it, unless a subscriber read FrameData, in which case user code may hold it and the GC reclaims it instead. Co-Authored-By: Claude Fable 5 <[email protected]>
45afe85 to
617bba5
Compare
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23762/wasm-skia-net9/index.html |
|
The build 222370 found UI Test snapshots differences: Details
|
RenderingEventArgs.FrameData kept its shape through the port but nothing ever filled it in, so the API that unoplatform#23762/unoplatform#23815 added was always null and its consumers got nothing. The frame is an opaque IRenderRecord now, so the backend says what it can expose: Skia hands out the SKPicture it recorded, and a backend with no meaningful equivalent hands out null. SkiaSharp has no public way to wrap an existing handle, so the managed picture has to be the one EndRecording produced -- and that costs a wrapper per recording. It is therefore opt-in through RenderRecordingOptions.CaptureFrameData, which is set only while a Rendering subscriber is attached; nothing else pays for it. Frames handed to subscribers outlive the pipeline, so ownership goes through FrameHold: the record is disposed once the pipeline is done and no in-flight raise still holds it, unless a subscriber actually read FrameData, in which case app code may keep it and the GC reclaims it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
GitHub Issue: https://github.com/unoplatform/kahua-private/issues/505
PR Type:
What changed? 🚀
PR Checklist ✅
Screenshots Compare Test Runresults.