diff options
author | Morten Sørvig <morten.sorvig@qt.io> | 2024-04-17 16:25:49 +0200 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@qt.io> | 2024-04-22 15:22:12 +0000 |
commit | a5bdb2128e4dc5014d5753840f84b815a0486c06 (patch) | |
tree | e465fc4e4151b26de6f1b8fd0e4bdb6365a463bc | |
parent | bd231cc051d6246f572af23d953c27a95e0846a8 (diff) |
wasm: back out of calling onLoaded at first frame
Qt and application code expects that QScreen geometry
should be available early in main(), after the QApplication
constructor returns.
This is not the case if onLoaded is called at later
point in time, since the container element for the
screen is typically made visible when onLoaded is called,
and does not have valid geometry before.
Change-Id: I62d87f01fce1cd601e7a70d842e22a61814c9db7
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_wasm.cpp | 9 | ||||
-rw-r--r-- | src/plugins/platforms/wasm/qtloader.js | 12 |
2 files changed, 14 insertions, 7 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_wasm.cpp b/src/corelib/kernel/qeventdispatcher_wasm.cpp index f4fcdbb8b2..4aa435b64b 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<void>("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 bbc0ac68ab..8027dd8fa9 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<EmscriptenModule> * Qt always uses emscripten's MODULARIZE option. This is the MODULARIZE entry function. * - module: Promise<WebAssembly.Module> @@ -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}`; |