summaryrefslogtreecommitdiffstats
path: root/src/network/access
diff options
context:
space:
mode:
authorPiotr Wierciński <piotr.wiercinski@qt.io>2023-11-17 16:16:38 +0100
committerPiotr Wierciński <piotr.wiercinski@qt.io>2023-11-22 20:15:38 +0000
commitf2f2b6ef18907a76461b54e110618e7840971fa7 (patch)
tree5d96ea738d35ea2650f9ce4d97ff3af7d8b7ad21 /src/network/access
parenta397247e2b57e2a553dd868aca408b40c253c76e (diff)
wasm: Proxy emscripten_fetch() to the main thread
Calling emscripten_fetch() on worker thread which never yields control back to the browser, will leave the fetch request pending forever. This can be a problematic for example in QML Loader, which tries to load resource by network. Proxy this function call to the main thread, so it can be processed by the browser. Fixes: QTBUG-118225 Pick-to: 6.6 6.5 Change-Id: I969d73f6a66670c4135960e08d2eedc8d2a6e5c3 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Diffstat (limited to 'src/network/access')
-rw-r--r--src/network/access/qnetworkreplywasmimpl.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/network/access/qnetworkreplywasmimpl.cpp b/src/network/access/qnetworkreplywasmimpl.cpp
index d8190434cc..f7380a10d9 100644
--- a/src/network/access/qnetworkreplywasmimpl.cpp
+++ b/src/network/access/qnetworkreplywasmimpl.cpp
@@ -9,6 +9,7 @@
#include <QtCore/qcoreapplication.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qthread.h>
+#include <QtCore/private/qeventdispatcher_wasm_p.h>
#include <QtCore/private/qoffsetstringarray_p.h>
#include <QtCore/private/qtools_p.h>
@@ -295,7 +296,10 @@ void QNetworkReplyWasmImplPrivate::doSendRequest()
QByteArray destinationPath = dPath.toUtf8();
attr.destinationPath = destinationPath.constData();
- m_fetch = emscripten_fetch(&attr, request.url().toString().toUtf8());
+ auto url = request.url().toString().toUtf8();
+ QEventDispatcherWasm::runOnMainThreadAsync([attr, url]() mutable {
+ emscripten_fetch(&attr, url);
+ });
state = Working;
}