wasm: hardcode idealThreadCount for some browsers

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 <morten.sorvig@qt.io>
(cherry picked from commit be5508fad068f422fd88b82c11db71bcc26f248f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Lorn Potter 2021-12-23 06:41:01 +10:00 committed by Qt Cherry-pick Bot
parent fca50c5985
commit a233251749

View File

@ -788,7 +788,11 @@ void QCoreApplicationPrivate::init()
#if QT_CONFIG(thread)
#ifdef Q_OS_WASM
QThreadPrivate::idealThreadCount = emscripten::val::global("navigator")["hardwareConcurrency"].as<int>();
emscripten::val hardwareConcurrency = emscripten::val::global("navigator")["hardwareConcurrency"];
if (hardwareConcurrency.isUndefined())
QThreadPrivate::idealThreadCount = 2;
else
QThreadPrivate::idealThreadCount = hardwareConcurrency.as<int>();
#endif
#endif