Repository navigation
[memory-leak] Dispose SKStreamAsset in ToHarfBuzzBlob non-memory-backed path - #4710
Conversation
… path The else-branch of ToHarfBuzzBlob (for non-memory-backed streams) copied bytes into CoTaskMem but its Blob release callback only freed the CoTaskMem and never disposed the consumed SKStreamAsset, leaking its native handle until finalization. Mirror the memory-backed branch by disposing the asset in the release callback. Co-authored-by: Copilot <[email protected]>
📦 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 -- 4710PowerShell / Windows: iex "& { $(irm https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.ps1) } 4710"Step 2 — Add the local NuGet source dotnet nuget add source ~/.skiasharp/hives/pr-4710/packages --name skiasharp-pr-4710More options
Or download manually from Azure Pipelines — look for the Remove the source when you're done: dotnet nuget remove source skiasharp-pr-4710 |
📊 SkiaSharp benchmarks — PR #4710⭐ this PR (full source build) vs 🌙 nightly · Linux · Windows · macOS
Highlights⏱️ Time — 🔴 36 slower · 🟢 62 faster
Full per-OS benchmark deltasLinux⏱️ Time (vs 🌙 nightly
Windows⏱️ Time (vs 🌙 nightly
macOS⏱️ Time (vs 🌙 nightly
|
📦 Artifact size reportPackages from this PR (build Total Packages
+37 package(s) unchanged (< 50.0 KB). Per-file changes
|
| File | Size |
|---|---|
🧬 android-x86 (runtimes/android-x86/native/libSkiaSharp.so) |
11.8 MB → 11.0 MB (🟢 −802.2 KB) |
README.md |
219 B → 1.9 KB (🔴 +1.7 KB) |
SkiaSharp.NativeAssets.WebAssembly
| File | Size |
|---|---|
README.md |
219 B → 1.9 KB (🔴 +1.7 KB) |
SkiaSharp.NativeAssets.WinUI
| File | Size |
|---|---|
runtimes/win-x64/native/libGLESv2.pdb |
66.6 MB → 66.5 MB (🟢 −96.0 KB) |
runtimes/win-arm64/native/libGLESv2.pdb |
64.5 MB → 64.4 MB (🟢 −80.0 KB) |
runtimes/win-x86/native/libGLESv2.pdb |
67.2 MB → 67.2 MB (🟢 −48.0 KB) |
README.md |
219 B → 1.9 KB (🔴 +1.7 KB) |
Informational only — this never blocks the PR. Native binaries are labelled by os/arch.
Description
Fixes an undisposed native-handle leak in
BlobExtensions.ToHarfBuzzBlob(this SKStreamAsset).For non-memory-backed streams,
ToHarfBuzzBlobcopies bytes intoMarshal.AllocCoTaskMemand hands a release callback to theBlob. That callback previously only freed the CoTaskMem and never disposed the consumedSKStreamAsset, leaking its native handle until finalization. The memory-backed branch already disposes the asset (() => asset.Dispose()); this change makes the else-branch consistent.Changes
source/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz/BlobExtensions.cs: disposeassetin the non-memory-backedBlobrelease callback.tests/Tests/SkiaSharp/SKShaperTest.cs: add regression testToHarfBuzzBlobDisposesNonMemoryBackedStream.Required skia PR
None.
Areas Affected
Testing
Red→green proven with the new in-repo test:
SKShaperTestsuite: 8/8 passed.No rendering change, so no screenshots.
Scope note
Framework bug (inconsistent native-handle ownership between the two branches), empirically proven via a red→green regression test. ABI-safe — internal behavior only, no signature change.
Produced automatically by the SkiaSharp agentic memory-leak-fixer workflow +
memory-leak-fixerskill.Fixes #4709