This article is more than 1 year old

'It's where the industry is heading': LibreOffice team working on WebAssembly port

Second attempt to run entirely in the browser – but nothing works yet

The LibreOffice team has been working on a port to browser-hosted WebAssembly, and hopes for a working demo by summer 2021. "It's the way the industry is heading," said Document Foundation board member Thorsten Behrens.

Browser-based versions of the open-source office productivity suite already exist in the form of Collabora Online and LibreOffice Online (LOOL), mainly developed by Collabora.

The Document Foundation, steward of the LibreOffice project, said that it is "not planning to develop and fund a cloud solution similar to existing products from Google and Microsoft" because this is "not in line with the original mission of the project."

Instead, it has provided the code for other providers to deploy, although the foundation added that this code is missing essential pieces, such as authentication, which are down to the provider.

A board deputy at TDF contacted us to emphasise the experimental nature of the project. “A port to WebAssembly is at present being independently developed by an organisation that is a member of the ecosystem but it hasn't been yet evaluated to be included in the road map or as being a joint project with TDF,” he said.

Speaking at the FOSDEM 2021 open-source developer event earlier this month, Behrens said LOOL is based on the HTML5 Canvas element that displays the document, but that "all the rendering, all the interaction with the document, all the editing" happens on the server.

This Qt Mandelbrot demo was successfully built with the gbuild LibreOffice build system; it is the only thing so far that runs

This Qt Mandelbrot demo was successfully built with the gbuild LibreOffice build system; it is the only thing so far that runs

This has the advantage that the client code is lightweight and that the document lives on the server, which is good for security and for collaborative editing, because there is only one document instance. The disadvantages? There is "no offline mode, it is relatively expensive to host, and there is no peer-to-peer editing."

Scaling LOOL is non-trivial, Behrens said, if you want to run it "beyond a handful of users."

Another snag is that the code for the online version is in a separate repository from that for the cloud version, but they have a lot in common, and keeping the two in sync with updates is challenging.

2015 was too early... but tech's more developed now

Behrens observed that technology advances mean that a smartphone today is more powerful than a typical PC back in the '90s, when much of the code in the core of LibreOffice (originally Star Office) was first developed.

He should know – his bio states that "Thorsten was part of the OpenOffice.org project almost from the start when he joined the then-Sun Microsystems development team back in early 2001."

That being the case, why not run LibreOffice "in the browser, all of it, using this nifty technology called WebAssembly? It's where the industry is heading," said Behrens.

The idea is to use browser APIs where possible, removing code from LibreOffice itself, and compile the core code to WebAssembly (Wasm). LibreOffice uses the Qt library and Qt for Wasm exists, using the Emscripten compiler, with the docs stating that "this format is nearly as fast as native machine code, and is now supported by all major web browsers."

LibreOffice 7.1 beta introduces new features including outline folding in Writer

LibreOffice 7.1 beta boasts impressive range of features let down by a lack of polish and poor mobile efforts

READ MORE

The team tried this before, said Behrens, in 2015, but could not get it to work. "It was too early, the technology was too young, Emscripten could not even do exceptions properly," he said. "Now it seems the stars are much more aligned. Nothing really missing any more, even threading support is kind-of there."

There is an issue with sharing memory between threads since browsers disable the JavaScript SharedArrayBuffer, used for this purpose, because of speculative execution security concerns, but there are workarounds using service workers and message passing. Writer, which is the team's initial target, was originally written as a single-threaded application. There are also issues with the size of the code. It is not feasible to download hundreds of megabytes of binary Wasm so the aim is to squeeze Writer into 20MB to 30MB of Wasm.

The team has had some success compiling the code, but unfortunately it mostly does not work, said Munich-based Jan-Marek Glogowski, who is working on the project. "The only thing that is runnable is a Qt5 demo which I ported to gbuild," he said (gbuild is the LibreOffice build system, based on the GNU Make tool.)

Youtube Video

Details on what did not work can be found in Behrens and Glogowski's talk here and in the readme document here. It is impossible to compile dynamic modules, plugin code causes problems, the compiled binary is still much too large, and debugging is difficult, said Glogowski.

"Right now we're still in the early stages," Behrens acknowledged. Despite these issues, Behrens said that "we hope to have vcldemo running" very soon – this being a demo of the LibreOffice Visual Class Library which displays the widgets used by the suite. He also aims to have Writer rendered interactively on an HTML5 canvas by summer. Behrens said that one of the advantages will be end-to-end encryption, which is not possible with LOOL, and said that the team hopes to demo this before the end of the year.

A WebAssembly version of LibreOffice would meet different needs than the current LOOL and in principle would enable cross-platform use of the suite without having to install software and without requiring a hefty server application – all the functionality would be in the browser.

Opinions on whether Wasm is the future of browser applications will vary, but reliable ways to run LibreOffice outside the context of a PC or Mac could potentially be important to the project's future. ®

More about

TIP US OFF

Send us news


Other stories you might like