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.

Pick-to: 6.3 6.2
Change-Id: Icb35d3b698b28d8191a554167dc8cc262b806fb2
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Lorn Potter 2021-12-23 06:41:01 +10:00
parent 2c3198ab5f
commit be5508fad0

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