From b96a38acd2b8dd0b9590daa9498adcf5343797cc Mon Sep 17 00:00:00 2001 From: Mikolaj Boc Date: Fri, 16 Jun 2023 15:53:15 +0200 Subject: [PATCH] Don't simulate main loop with JSPI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is not needed, as main loop just works with awaited calls thanks to JS suspender objects with JSPI enabled. Fixes: QTBUG-114651 Change-Id: I94e187953ac8cec5c999f1b02508efecc19641f6 Reviewed-by: Morten Johan Sørvig --- src/corelib/kernel/qeventdispatcher_wasm.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_wasm.cpp b/src/corelib/kernel/qeventdispatcher_wasm.cpp index 35ff4b4328f..6ae6ea0985b 100644 --- a/src/corelib/kernel/qeventdispatcher_wasm.cpp +++ b/src/corelib/kernel/qeventdispatcher_wasm.cpp @@ -431,10 +431,14 @@ void QEventDispatcherWasm::handleApplicationExec() // Note that we don't use asyncify here: Emscripten supports one level of // asyncify only and we want to reserve that for dialog exec() instead of // using it for the one qApp exec(). - const bool simulateInfiniteLoop = true; - emscripten_set_main_loop([](){ - emscripten_pause_main_loop(); - }, 0, simulateInfiniteLoop); + // When JSPI is used, awaited async calls are allowed to be nested, so we + // proceed normally. + if (!qstdweb::haveJspi()) { + const bool simulateInfiniteLoop = true; + emscripten_set_main_loop([](){ + emscripten_pause_main_loop(); + }, 0, simulateInfiniteLoop); + } } void QEventDispatcherWasm::handleDialogExec()