tectonic icon indicating copy to clipboard operation
tectonic copied to clipboard

WebAssembly?

Open samghelms opened this issue 7 years ago • 7 comments
trafficstars

I noticed that the possibility of compiling to webassembly is mentioned in the tectonic docs. Has anyone tried to do this recently? Are there major road blocks in the way? I imagine the C dependencies could be a problem, but a surmountable one.

I'm really interested given that projects like texlive.js and xetex-js have successfully ported the c libraries tex depends on before.

samghelms avatar Mar 08 '18 15:03 samghelms

I have been investigating this a bit since I am quite interested in ways to bring typesetting with TeX sophistication to the web. Based on my initial investigations, I suspect that compiling to WebAssembly will be pretty straightforward. The overall infrastructure can be a bit messy, but seeing as one can compile all sorts of legacy C packages, Tectonic should work too. Making a robust, reliable build system that targets WebAssembly would probably require some effort, but be more a matter of plumbing and infrastructure, not fundamental technical challenges in the code.

One area that I don't understand so well is how to interact with existing browser infrastructure. For instance, rather than compiling the Rust HTTP/SSL stack to WebAssembly, it would probably be better to use browser tools like XmlHttpRequest when available (as used in my first foray into this domain, webtex). I am not sure what the "state of the art" is in this area — you could imagine modules that provide unified APIs that either use browser hooks or native Rust code, depending on the target platform.

pkgw avatar Mar 08 '18 15:03 pkgw

I'm curious as well how the network requests from tectonic would behave when executed as WASM. There is a whole book from rust folks on working with WASM: https://rustwasm.github.io/docs/book/

ghost avatar Aug 14 '19 16:08 ghost

@efx Since this issue was originally posted, the web-sys crate has been developed, and I think that would be the basic underlying building block for work here. What I don't know is if there's a crate that could abstract between using web-sys for WASM targets, and something like hyper/reqwest for non-WASM. Trying to provide transparent abstractions between such different backends feels very risky, but I think it might not be totally unreasonable here ...

pkgw avatar Aug 15 '19 19:08 pkgw

This bas been done in swiftlatex with the swiftlatex-engine on github too

benabel avatar Mar 17 '21 10:03 benabel