-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Compiling to web assemby #1323
Comments
I'm not aware of any recent attempts, but if you're willing to give it a try that would be great! |
Also see https://forum.languagetool.org/t/using-teavm-to-run-lt-under-javascript/490 for an old discussion about that |
Thx for the link ! I test it and it seems the compilation of the Hunspell.java class is in error. It does not surprise me. It seems that LanguageTool use jna to execute native code so it's a non sense to want to transform it to native LLVM.
[INFO] ------------------------------------------------------------------------ |
I created a test repo https://github.com/maxiplay/LanguageTool-WebAssembly |
Now I excluded the hunspell native part
And i just initalize the french version
And i get this error relative to java.lang.System.getSecurityManager()
|
I invited the creator of TeaVM to contribute |
Do you have a full developer documentation of LanguageTool ? |
I created an online writing software for writer that use actively LanguageTool. If the project grow contributions could be frequent. |
Maybe it's a good idea to first make a cleanup, ensure everything still compiles and the tests work, and then introduce teaVM? I've tried that here: 2230484 (the cleanup part - only languages left are EN and FR). Can you try to build on that, i.e. add teaVM? BTW, this seems to be a commercial teaVM alternative: https://www.leaningtech.com/cheerpj |
Alternatives to teaVM are also relevant because teaVM is "not for taking your large existing codebase in Java or Kotlin and producing JavaScript." (http://teavm.org/docs/intro/overview.html) |
Ok thx for the cleanup. I re-add hunspell module for checking and now test fail with this error : org.languagetool.commandline.AbstractSecurityTestCase$ExitException: There is no escape! |
Will test with https://www.leaningtech.com/cheerpj |
On master branch all test seems good excepted for http server but it seems to be an encoding problem. Perhaps relative to my windows machine.
|
Could you push your changes to https://github.com/maxiplay/LanguageTool-WebAssembly so I can easily reproduce them? The test indeed seems to have an encoding issue, I think we hardly ever run the tests on Windows. |
For the encoding problem I cloned the languageTool repo and checkout to master branch. No change to source code. I am on windows 10, jdk 8 For the hunspell error relative to french, I was on LanguageTool repo on the "webassembly" branch. it was the branch you do the cleanup I read the documentation about cheerpj and successfuly test the getting started. The compilation crash with forbiden path error. I think there is perhaps a relation with the lib folder and the need to have a "fat" jar instead. I will try to create a very simple test with english and language-core in a unique jar. |
Just to succeed to compile a test project with cheerpJ :) it's in this repo https://github.com/maxiplay/LanguageTool-WebAssembly on the cheerpj branch. |
It takes 36 seconds to start (with browser cache) to launch a spell check. It load 50MB the first time composed of a javascript compiled JavaSE and language-en dependency. During 36 seconds it takes 20% of my CPU. |
Thanks for the update. It's amazing that it works at all :-) Is it faster once everything is loaded? How long does checking a single sentence take once everything is loaded? |
Here's a discussion about how to make the file size smaller: leaningtech/cheerpj-meta#14 - summary: it's not supported yet... |
Need to improve the test project to say you that. What is the reason why the French version need Hunspell and not the English version ? First I will follow this page to improve the startup page. |
Actually, I don't remember. Maybe this was the reason: #850 (comment). So a version for French without hunspell could be possible, but it might lack some words or so. For other languages, like German, living without hunspell is more complicated as they need support for compounds. |
Ok thx for the response. I will try to test Proguard following this documentation. https://github.com/leaningtech/cheerpj-meta/wiki/Startup-time-optimization Fully test the application, making sure that all possible scenarios are executed and all needed classes are loaded Do you have a resource (Like a test) that give me an full scenario of spellchecking ? Grammar, hunspell, etc. The goal is to reduce significally the size of the generated jar just providing the necessary bytcode to do spellcheck. |
All the tests combined (as in running I think one key to keeping the results small is to work on one language a time. A lot of what makes LT so large is the fact that the resulting artifacts support all languages. |
I printed the stackTrace with catch.
And get
That say this specific message relative to Hunspell lib Unknown OS/arch: linux/cheerpj |
Seems hunspell is still active. As a first step - which will remove spell checking altogether - you could try commenting out the line |
Yes it works. Thx ! I will do now a check about performance. |
I tested perfs with a text list and calculate the time to process What is interesting is with CheerpJ the CPU is never above 35% whereas with Java Native the CPU reach 75%. Here the code for the test
|
|
@maxiplay Are you still working on this? I'd be very interested in any updates. |
I don't work anymore on it. |
The conclusion is it can work without using Hunspell in pure java. And the performance are relatively slow because first you need to load a fake JSE + Language tool at each page loading. And performance during spellcheck are relatively slow too. |
Had you try to compile it to WebAssembly ?
It would be perfect to avoid a high load on server. Each user computing the spellcheck locally.
There is now compiler from java
https://github.com/appcypher/awesome-wasm-langs#java
The text was updated successfully, but these errors were encountered: