From a5bdb2128e4dc5014d5753840f84b815a0486c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Wed, 17 Apr 2024 16:25:49 +0200 Subject: wasm: back out of calling onLoaded at first frame MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Piotr WierciƄski --- src/plugins/platforms/wasm/qtloader.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/plugins/platforms/wasm/qtloader.js') 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 * 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}`; -- cgit v1.2.3