SkiaSharp icon indicating copy to clipboard operation
SkiaSharp copied to clipboard

[BUG] `libSkiaSharp.dll` Requires `d3d12.dll` in `3.119.0`, Causing Crashes on Win7

Open IDXGI opened this issue 7 months ago • 8 comments

Description

Since 3.119.0-preview.1.2, SkiaSharp supports D3D12 rendering, but not all Windows has D3D12. I update to 3.119 then got a crash on Windows7.

SkiaSharp even doesn't depend on OpenGL, it can use CPU to render by default, but added a D3D12 dependency, is this a good idea?

Image
Image
Image

Code

using SkiaSharp;
namespace SkiaSharpCrashTest
{
   internal class Program
   {
      static void Main(string[] args)
      {
         Console.WriteLine("Before");

         // Force to load libSkiaSharp.dll
         var fontMgr = SKFontManager.Default;

         Console.WriteLine("After");
      }
   }
}

Expected Behavior

No response

Actual Behavior

No response

Version of SkiaSharp

3.119.0-preview.1.2

Last Known Good Version of SkiaSharp

3.118.0-preview.2.3

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

Windows

Platform / Operating System Version

No response

Devices

No response

Relevant Screenshots

No response

Relevant Log Output


Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

IDXGI avatar May 06 '25 04:05 IDXGI

Yes, this problem will cause the version to crash under win7, which was also encountered.

JK62333 avatar May 17 '25 08:05 JK62333

Windows 7 is out of support, so IMHO it's reasonable for SkiaSharp not to support it either. Maybe you can use the Microsoft.Direct3D.D3D12On7 NuGet as a workaround? Though that hasn't been updated in years either.

molesmoke avatar May 26 '25 21:05 molesmoke

This has nothing to do with Win7 systems. Just like OpenGL, D3D12 should be treated as a dynamic dependency of Skia, not a direct dependency. Without manually turning it on, Skia uses CPU rendering by default, D3D12 is mostly idle, and a direct dependency adds bulk and introduces compatibility issues.

There are also many computers that only have D3D11, like Win8, or have glitches in D3D12. It shouldn't cause numerous compatibility issues because of a less common dependency. That's not a good software engineering design solution.

IDXGI avatar May 27 '25 02:05 IDXGI

Thanks for this issue. I will see what I can do for this.

mattleibow avatar May 27 '25 11:05 mattleibow

This has nothing to do with Win7 systems.

You can hopefully forgive my confusion given the title of the issue and its description 😆

But yeah, from the perspective that it could/should be an optional/dynamic dependency, I agree.

molesmoke avatar May 27 '25 22:05 molesmoke

Thanks for this issue. I will see what I can do for this.

Maybe we can make a direct12 package standalone?

Kation avatar Jun 12 '25 06:06 Kation

was there any progress with this

setiri avatar Nov 25 '25 22:11 setiri

@mattleibow Can we keep all D3D12 API and do not compile skia with D3D12 precondition? Then compile skia with D3D12 precondition and make a native dependency nuget package.

Kation avatar Nov 26 '25 06:11 Kation