"Cannot have multiple async operations in flight at once" during QApplication initialization
-
I am currently porting a moderately-sized Qt app to the web (Mixxx) and have found that enabling
-sASSERTIONS
(with Qt 6.6.2) will crash the app at launch withmixxx.js:12662 Aborted(Assertion failed: Cannot have multiple async operations in flight at once)
The issue seems to be that Mixxx's own asynchronous operations (mostly
QDialog::exec
) seem to clash withQWasmClipboard::initClipboardPermissions
, which is invoked internally duringQApplication
's initialization:abort assert whenDone promiseCallbackFinally2 Promise.finally (async) methodCaller<(emscripten::val) => emscripten::val> __emval_call_method imports.<computed> $std::__2::__function::__func<qstdweb::(anonymous namespace)::WebPromiseManager::adoptPromise(emscripten::val, qstdweb::PromiseCallbacks)::$_0, std::__2::allocator<qstdweb::(anonymous namespace)::WebPromiseManager::adoptPromise(emscripten::val, qstdweb::PromiseCallbacks)::$_0>, void (std::__2::unique_ptr<qstdweb::(anonymous namespace)::ThunkPool::ThunkAllocation, std::__2::default_delete<qstdweb::(anonymous namespace)::ThunkPool::ThunkAllocation>>)>::operator()(std::__2::unique_ptr<qstdweb::(anonymous namespace)::ThunkPool::ThunkAllocation, std::__2::default_delete<qstdweb::(anonymous namespace)::ThunkPool::ThunkAllocation>>&&) $qstdweb::Promise::adoptPromise(emscripten::val, qstdweb::PromiseCallbacks) $void qstdweb::Promise::make<emscripten::val>(emscripten::val, QString, qstdweb::PromiseCallbacks, emscripten::val) $QWasmClipboard::initClipboardPermissions() $QWasmClipboard::QWasmClipboard() $QWasmIntegration::QWasmIntegration() $QWasmIntegrationPlugin::create(QString const&, QList<QString> const&) $QPlatformIntegrationPlugin::create(QString const&, QList<QString> const&, int&, char**) $QPlatformIntegrationFactory::create(QString const&, QList<QString> const&, int&, char**, QString const&) $init_platform(QString const&, QString const&, QString const&, int&, char**) $QGuiApplicationPrivate::createPlatformIntegration() $QGuiApplicationPrivate::createEventDispatcher() $QApplicationPrivate::createEventDispatcher() $QCoreApplicationPrivate::init() $QGuiApplicationPrivate::init() $QApplicationPrivate::init() $QApplication::QApplication(int&, char**, int) $MixxxApplication::MixxxApplication(int&, char**) $main
My question is whether there is some way to avoid having
QApplication
perform such async operations internally, specifically if e.g. the clipboard initialization could be deferred or disabled, ideally without having to rearchitect the Mixxx side too much?I am pretty new to the Qt/Wasm backend, so any help would be greatly appreciated.
-
For testing I have patched out
QWasmClipboard::initClipboardPermissions
andbootstrapCheckPermissions
(which also spawns async operations), now I am getting the same error forqtStdWebEventCallbackActivate
, which looks like this bug: