summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Wierciński <[email protected]>2023-11-17 16:16:38 +0100
committerPiotr Wierciński <[email protected]>2023-12-16 01:34:20 +0000
commit6384c1f18d3b7ef8cc14db09128aa8005a1e06b4 (patch)
tree5ba747224aed3b83f541d0ad473955ab51df2198
parentf2d7272df72972a2a22601b20484a9332f6ab1fe (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.5 Change-Id: I969d73f6a66670c4135960e08d2eedc8d2a6e5c3 Reviewed-by: Lorn Potter <[email protected]> (cherry picked from commit f2f2b6ef18907a76461b54e110618e7840971fa7) Reviewed-by: Piotr Wierciński <[email protected]>
-rw-r--r--src/corelib/kernel/qeventdispatcher_wasm_p.h2
-rw-r--r--src/network/access/qnetworkreplywasmimpl.cpp6
2 files changed, 6 insertions, 2 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_wasm_p.h b/src/corelib/kernel/qeventdispatcher_wasm_p.h
index 1a87ad3bb98..a66f67c3e34 100644
--- a/src/corelib/kernel/qeventdispatcher_wasm_p.h
+++ b/src/corelib/kernel/qeventdispatcher_wasm_p.h
@@ -52,6 +52,7 @@ public:
void interrupt() override;
void wakeUp() override;
+ static void runOnMainThreadAsync(std::function<void(void)> fn);
static void socketSelect(int timeout, int socket, bool waitForRead, bool waitForWrite,
bool *selectForRead, bool *selectForWrite, bool *socketDisconnect);
protected:
@@ -89,7 +90,6 @@ private:
static void run(std::function<void(void)> fn);
static void runAsync(std::function<void(void)> fn);
static void runOnMainThread(std::function<void(void)> fn);
- static void runOnMainThreadAsync(std::function<void(void)> fn);
static QEventDispatcherWasm *g_mainThreadEventDispatcher;
diff --git a/src/network/access/qnetworkreplywasmimpl.cpp b/src/network/access/qnetworkreplywasmimpl.cpp
index be5b0f5f0ae..9c77d6881ea 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;
}