https://bugs.documentfoundation.org/show_bug.cgi?id=174440

            Bug ID: 174440
           Summary: WASM: qt_vcldemo.html fails with "Cannot open uno ini"
           Product: LibreOffice
           Version: 27.2.0.0 alpha0+ master
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: LibreOffice
          Assignee: [email protected]
          Reporter: [email protected]

static/README.wasm.md, section "Status of LibreOffice as WASM with Qt", says
that after the build "You should be able to run either"
workdir/installation/LibreOffice/emscripten/qt_soffice.html or
workdir/LinkTarget/Executable/qt_vcldemo.html. The first one works. The second
one stops at UNO bootstrap: the canvas stays blank and the console shows

    Bootstrap exception Cannot open uno ini file:///instdir/program/unorc

The page never requests soffice.data or soffice.data.js.metadata. Both files
are present next to vcldemo.js (in an Emscripten build,
solenv/gbuild/platform/unxgcc.mk copies them next to every Executable and
CppunitTest, together with a generated qt_<name>.html when Qt is enabled), but
vcldemo.js contains no code that loads them. So vcldemo's virtual file system
has no /instdir, and cppu bootstrap finds no unorc.

Steps to reproduce:
1. Build master for WASM with Qt5 as static/README.wasm.md describes. We used
--with-distro=LibreOfficeWASM32 --disable-symbols, emsdk 4.0.10 and Qt 5.15.2
from allotropia's qt5 repository, on master 2a2335cf with no local changes. (On
e42678e7 of 2026-11-11, configure with the same options stops with "Can't build
--disable-dynamic-loading without --disable-gui and a single VCL plugin", after
"VCLplugs to be built: gtk3 qt5"; that is why we stayed on 2a2335cf.)
2. In workdir/LinkTarget/Executable, run:

    emrun --hostname 127.0.0.1 --serve_after_close qt_vcldemo.html

3. Open the page in a new tab.

Actual: blank canvas; the console line above appears about 0.6 s after load.
Expected: the vcldemo rendering tests, or README.wasm.md not listing
qt_vcldemo.html as something to run.

Network requests and console output of step 3 (headless Chromium 151, served
with COOP/COEP):

    [0.0s] 200      3229 B  qt_vcldemo.html
    [0.0s] 200      3047 B  qtlogo.svg
    [0.0s] 200     22298 B  qtloader.js
    [0.2s] 200    282679 B  vcldemo.js
    [0.2s] 200 149670792 B  vcldemo.wasm
    [0.6s] Bootstrap exception Cannot open uno ini
file:///instdir/program/unorc

Control in the same build, served the same way: qt_soffice.html requests
soffice.data.js.metadata and soffice.data at 0.6 s and reaches the Start
Center.

The build output shows the same difference without a browser: grep for
"soffice.data" or "loadPackage" matches nothing in vcldemo.js and matches in
soffice.js.

Source (master 2a2335cf): the loader is file_packager's output
soffice.data.js.link. It is added as --pre-js only in
desktop/Executable_soffice_bin.mk, inside ifeq ($(OS),EMSCRIPTEN), together
with static/emscripten/environment.js. vcl/Executable_vcldemo.mk adds no
pre-js. vcl/Module_vcl.mk builds Executable_vcldemo for EMSCRIPTEN with Qt5
explicitly, so vcldemo looks intended to run in the browser.

Probable origin, from reading the history only (we did not build an older
tree): before commit cf0b0f0dd04f ("Emscripten: Only add the --pre-js code to
the soffice executable", 2024-04-30, first in 24.8),
solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk added gb_EMSCRIPTEN_PRE_JS_FILES
(environment.js and soffice.data.js.link) to every Executable and CppunitTest,
so vcldemo would have had the loader. That commit restricted the pre-js to
soffice_bin, so that executables run under node, such as uri-encode.js, no
longer fail with "XMLHttpRequest is not defined". Its message notes that every
executable still depends on soffice.data and soffice.data.js.metadata for the
cp instructions in unxgcc.mk, and that this "can probably be cleaned up further
in a next step". The README line is older (12a6b57c74aa, 2022-01) and has
stayed since.

Also seen on libreoffice-26-8 at 671c848b (2026-07-31): the same console error,
and vcldemo.js had no loader in each of the three configurations we built
there. The files involved are unchanged in libreoffice-26.8.2.2 and
libreoffice-26.8.3.1; for those two tags we read the source but did not run
them.

vcldemo seems worth keeping usable in the browser: it is the smallest program
that exercises VCL drawing, text layout and input through Qt there, without the
framework, the Start Center or a document, so it helps to tell whether a WASM
rendering or input problem is in VCL and below or higher up.

Fix, tested on 2a2335cf by relinking only vcldemo in the same build. Two
changes are needed, one in the link and one in vcldemo.cxx:

(1) In vcl/Executable_vcldemo.mk, add the same EMSCRIPTEN block that
desktop/Executable_soffice_bin.mk has (the link-target dependency on
soffice.data.js.link and the two gb_Executable_add_prejs calls), with
soffice_bin replaced by vcldemo. This changes only how vcldemo is linked, so
the node case that cf0b0f0dd04f fixed is not affected. With this alone, vcldemo
requests soffice.data and gets past UNO bootstrap, but the canvas stays blank.

(2) On Emscripten without JSPI, Application::Execute() ends in
QApplication::exec(), which unwinds the stack via a JS exception. With
-fwasm-exceptions this runs the destructors of the objects that DemoApp::Main()
keeps on the stack, so the DemoRenderer and the main window are disposed right
after the window has been shown. In a build with trace output, a line printed
in DemoWin::dispose() came right after the line printed before
Application::Execute(). desktop/source/app/sofficemain.cxx deliberately leaks
its desktop::Desktop for this reason. Doing the same for vcldemo's renderer and
windows, under #if defined __EMSCRIPTEN__ && !HAVE_EMSCRIPTEN_JSPI, fixes it.

With both changes, qt_vcldemo.html requests soffice.data, prints
"DemoWin::Paint(0,0,1164,669)" about 1 s after load and shows the grid of
rendering tests. A click zooms into a tile and Escape goes back, with no error.
Also linking vcldemo with soffice_bin's -sPROXY_TO_PTHREAD flags is not needed.
We ran only the default mode, not --widgets, --popup, --font or --threads. We
can submit the patch to Gerrit.

If vcldemo is no longer meant to run in the browser, the alternative is to
remove the qt_vcldemo.html line from README.wasm.md, and perhaps stop building
Executable_vcldemo for EMSCRIPTEN.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to