Skip to content

fix(sdk): align Linux SkiaSharp native asset on desktop - #23659

Merged
agneszitte merged 2 commits into
masterfrom
dev/mazi/sdk-skiasharp-linux-nativeassets
Jul 6, 2026
Merged

agneszitte merged 2 commits into
masterfrom
dev/mazi/sdk-skiasharp-linux-nativeassets

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

GitHub Issue: closes #23658

PR Type:

🐞 Bugfix

What changed? 🚀

On a Skia Desktop single-project head (net*-desktop), overriding <SkiaSharpVersion> above the version the Uno.Sdk ships did not retarget SkiaSharp.NativeAssets.Linux. Managed SkiaSharp and the Win32/macOS native assets moved to the requested version, but the Linux native libSkiaSharp.so stayed at the transitive floor referenced by the Uno.WinUI.Runtime.Skia.X11 / Uno.WinUI.Runtime.Skia.Linux.FrameBuffer runtime packs — a silent managed/native ABI mismatch that crashed Skia Desktop on Linux at startup (no build or restore diagnostic).

Root cause: the base SkiaSharp package auto-depends on SkiaSharp.NativeAssets.Win32 and .macOS (in every desktop/generic TFM group, at its own version), so those self-align on a managed bump — but it has no SkiaSharp.NativeAssets.Linux dependency in any group (Linux native is opt-in). Meanwhile the Uno.Sdk only injected the Linux native asset for the legacy *.Skia.Linux.FrameBuffer head, never for the modern single-project desktop head. With no top-level reference to bind to, SkiaSharpVersion (and the documented PackageReference Update fallback) had nothing to retarget, so the transitive floor won.

Fix: inject SkiaSharp.NativeAssets.Linux as an implicit package for executable desktop heads — in the same $(_IsExecutable) item group that already pulls the X11/FrameBuffer runtime packs. Because the package is already part of the Uno.Sdk SkiaSharp version group, SkiaSharpVersion now retargets it in one place, making the Using the Skia Desktop docs' promise actually hold, and mirroring both the legacy FrameBuffer head and SkiaSharp's own Win32/macOS behavior. This also aligns the default (non-overridden) case, where the Linux native previously resolved one patch below managed.

Validation:

  • NuGet-resolution repro (root cause + fix mechanism): a minimal Uno.WinUI.Runtime.Skia.X11 6.5.237 + SkiaSharp 4.148.0 project resolves managed + NativeAssets.Win32 + NativeAssets.macOS to 4.148.0 while NativeAssets.Linux stays at 3.119.0, with no restore warning/error. Adding a top-level SkiaSharp.NativeAssets.Linux 4.148.0 reference — exactly what this change injects — realigns it to 4.148.0.
  • Code review: the injection mirrors the existing Uno.Implicit.Packages.ProjectSystem.Legacy.targets pattern, and ImplicitPackagesResolver already routes SkiaSharpVersion into the SkiaSharp group so the injected reference is emitted at the overridden version.
  • The full Uno.Sdk-pack + consumer-restore end-to-end was not run in this environment (heavy Sdk packaging pipeline); happy to run it on request.

Related latent gaps tracked for follow-up (out of scope here to keep the backport minimal): HarfBuzzSharp.NativeAssets.Linux shares the same floor mechanism, and the WebAssembly native asset is structurally similar (managed SkiaSharp has no wasm dependency).

PR Checklist ✅

  • 🧪 Added Runtime/UI tests or a manual sample — build-system (MSBuild targets) change; there is no runtime-test harness for implicit-package resolution, so it is validated via the NuGet-resolution repro above.
  • 📚 Docs updated — the existing Using the Skia Desktop → "Upgrading to a later version of SkiaSharp" guidance becomes accurate with this fix; no doc change required.
  • ❗ Contains NO breaking changes.

The base SkiaSharp package auto-references its Win32/macOS native assets
but not the Linux one, so overriding SkiaSharpVersion on a Skia Desktop
head left SkiaSharp.NativeAssets.Linux at the transitive floor from the
X11/FrameBuffer runtime packs — a silent managed/native mismatch that
crashed Skia Desktop on Linux at startup. Inject it as an implicit
package for executable desktop heads so SkiaSharpVersion retargets it,
mirroring how the legacy FrameBuffer head and SkiaSharp's own Win32/macOS
dependencies already behave.

fixes #23658

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_018xXm9Kn9hR9vXncVvjPQnT
Copilot AI review requested due to automatic review settings July 6, 2026 14:27
@github-actions

github-actions Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 3m 10s —— View job


Review complete

  • Gather context
  • Read changed file and related targets
  • Review the change
  • Post findings

Verdict: LGTM — clean fix, no blocking issues.

What was reviewed:

  • Uno.Implicit.Packages.ProjectSystem.Desktop.targets — the only changed file
  • Uno.Implicit.Packages.ProjectSystem.Legacy.targets — the existing pattern this mirrors
  • Uno.Implicit.Packages.targets — confirms _UnoProjectSystemPackageReference items are the real build-time injection path (not design-time only)
  • Uno.Common.targets — confirms _IsExecutable is set before this targets file is evaluated
  • packages.json — confirms SkiaSharp.NativeAssets.Linux is already in the SkiaSharp version group, so SkiaSharpVersion overrides it correctly

Observations:

  1. Correct placement — $(_IsExecutable) == 'true' is the same condition as the surrounding runtime pack injections (X11, Win32, macOS, FrameBuffer). _IsExecutable is set in Uno.Common.targets before Uno.Implicit.Packages.targets is imported, so the condition is always evaluated correctly.

  2. No double injection — Desktop.targets is only imported when GetTargetPlatformIdentifier == 'desktop'; Legacy.targets (which already injects SkiaSharp.NativeAssets.Linux for FrameBuffer) is only imported when the platform identifier is empty. These are mutually exclusive conditions.

  3. Version routing is wired up — SkiaSharp.NativeAssets.Linux is already in the SkiaSharp group in packages.json, so the SkiaSharpVersion override flows through ImplicitPackagesResolver_v0 to emit this reference at the correct version.

  4. Publish-time safety — _UnoRemoveSkiaNativeLibraries in Uno.SingleProject.Desktop.targets already strips non-applicable native assets (it handles both libSkiaSharp and libHarfBuzzSharp) at publish time, so adding the Linux native asset to non-Linux desktop builds doesn't inflate publish output on Win32/macOS.

  5. HarfBuzzSharp.NativeAssets.Linux follow-up noted — HarfBuzzSharp has no entry in packages.json, so the same one-liner fix is not available for it; deferring is the right call.

Minor (non-blocking): The XML comment is four lines, which is on the verbose side for a .targets file, but the behavior it describes (SkiaSharp's Win32/macOS auto-deps vs. opt-in Linux dep) is genuinely non-obvious from the code, so the extra detail earns its place here.

No inline issues to report.

@MartinZikmund

Copy link
Copy Markdown
Member Author

@Mergifyio backport release/stable/6.6

@MartinZikmund MartinZikmund added the kind/bug Something isn't working label Jul 6, 2026
@mergify

mergify Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

backport release/stable/6.6

✅ Backports have been created

Details

Cherry-pick of a973552 has failed:

On branch mergify/bp/release/stable/6.6/pr-23659
Your branch is up to date with 'origin/release/stable/6.6'.

You are currently cherry-picking commit a9735520de.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   src/Uno.Sdk/targets/Uno.Implicit.Packages.ProjectSystem.Desktop.targets

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@MartinZikmund

Copy link
Copy Markdown
Member Author

@MartinZikmund
MartinZikmund requested a review from ramezgerges July 6, 2026 14:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a NuGet resolution gap in the Uno.Sdk desktop (Skia) implicit-package injection so that overriding SkiaSharpVersion also retargets the Linux native libSkiaSharp.so package, preventing a silent managed/native ABI mismatch on Linux desktop heads.

Changes:

  • Inject SkiaSharp.NativeAssets.Linux as an implicit package for executable net*-desktop heads (alongside the existing X11/FrameBuffer runtime packs).
  • Add an explanatory comment documenting the NuGet behavior/root cause and why the injection is needed.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Add a regression check to the Linux template-app job: restore the
net10.0-desktop template head with an overridden SkiaSharpVersion and
assert SkiaSharp.NativeAssets.Linux resolves to the same version as
managed SkiaSharp. Fails before the SDK injection fix, passes after.

refs #23658

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_018xXm9Kn9hR9vXncVvjPQnT
@github-actions github-actions Bot added the area/build Categorizes an issue or PR as relevant to build infrastructure label Jul 6, 2026
@MartinZikmund

Copy link
Copy Markdown
Member Author

Added a CI regression guard (2nd commit): the Linux template-app job now restores the uno56netcurrent net10.0-desktop head with -p:SkiaSharpVersion=4.148.0 and asserts SkiaSharp.NativeAssets.Linux resolves to 4.148.0 (matching managed SkiaSharp). This fails on master today and passes with the SDK injection in this PR — locally reproduced with a public-package project (Uno.WinUI.Runtime.Skia.X11 + SkiaSharp 4.148.0) where the Linux native otherwise stays stuck at the runtime-pack floor 3.119.0 with no restore warning. The full Uno.Sdk-pack + consumer-restore path is exercised by this job on the built SDK.

@github-actions

github-actions Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 2m 7s —— View job


Review complete

  • Gather context
  • Read changed files and related targets
  • Review the change
  • Post findings

Verdict: LGTM — clean fix, no blocking issues found.

What was reviewed (2nd commit additions)

  • build/test-scripts/run-net7-template-linux.ps1 — new regression guard at the end of the script
  • src/Uno.Sdk/targets/Uno.Implicit.Packages.ProjectSystem.Desktop.targets — SkiaSharp.NativeAssets.Linux injection (already reviewed in the first pass, no changes)

Observations on the regression guard

  1. Correct gate — $TestGroup -eq '1' matches the group that already builds uno56netcurrent, so no new group is needed and the test reuses an already-restored project.

  2. dotnet restore correctly overwrites obj/project.assets.json — running after the main loop ensures the prior build's cached assets don't interfere; the override restore produces a fresh assets file for the check.

  3. Regex check is safe — [regex]::Escape("SkiaSharp.NativeAssets.Linux/4.148.0") escapes the . so the dot in the version number is literal, not a wildcard. The project.assets.json format uses "SkiaSharp.NativeAssets.Linux/4.148.0" as a library key, so the substring match is valid.

  4. 4.148.0 is a meaningful sentinel — the PR description confirms the runtime-pack floor is 3.119.0, so 4.148.0 is genuinely above the floor. Without the fix, the asset stays at 3.119.0 and the test fails; with the fix it resolves to 4.148.0.

  5. Binlog path — binlogs/skiasharp-linux-alignment/restore.binlog is a new unique path; MSBuild creates parent directories for binlog output automatically.

  6. Publish safety unchanged — _UnoRemoveSkiaNativeLibraries in Uno.SingleProject.Desktop.targets still strips non-applicable native assets at publish time, so the Linux native package being referenced in Win32/macOS builds doesn't inflate publish output.

Non-blocking note: The obj/project.assets.json path is hardcoded. If the template ever moves its intermediate output path (via ArtifactsPath or BaseIntermediateOutputPath), the check would fail to find the file silently. Given template projects don't do this, it's acceptable for now.

No inline issues to report.

@unodevops

Copy link
Copy Markdown
Contributor

@unoplatform unoplatform deleted a comment from mergify Bot Jul 6, 2026
@mergify

mergify Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@agneszitte
agneszitte merged commit df9e937 into master Jul 6, 2026
65 checks passed
@agneszitte
agneszitte deleted the dev/mazi/sdk-skiasharp-linux-nativeassets branch July 6, 2026 19:43
agneszitte added a commit that referenced this pull request Jul 6, 2026
Keep 6.6's WPF RDP hardware-acceleration RuntimeHostConfigurationOption
alongside the SkiaSharp.NativeAssets.Linux injection backported from #23659.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
agneszitte added a commit that referenced this pull request Jul 6, 2026
…6.6/pr-23659

fix(sdk): align Linux SkiaSharp native asset on desktop (backport #23659)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build Categorizes an issue or PR as relevant to build infrastructure kind/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SkiaSharpVersion override does not retarget SkiaSharp.NativeAssets.Linux on Skia Desktop (managed/native mismatch → startup crash)

5 participants