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

The WebAssembly Threading not works as expected #5469

Closed
4 of 23 tasks
mnikonov opened this issue Mar 15, 2021 · 4 comments · Fixed by #8998
Closed
4 of 23 tasks

The WebAssembly Threading not works as expected #5469

mnikonov opened this issue Mar 15, 2021 · 4 comments · Fixed by #8998
Labels
area/external Categorizes an issue or PR as being external to the Uno kind/enhancement New feature or request

Comments

@mnikonov
Copy link

mnikonov commented Mar 15, 2021

Current behavior

I have tried to update WasmThreading example to the latest dev version of Bootstrap

<PackageReference Include="Uno.Wasm.Bootstrap" Version="2.0.0-dev.167" />
<PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="2.0.0-dev.167" PrivateAssets="all" />

after that console log start showing incorrect Thread id order sequence

[tid:1] Startup
[tid:1] Waiting for completion source
[tid:2] Thread begin
[tid:2] Got task result, raising event
[tid:2] Main thread exiting
[tid:2] Waiting for event
[tid:2] Got event, terminating thread

Expected behavior

Same as was described in blog article

[tid:1] Startup
[tid:1] Waiting for completion source
[tid:2] Thread begin
[tid:2] Waiting for event
[tid:1] Got task result, raising event
[tid:1] Main thread exiting
[tid:2] Got event, terminating thread

How to reproduce it (as minimally and precisely as possible)

Workaround

I'm not sure for 100% but seems that this issue appeared after 1.3.0 bootstrapper version. So, workaround for threading is to use versions of bootstrap <= 1.3.0

Environment

Nuget Package:

  • Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia
  • Uno.SourceGenerationTasks
  • Uno.UI.RemoteControl / Uno.WinUI.RemoteControl
  • Uno.Wasm.Bootstrap / Uno.Wasm.Bootstrap.DevServer

Nuget Package Version(s):

  • Uno.Wasm.Bootstrap 2.0.0-dev.167
  • Uno.Wasm.Bootstrap.DevServer 2.0.0-dev.167

Affected platform(s):

  • iOS
  • Android
  • WebAssembly
  • WebAssembly renderers for Xamarin.Forms
  • macOS
  • Skia
    • WPF
    • GTK (Linux)
    • Tizen
  • Windows
  • Build tasks
  • Solution Templates

IDE:

  • Visual Studio 2017 (version: )
  • Visual Studio 2019 (16.10.0)
  • Visual Studio for Mac (version: )
  • Rider Windows (version: )
  • Rider macOS (version: )
  • Visual Studio Code (version: )

Relevant plugins:

  • Resharper (2020.3)

Anything else we need to know?

In my next project this issue has completely different behaviour. It not enteres to Thread body at all, I have added logging per line and getting next console output log

[tid:1] Run
[tid:1] var t = new Thread
[tid:1] t.Start

This project has next configuration

<PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netstandard2.0</TargetFramework>
    <MonoWasmRuntimeConfiguration>threads-release</MonoWasmRuntimeConfiguration>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)'=='Debug'">
    <MonoRuntimeDebuggerEnabled>true</MonoRuntimeDebuggerEnabled>
    <DefineConstants>$(DefineConstants);TRACE;DEBUG;__WASM__</DefineConstants>
    <DebugType>portable</DebugType>
    <DebugSymbols>true</DebugSymbols>
  </PropertyGroup>

...

  <PackageReference Include="SkiaSharp.NativeAssets.WebAssembly" Version="2.80.3-preview.40" />
    <PackageReference Include="SkiaSharp.Views.Uno" Version="2.80.3-preview.40" />
    <PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls.DataGrid" Version="6.1.0-build.207.gcac670e618" />
    <PackageReference Include="Uno.UI.RemoteControl" Version="3.5.1" Condition="'$(Configuration)'=='Debug'" />
    <PackageReference Include="Uno.UI.WebAssembly" Version="3.5.1" />
    <PackageReference Include="Uno.Wasm.Bootstrap" Version="2.0.0-dev.167" />
    <PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="2.0.0-dev.167" PrivateAssets="all" />
@mnikonov mnikonov added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Mar 15, 2021
@jeromelaban
Copy link
Member

Thanks for the report.

Threading support is experimental in .NET and is currently somehow available when target netstandard 2.0. It has not yet been enabled in .NET 6.

@jeromelaban jeromelaban added area/external Categorizes an issue or PR as being external to the Uno kind/enhancement New feature or request and removed difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Mar 15, 2021
@mnikonov
Copy link
Author

Hi, @jeromelaban Thanks for a quick response. The project is targeted to netstandard 2.0 and not uses .NET5 or .NET6. I would appreciate any help on this issue. The problem mainly related bootstrapper version. Actually, what I need to do is to render list of big images using skiasharp, because wasm is single thread on attempt to load big file main thread become blocked and to workaround that I have had plan to move bitmap loading logic to background

@jeromelaban
Copy link
Member

jeromelaban commented Mar 15, 2021

The support for threads is very experimental, and there's no support I can give you on that matter, unfortunately. The .NET team has threading in its backlog, but that's as far as it goes for now.

@mnikonov
Copy link
Author

according to threading in its backlog topic not only me having need to have support of SkiaSharp + Threading. One thread behaviour significantly limits uno + wasm in usecase scenarious :(. If you are writing new app using Blazor that's one story, but, when you are trying to port desktop application it completely different

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/external Categorizes an issue or PR as being external to the Uno kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants