-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
System.Threading.Thread.Start not supported on webassembly #9
Comments
@wieslawsoltes thanks for reporting. Yes, the I'm sorry I'm not familiar with WASM, so I don't really know what could be an alternative for it. How background tasks are executed in WASM? If you provide some tips about I'll be happy to change. |
I'm reading a little bit about it. It seems that under Mono runtime, threads can be enabled. It's described in this article. Here is a working example: AFAIK it uses |
This does not work with AvaloniaUI that use under the hood Blazor.
|
Any ideas about this?
|
I recently ran into this issue as well. My understanding is that with .net 5/6, this functionality is no longer available. That said, Task.Run() can be used, but the work should be split into small chunks to avoid blocking the UI since ultimately, its running single-threaded. References: |
https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task.run?view=net-6.0 We are running into same issue. I may take a stab at doing a port |
@wieslawsoltes could you please check if #18 allows you now to use AvaloniaEdit with WebAssembly? Thanks! |
@mattkanwisher could you take a look into the changes to see if the implementation looks good? Thanks! |
I already tested it with AvaloniaEdit and it works as expected (in Desktop). |
In WebAssembly, parsing the tokens may block the UI thread (as there is no real multithreading yet), but I guess this is not going to be an issue since the execution is split into chunks of 5ms max. BTW, the good news is that it seems that blazor real multi-threading is coming for .net 7. |
I tested but got different exception
|
@wieslawsoltes please can you share a branch in AvaloniaEdit that setups a project for WebAssembly ... so I can try it myself? I can try to provide a fix... |
I don't have that, I just copied changes into my project I originally used. I can create one in Avalonia Edit repo. |
Yes that would be ok. |
@wieslawsoltes I did some tests and I noticed that the onigwrap native dll (that provides interop between Oniguruma and dotnet managed code) is not available in wasm. I think it needs to be compiled for wasm. I don't have any experience with wasm, so any help would be appreciated. |
Sorry I do not have experience compiling for wasm either. |
Some progress: #18 (comment) But still getting issues... |
I had a go at rebuilding a test app using .NET 7 and the nightly builds of Avalonia, and using the |
Awesome thanks for the update. cc/ @danwalmsley may be interested on this topic. |
A small update on my experimenting: I managed to get an Avalonia based test app compiled in multi-threaded mode using the latest versions of your TextMateSharp Wasm package and the preview builds of SkiaSharp/HarfBuzzSharp, although I had to fiddle the native file references in Avalonia.Web.targets in order for it to pick up the right version of the binaries. However - I then fell over another issue about needing to set some CORS headers in order for the browser to allow the threading stuff to work, and I couldn't manage to get that going, so now i'm going to have a go at 'simplifying' things by trying a more self contained Avalonia.Web app rather than something that uses Blazor. /Hopes that some of the many moving pieces here might settle down when all the .NET 7 versions of everything get released! |
cc/ @danwalmsley |
TextMateSharp/src/TextMateSharp/Model/TMModel.cs
Line 63 in 43b77d5
Found while trying AvaloniaEdit running on the webassembly.
AvaloniaUI/AvaloniaEdit#201
The text was updated successfully, but these errors were encountered: