Commit graph

18 commits

Author SHA1 Message Date
Balázs Varga (allotropia)
99c14f99e1 WASM: fix wasm build errors
Signed-off-by: Balázs Varga (allotropia) <balazs.varga.extern@allotropia.de>
Change-Id: I104e98ae1ddc64af55e4df0ccb301d5e88e0288d
2023-10-03 10:18:46 +02:00
Tor Lillqvist
a07f81388c I don't see the reason to use the intermediate libonline.a for WASM
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I520aa232f6ac51a6a57f36d8ac775150aa095a4d
2023-01-30 10:02:06 +02:00
Tor Lillqvist
b360c21c7f Avoid warning: deprecated item in EXPORTED_RUNTIME_METHODS: printErr use err instead.
We don't seem to need it anyway, so drop.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Idcccb3e46de692f179f0c01b5179eb43b816dcd5
2023-01-30 08:10:17 +02:00
Tor Lillqvist
38171388c8 Make the temporary "WASM app" work
Now I hope things are initialised in the right order and the plumbing
gets set up so that messages are passed as expected. It seems to work
most of the time.

Main changes are:

  - The online WASM executable is built using the -s MODULARIZE -s
    EXPORT_NAME=createOnlineModule options. This means that the WASM
    runtime is not automatically initialized and the main() function
    is not automatically started. Only when the createOnlineModule()
    function is called is that done. Calling exported C/C++ functions
    is a little bit more complicated.

  - Code to actually Base64-encode strings to be executed as
    JavaScript when expected is now present in wasmapp.cpp. (After
    being passed through the Base64ToArrayBuffer function on the JS
    side.) Whether this is actually necessary is not fully clear, but
    to keep the code similar to that in the GTK, iOS, and Android
    apps, this is kept as such for now. It would probably work fine to
    just directly create the ArrayBuffer in the C++ (using the EM_ASM
    magic).

  - The COOLWSD::run() function is now run in a separate thread so
    that main() can return.

  - The FakeWebSocket's onopen() function is now called from
    innerMain(), where the HULLO message is sent. It remains a bit
    unclear if this really is the ideal place.

    In the mobile apps the HULLO message is sent and the onopen()
    function is called in the window.socket.onopen() function in
    global.js.

    But note that despite that the WASM app and the mobile apps are
    largely quite similarly constructed and the FakeSocket and
    FakeWebSocket plumbing is the same, there is an important
    difference. In a mobile app the C++ code is what runs first, and
    that then loads the HTML page into WebKit, in which the JS
    runs. In the WASM app it is the other way around. The web page is
    naturaly the one that is loaded and the JS code then starts
    running the C++ code as WASM.

Finally, note that the whole concept that there is a separate "WASM
app" is temporary.

What we eventually want to achieve is that the COOL webpage upon
loading will connect a COOL server. As it does currently. The COOL
server runs the online and core C++ code to load a document, and
renders document tiles and sends those to the client JS code to
dispay.

The new thing will be that, if enabled, in addition to the HTML and JS
resources, the client will also download the WASM code and data
resources. Also, the document and updates to it will be downloaded
while being edited so that a copy can be kept in client memory. But
the WASM code and the downloaded document will remain unused most of
the time. Only if the connection to the COOL server breaks will the JS
start running the WASM code and the JS will talk to online code
running locally as WASM instead of to a COOL server. Obviously there
are still lots of things hanging in the air here regarding how exactly
this will work.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Ib1786a0b485d51797b0f2302d4296aa1ff9df5c1
2023-01-28 22:04:39 +02:00
Tor Lillqvist
1e55de0924 Use -gseparate-dwarf like in core
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Ie7814a0f0f02a577f641a7d223fbb0c81ab3b2ab
2023-01-27 10:06:12 +02:00
Tor Lillqvist
b1bb133e52 Bump PTHREAD_POOL_SIZE to 15
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I9c6c7075fff9d67c921d0c525eb8c0fe474b847c
2023-01-26 09:12:06 +02:00
Tor Lillqvist
bc5f8d16e9 Add _handle_cool_message to EXPORTED_FUNCTIONS
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I93d987284e2b14a08c4dd1613101572a72e85136
2023-01-15 19:46:37 +01:00
Tor Lillqvist
fc0b538a19 Increase PTHREAD_POOL_SIZE
Just 4 is very likely not nearly enough. I think I did see some error
that could be related to running out of threads. Does
PTHREAD_POOL_SIZE limit how many threads can exist simultaneously?

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I5da637b5660e89655f7049b6754f70c74dff6da2
2023-01-15 19:46:37 +01:00
Balázs Varga (allotropia)
158fe2f93a Trying to init LOKit cause mysterious runtime error
Also using soffice.data name instead online.data: online.js
looking for soffice.data

Signed-off-by: Balázs Varga (allotropia) <balazs.varga.extern@allotropia.de>
Change-Id: I62cee3f4866a2824a08b472f15bcdec06a6407b9
2023-01-15 19:46:37 +01:00
Michael Stahl
db532e12d0 WASM rename executable and copy missing data files from core
* add dependency on soffice.html.linkdeps to rebuild if core was rebuilt
* copy needed data files as-is from core build
* rename executable by setting automake EXEEXT var - appears to work

Signed-off-by: Michael Stahl <michael.stahl@allotropia.de>
Change-Id: I458b49290dae9d621a8043b1b3103d8b8fd606b8
2023-01-15 19:46:37 +01:00
Tor Lillqvist
8891cc1091 Remove TODO, we added a --pre-js a few commits ago
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Id372422578c9d6f49e453ede6a70cdc9db01c8b1
2023-01-11 09:27:36 +02:00
Tor Lillqvist
d575447e5b Need DEBUG_ABSSRCDIR here, too, for build with --enable-debug
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I02ee35797216135de79484e5929a4f72a1bb20b2
2023-01-11 09:27:36 +02:00
Tor Lillqvist
b004971e11 For now, link the WASM thing with the emscripten_fs_image from LO
The LO build directory in question needs to be one separately
configured for this (not one that would use Qt5 for UI, for instance),
so in the long run perhaps it does not make sense to create the FS
image there in core, but we should do it here in online? And we will
surely need additional files in the fs image anyway that core knows
nothing about.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I2cff0421da6075eefc017603ddf9d2ecf9dc79e2
2023-01-11 09:27:36 +02:00
Tor Lillqvist
9f8c4f6741 No need to export _doc_postUnoCommand from the wasm here
That is needed by core:feature/wasm for the way it implements
conversion to PDF. Not relevant here.

Signed-off-by: Tor Lillqvist <tml@collabora.com>
2023-01-10 22:02:22 +02:00
Michael Stahl
b1a1522a2b WASM use same CXXFLAGS as core
-pthreads is required, or wasm-ld reports errors about
"was not compiled with 'atomics' or 'bulk-memory' features"

Also, POCO needs to be built with this, add it in README.

Signed-off-by: Michael Stahl <michael.stahl@allotropia.de>
Change-Id: Ie83e3942e5fc689e6df5a5a705d7ee2e1325ce03
2023-01-10 22:02:22 +02:00
Michael Stahl
fdea5cde94 WASM WIP link an executable
Use the newly introduced soffice.html.linkdeps from core to get the
recursive dependencies into the link command.

This currently fails due to some problem with POCO:
wasm-ld: error: --shared-memory is disallowed by AtomicCounter.o because it was not compiled with 'atomics' or 'bulk-memory' features.

Signed-off-by: Michael Stahl <michael.stahl@allotropia.de>
Change-Id: I76b0a2265f67e89f6992d556525f1263ad1b45db
2023-01-10 22:02:22 +02:00
Tor Lillqvist
b2ea380bca Try to work around a bug in older Automake versions
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: I6af557dc0d6824011aeffd981b9a0f51f27fabbf
2023-01-09 15:21:37 +02:00
Michael Stahl
901ad84339 WASM add simple automake file and dummy cpp file
Copy the list of .cpp files from the Android project, assuming this will
be similar in scope.

Signed-off-by: Michael Stahl <michael.stahl@allotropia.de>
Change-Id: I57c7ad2f10d1867307ff4fcea3d0c650726d18d8
2023-01-09 15:21:37 +02:00