diff --git a/src/corelib/kernel/qeventdispatcher_wasm.cpp b/src/corelib/kernel/qeventdispatcher_wasm.cpp index f4fcdbb8b29..4aa435b64b0 100644 --- a/src/corelib/kernel/qeventdispatcher_wasm.cpp +++ b/src/corelib/kernel/qeventdispatcher_wasm.cpp @@ -938,10 +938,11 @@ void QEventDispatcherWasm::callOnLoadedIfRequired() void QEventDispatcherWasm::onLoaded() { - emscripten::val qt = emscripten::val::module_property("qt"); - if (qt.isUndefined()) - return; - qt.call("onLoaded"); + // TODO: call qtloader.js onLoaded from here, in order to delay + // hiding the "Loading..." message until the app is ready to paint + // the first frame. Currently onLoaded must be called early before + // main() in order to ensure that the screen/container elements + // have valid geometry at startup. } namespace { diff --git a/src/plugins/platforms/wasm/qtloader.js b/src/plugins/platforms/wasm/qtloader.js index bbc0ac68ab0..8027dd8fa9f 100644 --- a/src/plugins/platforms/wasm/qtloader.js +++ b/src/plugins/platforms/wasm/qtloader.js @@ -23,7 +23,8 @@ * - fontDpi: number * Specifies font DPI for the instance * - onLoaded: () => void - * Called when the module has loaded. + * Called when the module has loaded, at the point in time where any loading placeholder + * should be hidden and the application window should be shown. * - entryFunction: (emscriptenConfig: object) => Promise * Qt always uses emscripten's MODULARIZE option. This is the MODULARIZE entry function. * - module: Promise @@ -172,9 +173,14 @@ async function qtLoad(config) config.preRun = []; config.preRun.push(qtPreRun); + const originalOnRuntimeInitialized = config.onRuntimeInitialized; + config.onRuntimeInitialized = () => { + originalOnRuntimeInitialized?.(); + config.qt.onLoaded?.(); + } + const originalLocateFile = config.locateFile; - config.locateFile = filename => - { + config.locateFile = filename => { const originalLocatedFilename = originalLocateFile ? originalLocateFile(filename) : filename; if (originalLocatedFilename.startsWith('libQt6')) return `${config.qt.qtdir}/lib/${originalLocatedFilename}`;