You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I saw the package TextmateSharp.Wasm.
Is it possible to run with AvaloniaEdit?
For me AvaloniaEdit alone works in Wasm. As soon as I add some highlighting it breaks, with or without the TextMateSharp.Wasm package.
Maybe I am not doing it right, since I didn't see any demo project for this
Is there any progress on this problem? Seems like TextMate.Wasm package exists, but installing it doesn't change anything - app still hangs while applying coloring to AvaloniaEdit.
It worked some time ago but I didn't try it recently. Any clue of what the issue is?
I was never able to get WasmEnableTheads to work properly in Avalonia 11.0 (various problems occuring before it even got to the TextMateSharp bit), but I just had another try with the Avalonia 11.1 nightly and it seems to have worked:
(that's both highlighting Json and doing folding at the same time)
I was just doing some tests with the 1.0.5 onigwrap build, and had this odd situation on Firefox where the behavior varies depending if I have the browser dev tools are open:
(I'm not yet clear if my sample app is doing something wrong, or if there is a timing issue somewhere)
I also sometimes get this in the diagnostics:
Reading the linked article, it mentions setting PTHREAD_POOL_SIZE to help with this, and I see that the project linked by @hendrikmennen has _WasmPThreadPoolSize set in the project file, so maybe it could be a configuration thing?
Why any of this is different to the previous TextMateSharp.Wasm package, I don't know :-(
I've noticed that when I start deleting text from your example, I get a deadlock.
Additional note: The app I posted the screen shot from on April 4th is actually running AvaloniaEdit in read only mode, so I didn't previously test editing the json after display.
Reading the linked article, it mentions setting PTHREAD_POOL_SIZE to help with this, and I see that the project linked by @hendrikmennen has _WasmPThreadPoolSize set in the project file, so maybe it could be a configuration thing?
I can see an idle worker in dev tools, probably not the reason... Worth trying though
Why any of this is different to the previous TextMateSharp.Wasm package, I don't know :-(
Maybe because it was built with older emsdk. I will try to swap the asset with freshly built to confirm.
Judging by deadlock it should be a threading problem, dont know where to dig though
Maybe because it was built with older emsdk. I will try to swap the asset with freshly built to confirm.
Not confirmed. It works but still hangs with the same deadlock after text is erased.
I have a wild guess. The only behavior from original Onigwrap I changed was dropping IDisposable in favor of just finalizer. This was supposed to ease freeing of native resources (pattern I follow with small memory resources), but maybe mono's GC has some problems with this. I'll try to understand current state of mono threading in Wasm and see if I can do anything.
The hang that sometimes happens when changing the highlighted text does appear to work better when running on .NET 9.0
Your example with dotnet 9 works for me without any freeze. I've released a new version with a workaround that links the latest available version of the binding with dotnet 9 (at this moment the emsdk used in 8 and 9 is the same).
Honestly, I would like to wait for dotnet 9 release, it looks very promising for Wasm support. I couldn't set up a debug environment to debug Wasm though, seems like documentation in veryyy early stages 😁
The hang that sometimes happens when changing the highlighted text does appear to work better when running on .NET 9.0
Your example with dotnet 9 works for me without any freeze. I've released a new version with a workaround that links the latest available version of the binding with dotnet 9 (at this moment the emsdk used in 8 and 9 is the same).
Honestly, I would like to wait for dotnet 9 release, it looks very promising for Wasm support. I couldn't set up a debug environment to debug Wasm though, seems like documentation in veryyy early stages 😁
If I run dotnet build --getProperty:EmscriptenVersion with the .NET 9.0 RC-1 SDK then it says 3.1.34, but when I did a dotnet workload update it installed a set of 3.1.56 versions:
for the record:
I've had the minimal sample working on .NET 9, using Avalonia 11.2.1 and SkiaSharp 2.88.9, though there still seems to be a few issues with all the new versions of things (e.g. dotnet/runtime#109289) and it only presently works for me in release builds.
Also the shipping .NET 9 apparently has the wrong value for EmscriptenVersion - dotnet/runtime#108972
Reacted by Daniel Peñalba, aikawayataro and SKProCH
Activity
[-]TextMateSharp with Wasm[/-][+]TextMateSharp with Wasm not working?[/+]danipen commentedon Oct 26, 2023
TextMateSharpshould support WASM but it's possible that the AvaloniaEdit TextMate integration may not be fully prepared to work with WASM yet.SKProCH commentedon Mar 29, 2024
Hello, @danipen
Is there any progress on this problem? Seems like TextMate.Wasm package exists, but installing it doesn't change anything - app still hangs while applying coloring to AvaloniaEdit.
danipen commentedon Mar 29, 2024
It worked some time ago but I didn't try it recently. Any clue of what the issue is?
SKProCH commentedon Mar 29, 2024
Actually I think this is something related to TextMate library calls or coloring the AvaloniaEdit (perhaps a multithreading or something like that). I've actually use your library for ShowMeTheXaml editor: https://github.com/AvaloniaUtils/ShowMeTheXaml.Avalonia/blob/master/ShowMeTheXaml.Avalonia.AvaloniaEdit/XamlDisplayAvaloniaEditThemeBehavior.cs
And seems like initialization was completed successfully:
https://github.com/AvaloniaUtils/ShowMeTheXaml.Avalonia/blob/53c1c0c7e3702072a2b77560a67d4cb1abab95cf/ShowMeTheXaml.Avalonia.AvaloniaEdit/XamlDisplayAvaloniaEditThemeBehavior.cs#L27-L34
But after that apps hangs out.
Actual issue is reproduceable in Material.Avalonia demo app for browser. Here is the link: https://avaloniacommunity.github.io/Material.Avalonia/ (aim on code icons on the bottom right side of controls on any page).
Also, this issue only reproduceable in browser WASM, since NAOT app on desktop works fine.
I'd be grateful for any help to diagnose this issue.
Numpsy commentedon Apr 4, 2024
I was never able to get WasmEnableTheads to work properly in Avalonia 11.0 (various problems occuring before it even got to the TextMateSharp bit), but I just had another try with the Avalonia 11.1 nightly and it seems to have worked:
(that's both highlighting Json and doing folding at the same time)
SKProCH commentedon Apr 4, 2024
Hmm, I should give it a try.
SKProCH commentedon Apr 7, 2024
Seems like my case still doesn't work properly with nightly avalonia. @Numpsy, can you, please, share your project?
Numpsy commentedon Apr 8, 2024
The screen shot I posted is from a project at work that I can't post all the code for, but I'll try to extract a sample out of it
danipen commentedon Aug 10, 2024
Guys, you should try v1.0.61. It ships #70, so TextMateSharp now supports WASM and includes native libs for each dotnet (6.0, 7.0, 8.0).
Numpsy commentedon Aug 11, 2024
I had a go at a minimal test project using Avalonia.FuncUI at https://github.com/Numpsy/FuncUITextMateSharpWasmTest and the syntax highlighting for Json seems ok (tried on Edge and Firefox on Windows).
My first go at using TextMateSharp 1.0.61 rather than TextMateSharp.Wasm didn't work. I haven't had time to investigate that in detail, though it might be that the condition at https://github.com/aikawayataro/Onigwrap/blob/a62e9cae00b8cc134f807f59c995ae14b9f969ed/src/Onigwrap/buildTransitive/Onigwrap.targets#L3 doesn't include the native assets when using Avalonia.Browser (with no Blazor)
aikawayataro commentedon Aug 12, 2024
@Numpsy thanks for the example! I'll have a look at it
hendrikmennen commentedon Aug 12, 2024
Once I enable "WasmEnableThreads" my app won't start anymore with:
MONO_WASM: Assert failed: Expect to have one js-module-threads asset in resources
Error: Assert failed: Expect to have one js-module-threads asset in resources
at Te (http://127.0.0.1:53299/_framework/dotnet.js:3:18520)
at J (http://127.0.0.1:53299/_framework/dotnet.js:3:5850)
at http://127.0.0.1:53299/_framework/dotnet.js:3:27682
at http://127.0.0.1:53299/_framework/dotnet.js:3:28704
at async Object.create (http://127.0.0.1:53299/_framework/dotnet.js:3:34625)
at async http://127.0.0.1:53299/main.js:6:23
Probably doesn't have anything to do with TextMateSharp though, but without it won't work aswell
https://github.com/one-ware/OneWare/tree/main/studio/OneWare.Studio.Browser
2 remaining items
Numpsy commentedon Aug 12, 2024
I was just doing some tests with the 1.0.5 onigwrap build, and had this odd situation on Firefox where the behavior varies depending if I have the browser dev tools are open:

(I'm not yet clear if my sample app is doing something wrong, or if there is a timing issue somewhere)
I also sometimes get this in the diagnostics:

Reading the linked article, it mentions setting PTHREAD_POOL_SIZE to help with this, and I see that the project linked by @hendrikmennen has _WasmPThreadPoolSize set in the project file, so maybe it could be a configuration thing?
Why any of this is different to the previous TextMateSharp.Wasm package, I don't know :-(
Numpsy commentedon Aug 12, 2024
Additional note: The app I posted the screen shot from on April 4th is actually running AvaloniaEdit in read only mode, so I didn't previously test editing the json after display.
aikawayataro commentedon Aug 12, 2024
I can see an idle worker in dev tools, probably not the reason... Worth trying though
Maybe because it was built with older emsdk. I will try to swap the asset with freshly built to confirm.
Judging by deadlock it should be a threading problem, dont know where to dig though
aikawayataro commentedon Aug 12, 2024
Not confirmed. It works but still hangs with the same deadlock after text is erased.
I have a wild guess. The only behavior from original Onigwrap I changed was dropping IDisposable in favor of just finalizer. This was supposed to ease freeing of native resources (pattern I follow with small memory resources), but maybe mono's GC has some problems with this. I'll try to understand current state of mono threading in Wasm and see if I can do anything.
aikawayataro commentedon Aug 12, 2024
Not confirmed. Replaced Onigwrap with a dummy implementation and still hangs.
hendrikmennen commentedon Aug 12, 2024
I guess we will need to wait a little bit for things to work
dotnet/runtime#68162
Numpsy commentedon Aug 12, 2024
The hang that sometimes happens when changing the highlighted text does appear to work better when running on .NET 9.0 - https://github.com/Numpsy/FuncUITextMateSharpWasmTest/tree/net9.0
aikawayataro commentedon Aug 13, 2024
Your example with dotnet 9 works for me without any freeze. I've released a new version with a workaround that links the latest available version of the binding with dotnet 9 (at this moment the emsdk used in 8 and 9 is the same).
Honestly, I would like to wait for dotnet 9 release, it looks very promising for Wasm support. I couldn't set up a debug environment to debug Wasm though, seems like documentation in veryyy early stages 😁
danipen commentedon Aug 13, 2024
I bumped the new onigwrap version in a new TextMateSharp v1.0.61. Thanks guys.
Numpsy commentedon Sep 30, 2024
According to
mono/SkiaSharp#3010
dotnet/runtime#100334
.NET 9.0 has moved to emscripten 3.1.56.
Does that require any updates over here to match?
aikawayataro commentedon Sep 30, 2024
Yes, it has to be. Could you please check the value of the
EmscriptenVersionproperty on the latest dotnet 9 preview?Numpsy commentedon Sep 30, 2024
If I run
dotnet build --getProperty:EmscriptenVersionwith the .NET 9.0 RC-1 SDK then it says 3.1.34, but when I did a dotnet workload update it installed a set of 3.1.56 versions:aikawayataro commentedon Sep 30, 2024
I will add functionality to use the appropriate version when
EmscriptenVersionis defined, thanks for your investigationNumpsy commentedon Nov 15, 2024
for the record:
I've had the minimal sample working on .NET 9, using Avalonia 11.2.1 and SkiaSharp 2.88.9, though there still seems to be a few issues with all the new versions of things (e.g. dotnet/runtime#109289) and it only presently works for me in release builds.
Also the shipping .NET 9 apparently has the wrong value for
EmscriptenVersion- dotnet/runtime#108972danipen commentedon Nov 15, 2024
There is a workaround for dotnet/runtime#109289 here: AvaloniaUI/Avalonia#17507