forderud / QtWasm

Dockerfile for building Qt projects for WebAssembly
https://hub.docker.com/r/forderud/qtwasm
17 stars 4 forks source link

Preloading broken after upgrading to Qt 6.6 #72

Closed forderud closed 9 months ago

forderud commented 10 months ago

Regression introduced when upgrading to Qt 6.6. in #67.

Observed a Module.preRun.push is not a function crash at startup after upgrading that was solved by switching from --preload-file to --embed-file. Not sure if this is the "best" way of fixing the problem though, but it seems to work for both the CMake and QMake builds.

Preload problem detail (worked around)

This problem is not tied to the Emscripten 3.1.37 upgrade. Upgrading to Qt 6.6.0 without also upgrading Emscripten also triggers the same problem.

The sample app crashed during startup with a Module.preRun.push is not a function error: image

The error is the same for both QMake and CMake builds.

Console output:

helloworld.html:66 TypeError: Module.preRun.push is not a function
    at loadPackage (helloworld.js:8:5562)
    at helloworld.js:8:5580
    at Object.entryFunction (helloworld.js:8:5678)
    at qtLoad (qtloader.js:211:40)
    at async init (helloworld.html:48:34)
init @ helloworld.html:66
helloworld.html:67 TypeError: Module.preRun.push is not a function
    at loadPackage (helloworld.js:8:5562)
    at helloworld.js:8:5580
    at Object.entryFunction (helloworld.js:8:5678)
    at qtLoad (qtloader.js:211:40)
    at async init (helloworld.html:48:34)

Extract of failing code in helloworld.js:

               ....
                if (Module["calledRun"]) {
                    runWithFS()
                } else {
                    if (!Module["preRun"])
                        Module["preRun"] = [];
                    Module["preRun"].push(runWithFS) <-- FAILURE POINT
                }
            };
            loadPackage({   <--- CALLING POINT
                "files": [{
                    "filename": "/example.txt",
                    "start": 0,
                    "end": 31
                }],
                "remote_package_size": 31
            })

The sources seem to come from Emscripten file_packager.py.

forderud commented 10 months ago

https://codereview.qt-project.org/c/qt/qtbase/+/521924 might fix the preload issue,