Repository navigation
Build SkiaSharp.Views.Uno.WinUI against Uno Platform 7 - #5377
Conversation
📦 Try the packages from this PRWarning Do not run these scripts without first reviewing the code in this PR. Step 1 — Download the packages bash / macOS / Linux: curl -fsSL https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.sh | bash -s -- 5377PowerShell / Windows: iex "& { $(irm https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.ps1) } 5377"Step 2 — Add the local NuGet source dotnet nuget add source ~/.skiasharp/hives/pr-5377/packages --name skiasharp-pr-5377More options
Or download manually from Azure Pipelines — look for the Remove the source when you're done: dotnet nuget remove source skiasharp-pr-5377 |
|
Hey there @@ramezgerges! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
b17f6ab to
e674a86
Compare
37d15aa to
ab6af35
Compare
ab6af35 to
1a51108
Compare
df5a1b2 to
6eeb8e2
Compare
|
@dalexsoto review |
|
@mattleibow Not reviewing this request in this iteration: The PR is still a draft. I will review it once it is marked ready; this head has not been marked reviewed. |
Every published SkiaSharp.Views.Uno.WinUI is built against Uno.WinUI 5.2 and references the Uno and Uno.UI.Toolkit assemblies, which Uno Platform 7 renamed to Uno.WinRT and Uno.UI.Extras without forwarders. On 7.0 the app throws FileNotFoundException from SkiaSharp.Views.Windows.GlobalStaticResources.Initialize() at startup. Build the package against Uno.WinUI 7.0, as one plain netX assembly instead of one per platform: - the Android, iOS, macOS, Mac Catalyst and WebAssembly variants and the uno-runtime packaging split are removed; - the package targets net10.0 and later plus -windows, since Uno Platform 7 does not support net9.0. - with one implementation left, each view is a single file in the project: the shared folder and its .Skia.cs partials are merged. This drops Uno Platform 5 and 6 support. SKSwapChainPanel stays unsupported outside Windows App SDK; Uno's SKCanvasElement is the GPU-backed control there. The Uno samples move to Uno.Sdk 7.0.0-dev.79 and its conditional XAML prefixes. Earlier 7.0 SDKs bring a Hot Design build that still references the pre-7 assemblies. The Gallery also stops declaring SkiaSharp.Views.WinUI twice, which the 7.0 SDK's package resolver rejects. The in-tree samples also exclude the Uno.Sdk's Win32, Android and iOS SkiaSharp native packages, as they already did the Linux, macOS and WebAssembly ones, so they load the natives built in the tree instead of the SDK's older ones. The samples' Android heads move to Uno.UI.Runtime.Android's NativeApplication and ApplicationActivity and build their host in CreateHost, as Uno Platform 7 requires. SkiaFiddle moves to Uno.Monaco.Editor 7.0.0-dev.3, the first build for Uno Platform 7; earlier ones depend on a CommunityToolkit build that references Uno.UI.Toolkit and fail at startup the same way. The Basic sample drops the WebAssembly splash workaround it carried for Uno 6.7: Uno 7 requests a recorded frame for the splash itself (unoplatform/uno#24260). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Uno Platform 7 draws Android apps edge to edge, so the Basic sample's Drawing toolbar sat under the navigation bar and the Gallery's header under the status bar; both now pad to the visible bounds on every side. On a phone-width screen the Gallery's 290 px controls sidebar left its sample canvas 40 px wide. Below 720 px the controls now go under the canvas and fold vertically. The Android back button returns from a sample to the gallery instead of closing the app. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The Android, iOS and macOS views carried HAS_UNO and HAS_UNO_WINUI branches for the Uno native-renderer builds that compiled them as internal types; only SkiaSharp.Views compiles them now, where neither symbol is defined. In the shared paint event args, the HAS_UNO arm of the UWP namespace and the !HAS_UNO guards on the Android branches served the same removed builds, and the GLES interop condition worked around an Uno bug in those platform heads. The Uno views project also stops defining HAS_UNO, which Uno.WinUI already defines for its consumers. Every view assembly's public API is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The WebAssembly native-asset targets linked the static libraries for Uno apps through Uno.Wasm.Bootstrap's own emcc pipeline (WasmShell* items gated on IsUnoHead and UnoRuntimeIdentifier). Uno Platform has built WebAssembly through the .NET SDK since Uno.Wasm.Bootstrap 9, which these targets already handle, and Uno Platform 7 no longer sets UnoRuntimeIdentifier, so those blocks could no longer apply. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
It still builds on Uno.Wasm.Bootstrap 2.1.0 and nothing runs it; the WebAssembly native assets are exercised by the samples and the browser sample tests. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
SkiaRenderer is only a legacy alias the 7.0 SDK maps to skia, so the samples name skia directly. UnoDisableLottieSkiaVersionCheck belonged to the 6.x Uno.WinUI.Lottie package, which none of the samples use. Comments no longer attribute their workarounds to SkiaRenderer or Uno.Sdk 6.6. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
SkiaSharp.Views.Uno.WinUI now targets net10.0 and Uno Platform 7, no longer pulls in the WebAssembly native assets (the Uno.Sdk adds them), and only Windows targets get a working SKSwapChainPanel. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
On Uno Platform targets SKSwapChainPanel threw NotSupportedException from its constructor by default, and otherwise drew nothing, so apps and libraries that used it broke on Uno Platform 7, where every target lost the native GPU implementations. Uno Platform exposes no swap chain or GPU context to draw into, so the panel now renders on the CPU through an SKXamlCanvas it hosts, and raises PaintSurface with that raster surface. GRContext is null. BackendRenderTarget describes the surface's size and format, with no framebuffer behind it, because handlers commonly size their drawing from it. EnableRenderLoop redraws on CompositionTarget.Rendering while the panel is loaded and visible. The panel derives from Grid, as it does on Windows App SDK, so it can host the canvas. RaiseOnUnsupported, which only controlled the old exception, is removed. SKCanvasElement remains the GPU-backed control on Uno Platform targets. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
No project targets UWP or netstandard1.x any more, so WINDOWS_UWP, UAP10_0_10240 and NETSTANDARD1_3 are never defined. Drop the code behind them from the core binding and the shared view sources. The public API of every built assembly and target framework is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Uno.Sdk 7 references the HarfBuzzSharp native assets implicitly, at its own stable version. The generated Uno samples only overrode SkiaSharpVersion, so restore asked for a stable HarfBuzzSharp the artifacts feed doesn't carry and failed with NU1103. They now override HarfBuzzSharpVersion the same way. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…HarfBuzzSharp Uno.Sdk 7 no longer references SkiaSharp.Views.Uno.WinUI implicitly, and the Gallery sample only got it through the stripped _UnoPlatformSamples.targets. SkiaFiddle was the one Uno sample missing the HarfBuzzSharpVersion override. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Uno.Wasm.Bootstrap probes the HTTP cache with only-if-cached fetches. Chromium logs every miss as "Failed to load resource: net::ERR_CACHE_MISS" even though the bootstrapper handles it, so a first load always reported a console error. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Uno Platform 7 is only on nuget.org for now and isn't mirrored into dotnet-public, so CI can't restore SkiaSharp.Views.Uno.WinUI or the Uno samples. Add nuget.org to the repository's nuget.config and to the NuGet config the sample tests generate for their workspaces. Drop this commit once the packages are available from dotnet-public. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Refresh the Linux, macOS, and Windows Uno drawing references from the Uno Platform 7 CI output. Co-authored-by: Copilot App <[email protected]> Copilot-Session: ca540d5b-deca-4c37-962e-af4d96c4431d
The cleared page was still the Uno Platform 6 render: on Uno Platform 7 the tab indicator sits a pixel further right and the button edges antialias differently, which failed UnoPlatformDrawingSampleNavigatesDrawsAndClears on every host (0.125% of pixels against a 0.075% budget). The new references are the settled captures from CI build 1646102; Linux and Windows render the same bytes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
6eeb8e2 to
d7ce59b
Compare
|
@dalexsoto The PR should be ready to review and was green right before the new conflict (which I just fixed). |
|
@dalexsoto review |
Remove the temporary nuget.org source from repository and generated sample restore configurations so CI verifies that all Uno 7 dependencies are mirrored. Co-authored-by: Copilot App <[email protected]> Copilot-Session: ca540d5b-deca-4c37-962e-af4d96c4431d
dalexsoto
left a comment
There was a problem hiding this comment.
The documented Uno 7/.NET 10 migration, CPU rendering and Uno-only API changes are intentional. Three current correctness/integration blockers remain:
-
Keep redraw requests deferred. SKSwapChainPanel.cs:78-79 now forwards to synchronous canvas invalidation on the UI thread. A
PaintSurfacehandler callingpanel.Invalidate()immediately re-enters itself until stack overflow, whereas the old panel queued redraws. Restore deferred/coalesced scheduling. -
Pin generated SkiaFiddle's managed cohort. SkiaFiddle.csproj:1 loses the in-tree import during generation, and SDK 7 no longer supplies the previous managed Views/Skottie pin.
SkiaSharpVersion=4.156.0selects native WASM milestone 156 but does not constrain the managed core. Normal feeds offering the renderer dependency minimum can select managed 4.151.1, whose automatic native check accepts only milestone 151. The pinned SDK/Monaco/browser-runtime/Extras/bootstrap contracts contain no compensating managed reference or constraint. Add explicit current managed product references that survive generation, or emit equivalent references in the generator. -
Release the Android back handler at the gallery root. MainPage.xaml.cs:23-30 keeps
BackRequestedsubscribed onHomePage. In the pinned Uno Android API 36+ path, any subscriber enables the native callback, which consumes back regardless ofHandled; the root branch does nothing, so OS back cannot run. Register a removable handler only while sample/back navigation is available and unregister it at the root.
SKSwapChainPanel.Invalidate forwarded to SKXamlCanvas.Invalidate, which draws synchronously on the UI thread, so a PaintSurface handler that calls Invalidate re-entered itself until the stack overflowed. The panel used to queue its redraws on the dispatcher; it does again, with at most one pending request. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The sample generator drops the in-tree _UnoPlatformSamples.targets import and turns a sample's own project references into package references at the product version. SkiaFiddle had none, so a generated copy only versioned the native assets through SkiaSharpVersion, and restore could pick an older managed SkiaSharp than the native library it loads. Reference the managed projects directly, as the Gallery does. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Any BackRequested subscriber makes Uno Platform's Android host take the system back button, whether or not the handler sets Handled, so the Gallery's permanent subscription stopped back from leaving the app at the home page. Subscribe only while a sample page is showing. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
All three blockers are addressed on the current head:
The branch is clean and CI is running against these fixes. |
dalexsoto
left a comment
There was a problem hiding this comment.
The three earlier blockers are fixed: redraws are deferred/coalesced, generated SkiaFiddle pins the managed product cohort, and Gallery releases Android back at the root. The latest maintainer reply and updated Uno 7/CPU-rendering scope are incorporated.
One new lifetime blocker remains in the replacement redraw path: SKSwapChainPanel.cs:88-92 unconditionally paints in the queued callback. A loaded, arranged panel can queue Invalidate() and then be removed before the dispatcher runs. Unload frees the child pixel buffer/pin, but the queued callback can paint the detached canvas; its retained positive dimensions allow a fresh allocation and GCHandle pin after final cleanup. There is no subsequent unload to release that pin, and a self-invalidating handler can keep detached rendering alive.
Reset pending state and discard queued work when the panel/child is no longer loaded, or invalidate/cancel that work on unload. This is a source-derived scheduling/lifetime case, not an executed runtime reproduction or an objection to the intentional CPU fallback.
A redraw queued while the canvas was loaded (by SKSwapChainPanel's coalesced Invalidate, a size or visibility change, or a DPI change) could run after the last Unloaded. It then reallocated and pinned a pixel buffer that no later unload would free, and a handler that invalidates from PaintSurface kept a detached canvas rendering. Loading invalidates again, so nothing is lost by skipping it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
@dalexsoto Fixed in d45efbc. The guard is in I put it in the canvas because the panel isn't the only way to queue a redraw that runs after unload. A size, visibility or DPI change can queue one too, and so can the canvas's own off-thread Nothing is lost by skipping these: loading invalidates again ( Validation: built |
dalexsoto
left a comment
There was a problem hiding this comment.
The prior queued-redraw lifetime blocker is fixed in the canvas path shared by manual, size, visibility, DPI and off-thread invalidation: detached work returns before allocation/paint, pending state resets normally, and loading invalidates again.
Reviewed the complete 97-file current boundary and material integration using exact unchanged-source/previously viewed-image bridges plus the replacement guard and a separate additional-blocker search. Earlier fixes and the accepted Uno 7/CPU-rendering scope remain intact; no independent high-confidence introduced blocker remains. This is a bounded static-source review, not an executed runtime or whole-pipeline certification.
Uno.Sdk 7 ships Uno.Wasm.Bootstrap 10, which writes uno-config.js at the wwwroot root instead of package_<hash>/, adds root-absolute references to it in index.html and service-worker.js, and sets WEBAPP_PATH = '/' in the service worker. The smoke scripts still required package_*/uno-config.js, so every Pages - Deploy run on main has failed since mono#5377, and the Assemble site rewrite no longer covered the new absolute paths. Publish the Gallery and SkiaFiddle with WasmShellWebAppBasePath=./ so every bootstrapper-generated path is relative, and make the Gallery manifest's start_url and scope relative. The copies then work at /gallery-uno/, /fiddle/ and the staging prefixes without post-publish rewriting, so drop the sed rewrite from Assemble site. Each Uno app job instead checks that no root-absolute reference reappears; a violation fails that app, which the site then omits like any other failed app, so docs still publish. Update both smoke scripts to check the Uno 7 layout and to serve the app from a sub-path, so a root-absolute reference fails the smoke test instead of only breaking the deployed site. Exempt the bootstrapper's handled only-if-cached probe (net::ERR_CACHE_MISS) in both drivers, matching the existing exemption in BrowserRunningApp. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* Fix Pages deploy for the Uno 7 WASM publish layout (#5771) Uno.Sdk 7 ships Uno.Wasm.Bootstrap 10, which writes uno-config.js at the wwwroot root instead of package_<hash>/, adds root-absolute references to it in index.html and service-worker.js, and sets WEBAPP_PATH = '/' in the service worker. The smoke scripts still required package_*/uno-config.js, so every Pages - Deploy run on main has failed since #5377, and the Assemble site rewrite no longer covered the new absolute paths. Publish the Gallery and SkiaFiddle with WasmShellWebAppBasePath=./ so every bootstrapper-generated path is relative, and make the Gallery manifest's start_url and scope relative. The copies then work at /gallery-uno/, /fiddle/ and the staging prefixes without post-publish rewriting, so drop the sed rewrite from Assemble site. Each Uno app job instead checks that no root-absolute reference reappears; a violation fails that app, which the site then omits like any other failed app, so docs still publish. Update both smoke scripts to check the Uno 7 layout and to serve the app from a sub-path, so a root-absolute reference fails the smoke test instead of only breaking the deployed site. Exempt the bootstrapper's handled only-if-cached probe (net::ERR_CACHE_MISS) in both drivers, matching the existing exemption in BrowserRunningApp. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Pin Pages app validation to Playwright-supported Ubuntu 24.04 The existing smoke-test Playwright version cannot install Chromium on ubuntu-latest now that it resolves to Ubuntu 26.04. Keep the existing dependencies and run the Pages app jobs on Ubuntu 24.04 instead. Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: Ramez Ragaa <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Copilot App <[email protected]>
On .NET 9+ the WebAssembly block links Dawn's emdawnwebgpu port, whose library_webgpu.js refuses to link with emsdk's -sUSE_WEBGPU. The Uno block added that flag unconditionally, so an Uno 6.x WASM app with the Skia renderer failed to link with "To use Dawn's library_webgpu.js, disable -sUSE_WEBGPU". Only net8.0 (emsdk 3.1.34) still uses the built-in WebGPU port, so add the flag only there. Main no longer has the flag at all (the Uno block went with the Uno 7 move in #5377, and .NET 8 WASM support was dropped). Co-authored-by: Claude Opus 5.5 <[email protected]>
Description
Moves
SkiaSharp.Views.Uno.WinUIand the Uno samples to Uno Platform 7 and .NET 10.Uno Platform 7 removed the native Android, iOS, and WASM DOM renderers. Every Uno target now uses the same plain
netXUno assembly, so the views package no longer needs the separate.Skiaand.Wasmruntime projects, per-platform implementations, JavaScript bridge, oruno-runtimepackaging.SKXamlCanvasandSKSwapChainPanelare each implemented in one source file, and the package contains the commonnetXassembly plus its WinAppSDK facade.SKSwapChainPanelnow provides a compatible CPU-rendered fallback on Uno targets by hostingSKXamlCanvas. Redraw requests are deferred and coalesced soPaintSurfacehandlers can safely callInvalidate()without re-entering themselves. Uno'sSKCanvasElementremains the preferred GPU-backed control outside WinAppSDK.The Uno samples move to
Uno.Sdk 7.0.0-dev.79, use the Uno 7 Android hosting model, explicitly pin the in-tree SkiaSharp and HarfBuzzSharp package cohorts, and include updated responsive layouts and Android back-button handling. The Uno drawing goldens were refreshed for the rendering differences introduced by Uno 7.The PR also removes code paths that are outside the supported product matrix: pre-Uno 7 WasmShell integration, the obsolete Uno WASM mini-test, and unreachable UWP/.NET Standard 1.x and old Uno native-renderer branches. Active
SkiaSharp,HarfBuzzSharp,SkiaSharp.Views, Blazor, and modern .NET WebAssembly behavior is unchanged by that cleanup.All restores use the repository mirrors and staged artifacts; the temporary
nuget.orgsource has been removed.Related issues
Fixes #5174
Required skia PR
None.
Areas affected
binding/)externals/skia/src/c,include/c)Changes
Public API
SkiaSharp.Views.Uno.WinUInow targets .NET 10 and later plus the WinAppSDK TFMs. The previous .NET 9 and per-platform Android, iOS, Mac Catalyst, macOS, and WASM assemblies are removed.Behavior
SKSwapChainPanelrenders on the CPU on Uno targets.GRContextisnull, andBackendRenderTargetdescribes the raster surface with framebuffer 0.SKSwapChainPanel.Invalidate()is deferred and coalesced to prevent recursivePaintSurfacere-entry.EnableRenderLoopredraws only while the control is loaded and visible.DrawInBackgroundremains unimplemented.SkiaSharp.Views.WinUIand its GPU-backedSKSwapChainPanel.Testing
dotnet build source/SkiaSharp.Views.Uno/SkiaSharp.Views.Uno.WinUI/SkiaSharp.Views.Uno.WinUI.csproj -f net10.0 -c Release --no-restore— passed.tests/Goldens/Samples/*/Uno/were updated from CI output.Checklist
Changesabove lists all public API and behavioral changes (or "None.")///documentation and regenerated bindings when applicablemono/skiaPR linked above and bindings regenerated