Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] wasm-ld : error : --shared-memory is disallowed by libskia.SkOpts.o because it was not compiled with 'atomics' or 'bulk-memory' features. #2614

Open
1 task done
Maxxen opened this issue Sep 18, 2023 · 5 comments · May be fixed by #2620

Comments

@Maxxen
Copy link

Maxxen commented Sep 18, 2023

Description

Hey! Im trying to use SkiaSharp in combination with <WasmEnableThreads>true</WasmEnableThreads>, but I get the following error(s):

wasm-ld : error : --shared-memory is disallowed by libskia.SkOpts.o because it was not compiled with 'atomics' or 'bulk-memory' features.
wasm-ld : error : <....>/obj/Debug/net8.0/wasm/for-build/pinvoke.o: undefined symbol: InterceptGLObject
...

I do get the -msimd128 flag passed way down the end though.

It seems like a similar issue has been solved previously (#2286), although I have not been able to get it working either on net7 + 2.88.4 or on the latest net8 RC1 and 2.88.6-preview, so Im not sure this is a regression. As it seems like others are also still running into this I'm guessing this never worked completely in the first place? Is there some flag I need to pass in <EmccExtraCFlags> or <EmccExtraLDFlags>?

My IDE is Rider.

Code

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <WasmBuildNative>true</WasmBuildNative>
    <RunAOTCompilation>true</RunAOTCompilation>
    <WasmEnableThreads>true</WasmEnableThreads>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0-rc.1.23421.29" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0-rc.1.23421.29" PrivateAssets="all" />
    <PackageReference Include="Microsoft.NET.WebAssembly.Threading" Version="8.0.0-rc.1.23419.4" />
    <PackageReference Include="SkiaSharp.NativeAssets.WebAssembly" Version="2.88.6-preview.1.2" />
    <PackageReference Include="SkiaSharp.Views.Blazor" Version="2.88.6-preview.1.2" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Shared\Project.Shared.csproj" />
  </ItemGroup>

</Project>

Expected Behavior

No response

Actual Behavior

No response

Version of SkiaSharp

Other (Please indicate in the description)

Last Known Good Version of SkiaSharp

Other (Please indicate in the description)

IDE / Editor

Other (Please indicate in the description)

Platform / Operating System

macOS

Platform / Operating System Version

No response

Devices

No response

Relevant Screenshots

No response

Relevant Log Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@mattleibow
Copy link
Contributor

mattleibow commented Sep 18, 2023

Thanks for reporting this. I believe it is because we are including the wrong build of libSkiaSharp in your multi-threading blazor app.

I have some PRs to fix it, but for now, adding this to the csproj will/should fix it. I just typed this, so let me know:

<ItemGroup>
  <!-- remove all previous native files -->
  <NativeFileReference Remove="@(SkiaSharpStaticLibrary)" />
  <!-- include the multi-threaded build if WasmEnableThreads=true -->
  <NativeFileReference Include="$(SkiaSharpStaticLibraryPath)\3.1.34\mt\*.a" Condition="'$(WasmEnableThreads)' == 'True'" />
  <!-- otherwise use the single threaded build -->
  <NativeFileReference Include="$(SkiaSharpStaticLibraryPath)\3.1.34\st\*.a" Condition="'$(WasmEnableThreads)' != 'True'" />
</ItemGroup>

@Maxxen
Copy link
Author

Maxxen commented Sep 18, 2023

Thanks for the quick reply!
The workaround you posted seems to work - it compiles at least, so I'm guessing its all good!

Also just want to say thanks for all the work you guys are doing on this, I've tried to work with SKIA natively previously so I have a lot of respect for anybody capable to deal with it efficiently and Im super stoked for all the possibilities this enables. Kudos!

@ghost
Copy link

ghost commented Sep 22, 2023

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

@mattleibow
Copy link
Contributor

How are you currently running things? I have a new project and added:

<WasmEnableThreads>true</WasmEnableThreads>
<WasmBuildNative>true</WasmBuildNative>

But I am getting errors:

MONO_WASM: Assert failed: Expect to have one js-module-threads asset in resources

@mattleibow
Copy link
Contributor

Seems that most of this does not work in .NET 8 Blazor, and things are coming to .NET 9. I will fix this so we are ready for net9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants