Repository navigation
Fix x86 .NET Framework threading test OOM failures (#3608) - #3674
Merged
Merged
Conversation
Contributor
📦 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 -- 3674PowerShell / Windows: iex "& { $(irm https://raw.githubusercontent.com/mono/SkiaSharp/main/scripts/get-skiasharp-pr.ps1) } 3674"Step 2 — Add the local NuGet source dotnet nuget add source ~/.skiasharp/hives/pr-3674/packages --name skiasharp-pr-3674More options
Or download manually from Azure Pipelines — look for the Remove the source when you're done: dotnet nuget remove source skiasharp-pr-3674 |
Contributor
|
📖 Documentation Preview The documentation for this PR has been deployed and is available at: 🔗 View Staging Site This preview will be updated automatically when you push new commits to this PR. This comment is automatically updated by the documentation staging workflow. |
mattleibow
marked this pull request as ready for review
April 15, 2026 12:44
mattleibow
force-pushed
the
dev/issue-3608-fix-x86-threading-tests
branch
from
April 15, 2026 14:02
41e7576 to
b558338
Compare
mattleibow
force-pushed
the
dev/issue-3608-fix-x86-threading-tests
branch
9 times, most recently
from
April 16, 2026 00:27
ed50375 to
cec90da
Compare
mattleibow
force-pushed
the
dev/issue-3608-fix-x86-threading-tests
branch
from
April 16, 2026 01:53
cec90da to
7d7b6c9
Compare
5 tasks
mattleibow
force-pushed
the
dev/issue-3608-fix-x86-threading-tests
branch
from
April 24, 2026 03:07
18d641d to
31a55e0
Compare
On x86 (.NET Framework), address space is limited to 2GB. The (100 threads × 1000 iterations) and (1000 iterations) stress tests create too many undisposed native allocations simultaneously, causing the GC finalizer queue to fall behind and Skia's allocator to fail. Fix: skip the known-OOM combinations on x86, and add lighter-weight intermediate variants (10×100 and 100 iterations) so concurrent GC/finalizer behavior is still exercised at lower load. Co-authored-by: Copilot <[email protected]>
mattleibow
force-pushed
the
dev/issue-3608-fix-x86-threading-tests
branch
from
April 24, 2026 03:08
31a55e0 to
a8c73f4
Compare
mattleibow
added a commit
that referenced
this pull request
May 30, 2026
Backport of #3674 to release/3.119.x. SKBitmapThreadingTest.ImageScalingMultipleThreadsTest and SKObjectTest.EnsureMultithreadingDoesNotThrow intentionally create native SkiaSharp objects WITHOUT disposing them, so they are reclaimed only by the GC and finalizer thread. This is deliberate: the tests verify that SkiaSharp objects can be finalized safely from many threads concurrently. Adding deterministic disposal would defeat the purpose of the tests. On x86 (.NET Framework, 2GB address space) the heaviest variants queue too many undisposed native allocations for the finalizer to keep up, so Skia's allocator fails ("Unable to allocate pixels"). This is a genuine address-space limit, not a leak: the 64-bit .NET Core jobs pass. Fix (matching main): skip the known-OOM combinations on x86 and add lighter intermediate variants (10x100 and 100) so concurrent GC/finalizer behavior is still exercised at lower load. Also add comments documenting the test purpose and that disposal is intentionally omitted. Co-authored-by: Copilot <[email protected]>
This was referenced May 30, 2026
mattleibow
added a commit
that referenced
this pull request
Jun 2, 2026
Fix x86 .NET Framework threading test OOM failures (#4105) Backport of #3674 to release/3.119.x. Fixes #3608 Context: #3674 Fixes: chronically-red "Windows (.NET Framework)" (net48/x86) Tests job on release/3.119.x The internal Tests pipeline on release/3.119.x has been red for months. The failing job is Windows (.NET Framework) on x86, where SKBitmapThreadingTest.ImageScalingMultipleThreadsTest(100, 1000) and SKObjectTest.EnsureMultithreadingDoesNotThrow(1000) throw "Unable to allocate pixels for the bitmap", with adjacent tests dying as collateral in the same starved process. These tests intentionally create native SkiaSharp objects without disposing them so they are reclaimed only by the GC and finalizer thread — that is the point of the tests: they verify SkiaSharp objects can be finalized safely from many threads concurrently. Disposing would defeat the purpose (an earlier "add using" attempt was wrong and was reverted). The real cause is an environment limit: on x86 (.NET Framework, 2 GB address space) the heaviest variants queue more undisposed native allocations than the finalizer can keep pace with, so Skia's allocator fails. The 64-bit .NET Core jobs have enough address space and pass. * Skip the known-OOM combinations on x86 only (IntPtr.Size == 4) — a sanctioned environment skip, not masking a product bug. * Add lighter intermediate variants (10x100 and 100) so concurrent GC/finalizer behavior is still exercised on x86 at lower load. * Document the test purpose and that disposal is intentionally omitted, so future readers don't "fix" it by adding using. Touches tests only: tests/SkiaSharp.Tests.Console/SkiaSharp/SKBitmapThreadingTest.cs and tests/Tests/SkiaSharp/SKObjectTest.cs (+28/-0). Validated by a full pipeline run that built natives fresh in-run (3.119.5-preview.0.3+merge): all stages succeeded, including every Tests-stage job. The previously chronically-red net48/x86 job now passes. Co-authored-by: Copilot <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Investigation: Fix x86 .NET Framework threading test OOM (#3608)
Problem
Two multithreading tests fail consistently on Windows .NET Framework x86 (net472-x86) with
Unable to allocate pixels for the bitmapdue to x86 2GB address space exhaustion. Hits 8/15 recent main builds (53%).Related Issues
Fixes #3608