-
-
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
TextMateSharp with Wasm not working? #57
Comments
|
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. |
It worked some time ago but I didn't try it recently. Any clue of what the issue is? |
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: 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. |
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) |
Hmm, I should give it a try. |
Seems like my case still doesn't work properly with nightly avalonia. @Numpsy, can you, please, share your project? |
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 |
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) |
@Numpsy thanks for the example! I'll have a look at it |
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 Probably doesn't have anything to do with TextMateSharp though, but without it won't work aswell |
It might be that it needs different onigwrap builds for single/multi threaded consumer builds, though my knowledge of what actually changes in the native build part of that is rather slim |
@Numpsy I was working on pthread build and adjusted the condition, but unfortunately it doesn't change anything (I verified that the resulting Wasm links onigwrap). I've noticed that when I start deleting text from your example, I get a deadlock. This deadlock is very similar to the one I get with the new version of the package, but the new one starts right after the app is launched. I'll investigate this further... |
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 :-( |
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. |
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 |
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. |
Not confirmed. Replaced Onigwrap with a dummy implementation and still hangs. |
I guess we will need to wait a little bit for things to work |
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 |
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 😁 |
I bumped the new onigwrap version in a new TextMateSharp v1.0.61. Thanks guys. |
According to .NET 9.0 has moved to emscripten 3.1.56. |
Yes, it has to be. Could you please check the value of the |
I will add functionality to use the appropriate version when |
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
The text was updated successfully, but these errors were encountered: