Skip to content

Commit 68a626f

Browse files
authored
Fix .NET 9 WASM incompatibility by updating SkiaSharp.WASM package (#17362)
* Bump SkiaSharp versions * Include .NET 9 compatible SkiaSharp binaries * Minor warning fix * Bump HarfBuzz too
1 parent 0944e04 commit 68a626f

File tree

5 files changed

+26
-19
lines changed

5 files changed

+26
-19
lines changed

build/HarfBuzzSharp.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<ItemGroup>
33
<PackageReference Include="HarfBuzzSharp" Version="7.3.0.2" />
44
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.Linux" Version="7.3.0.2" />
5-
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.WebAssembly" Version="7.3.0.2" />
5+
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.WebAssembly" Version="7.3.0.3-preview.2.2" />
66
</ItemGroup>
77
</Project>

build/SkiaSharp.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<ItemGroup Condition="'$(AvsIncludeSkiaSharp3)' != 'true'">
33
<PackageReference Include="SkiaSharp" Version="2.88.8" />
44
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="2.88.8" />
5-
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="SkiaSharp.NativeAssets.WebAssembly" Version="2.88.8" />
5+
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="SkiaSharp.NativeAssets.WebAssembly" Version="2.88.9-preview.2.2" />
66
</ItemGroup>
77
<ItemGroup Condition="'$(AvsIncludeSkiaSharp3)' == 'true'">
8-
<PackageReference Include="SkiaSharp" Version="3.0.0-preview.3.1" />
9-
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="3.0.0-preview.3.1" />
10-
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="SkiaSharp.NativeAssets.WebAssembly" Version="3.0.0-preview.3.1" />
8+
<PackageReference Include="SkiaSharp" Version="3.0.0-preview.5.4" />
9+
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="3.0.0-preview.5.4" />
10+
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="SkiaSharp.NativeAssets.WebAssembly" Version="3.0.0-preview.5.4" />
1111
</ItemGroup>
1212
</Project>

src/Browser/Avalonia.Browser/build/Avalonia.Browser.props

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<Project>
22
<PropertyGroup>
33
<AvaloniaAllowWebGl2 Condition="'$(AvaloniaAllowWebGl2)' == ''">true</AvaloniaAllowWebGl2>
4-
<ShouldIncludeAvaloniaAssets Condition=" '$(ShouldIncludeAvaloniaAssets)' == '' ">True</ShouldIncludeAvaloniaAssets>
5-
<ShouldIncludeAvaloniaLegacyAssets Condition=" '$(ShouldIncludeAvaloniaLegacyAssets)' == '' AND '$(ShouldIncludeAvaloniaAssets)' == 'True'">True</ShouldIncludeAvaloniaLegacyAssets>
6-
<ShouldIncludeAvaloniaStaticAssets Condition=" '$(ShouldIncludeAvaloniaStaticAssets)' == '' AND '$(ShouldIncludeAvaloniaAssets)' == 'True'">True</ShouldIncludeAvaloniaStaticAssets>
7-
8-
<ShouldIncludeNativeSkiaSharp Condition=" '$(ShouldIncludeNativeSkiaSharp)' == '' ">True</ShouldIncludeNativeSkiaSharp>
9-
<ShouldIncludeNativeHarfBuzzSharp Condition=" '$(ShouldIncludeNativeHarfBuzzSharp)' == '' ">True</ShouldIncludeNativeHarfBuzzSharp>
4+
<ShouldIncludeAvaloniaAssets Condition=" '$(ShouldIncludeAvaloniaAssets)' == '' ">true</ShouldIncludeAvaloniaAssets>
5+
<ShouldIncludeAvaloniaLegacyAssets Condition=" '$(ShouldIncludeAvaloniaLegacyAssets)' == '' AND '$(ShouldIncludeAvaloniaAssets)' == 'true'">true</ShouldIncludeAvaloniaLegacyAssets>
6+
<ShouldIncludeAvaloniaStaticAssets Condition=" '$(ShouldIncludeAvaloniaStaticAssets)' == '' AND '$(ShouldIncludeAvaloniaAssets)' == 'true'">true</ShouldIncludeAvaloniaStaticAssets>
7+
8+
<ShouldIncludeNativeSkiaSharp Condition=" '$(ShouldIncludeNativeSkiaSharp)' == '' ">true</ShouldIncludeNativeSkiaSharp>
9+
<ShouldIncludeNativeHarfBuzzSharp Condition=" '$(ShouldIncludeNativeHarfBuzzSharp)' == '' ">true</ShouldIncludeNativeHarfBuzzSharp>
1010
</PropertyGroup>
1111

1212
<Import Project="$(MSBuildThisFileDirectory)/../build/Microsoft.AspNetCore.StaticWebAssets.props" />
Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<Project>
22
<PropertyGroup>
33
<EmccFlags Condition="'$(AvaloniaAllowWebGl2)' == 'true'">$(EmccFlags) -sUSE_WEBGL2=1 -sMAX_WEBGL_VERSION=2 -lGL </EmccFlags>
4+
<_AvNativeBinaryType Condition="'$(WasmEnableThreads)' == 'True'">mt</_AvNativeBinaryType>
5+
<_AvNativeBinaryType Condition="'$(WasmEnableThreads)' != 'True'">st</_AvNativeBinaryType>
46
</PropertyGroup>
57

68
<ItemGroup>
@@ -10,22 +12,27 @@
1012
</ItemGroup>
1113

1214
<!-- Fallback for applications without StaticWebAssetsEnabled (legacy WASM SDK) -->
13-
<ItemGroup Condition="'$(ShouldIncludeAvaloniaLegacyAssets)' == 'True'">
15+
<ItemGroup Condition="'$(ShouldIncludeAvaloniaLegacyAssets)' == 'true'">
1416
<WasmExtraFilesToDeploy Condition="'$(WasmRuntimeAssetsLocation)' == ''" Include="$(MSBuildThisFileDirectory)/../staticwebassets/**/*.*" />
1517
<WasmExtraFilesToDeploy Condition="'$(WasmRuntimeAssetsLocation)' != ''" Include="$(MSBuildThisFileDirectory)/../staticwebassets/**/*.*" TargetPath="$(WasmRuntimeAssetsLocation)/%(FileName)%(Extension)" />
1618
</ItemGroup>
1719

18-
<PropertyGroup Condition="'$(ShouldIncludeNativeSkiaSharp)' == 'True' or '$(ShouldIncludeNativeHarfBuzzSharp)' == 'True'">
20+
<PropertyGroup Condition="'$(ShouldIncludeNativeSkiaSharp)' == 'true' or '$(ShouldIncludeNativeHarfBuzzSharp)' == 'true'">
1921
<WasmBuildNative Condition="'$(WasmBuildNative)' == ''">true</WasmBuildNative>
2022
</PropertyGroup>
2123

22-
<ItemGroup Condition="'$(TargetFrameworkVersion)' != '' and '$(ShouldIncludeNativeSkiaSharp)' == 'True'">
23-
<NativeFileReference Include="$(SkiaSharpStaticLibraryPath)/3.1.34/mt/*.a" Condition="'$(WasmEnableThreads)' == 'True'" />
24-
<NativeFileReference Include="$(SkiaSharpStaticLibraryPath)/3.1.34/st/*.a" Condition="'$(WasmEnableThreads)' != 'True'" />
24+
<!-- Revisit after https://github.com/mono/SkiaSharp/pull/2620 is merged and released. -->
25+
<ItemGroup Condition="'$(TargetFrameworkVersion)' != '' and '$(ShouldIncludeNativeSkiaSharp)' == 'true'">
26+
<NativeFileReference Include="$(SkiaSharpStaticLibraryPath)\3.1.34\$(_AvNativeBinaryType)\*.a"
27+
Condition="$([MSBuild]::VersionEquals($(TargetFrameworkVersion), '8.0'))" />
28+
<NativeFileReference Include="$(SkiaSharpStaticLibraryPath)\3.1.56\$(_AvNativeBinaryType)\*.a"
29+
Condition="$([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '9.0'))" />
2530
</ItemGroup>
2631

2732
<ItemGroup Condition="'$(TargetFrameworkVersion)' != '' and '$(ShouldIncludeNativeHarfBuzzSharp)' == 'True'">
28-
<NativeFileReference Include="$(HarfBuzzSharpStaticLibraryPath)/3.1.34/st/*.a" Condition="'$(WasmEnableThreads)' != 'True'" />
29-
<NativeFileReference Include="$(HarfBuzzSharpStaticLibraryPath)/3.1.34/mt/*.a" Condition="'$(WasmEnableThreads)' == 'True'" />
33+
<NativeFileReference Include="$(HarfBuzzSharpStaticLibraryPath)\3.1.34\$(_AvNativeBinaryType)\*.a"
34+
Condition="$([MSBuild]::VersionEquals($(TargetFrameworkVersion), '8.0'))" />
35+
<NativeFileReference Include="$(HarfBuzzSharpStaticLibraryPath)\3.1.56\$(_AvNativeBinaryType)\*.a"
36+
Condition="$([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '9.0'))" />
3037
</ItemGroup>
3138
</Project>

src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ public static (IXamlType Target, IXamlType? DataContextType)? GetTargetType(IXam
458458

459459
var finder = new ScopeRegistrationFinder(name);
460460
namescopeRoot.Visit(finder);
461-
return finder.TargetType is not null ? (finder.TargetType, DataType: finder.DataContextType) : null;
461+
return finder.TargetType is not null ? (finder.TargetType, finder.DataContextType) : null;
462462
}
463463

464464
void IXamlAstVisitor.Pop()

0 commit comments

Comments
 (0)