From a2332517490ae807140566ab78720a40ff5f15c4 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Thu, 23 Dec 2021 06:41:01 +1000 Subject: [PATCH] wasm: hardcode idealThreadCount for some browsers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Browsers like Safari do not support the hardwareConcurrency property. Will hard code it to 2, as iOS only supports that amount. Change-Id: Icb35d3b698b28d8191a554167dc8cc262b806fb2 Reviewed-by: Morten Johan Sørvig (cherry picked from commit be5508fad068f422fd88b82c11db71bcc26f248f) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/kernel/qcoreapplication.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index a2f227ee5a4..2bc4acf90bc 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -788,7 +788,11 @@ void QCoreApplicationPrivate::init() #if QT_CONFIG(thread) #ifdef Q_OS_WASM - QThreadPrivate::idealThreadCount = emscripten::val::global("navigator")["hardwareConcurrency"].as(); + emscripten::val hardwareConcurrency = emscripten::val::global("navigator")["hardwareConcurrency"]; + if (hardwareConcurrency.isUndefined()) + QThreadPrivate::idealThreadCount = 2; + else + QThreadPrivate::idealThreadCount = hardwareConcurrency.as(); #endif #endif