mirror of
https://github.com/9001/copyparty.git
synced 2025-12-08 06:03:29 -07:00
fix worker init timeout (closes #1035);
context: if webworkers fail to initialize within 5sec, up2k falls back to hashing on the main-thread instead problem: if webworkers eventually do finish init, they would then be racing the mainthread fix: disconnect webworkers if init timeout additionally, gradually extend the timeout as long as the workers are still making progress initializing
This commit is contained in:
parent
a28503e805
commit
98701b78e6
|
|
@ -2271,11 +2271,17 @@ function up2k_init(subtle) {
|
|||
busy = {},
|
||||
nbusy = 0,
|
||||
init = 0,
|
||||
ninit = 0,
|
||||
hashtab = {},
|
||||
mem = (MOBILE ? 128 : 256) * 1024 * 1024;
|
||||
|
||||
if (!hws_ok)
|
||||
init = setTimeout(function() {
|
||||
init = setInterval(function() {
|
||||
if (ninit < hws_ok) {
|
||||
ninit = hws_ok;
|
||||
return toast.inf(10, 'initializing webworkers ({0}/{1})'.format(hws_ok, hws.length), "iwwt");
|
||||
}
|
||||
clearInterval(init);
|
||||
hws_ng = true;
|
||||
toast.warn(30, 'webworkers failed to start\n\nwill be a bit slower due to\nhashing on main-thread');
|
||||
apop(st.busy.hash, t);
|
||||
|
|
@ -2325,12 +2331,17 @@ function up2k_init(subtle) {
|
|||
}
|
||||
|
||||
function onmsg(d) {
|
||||
if (hws_ng)
|
||||
return;
|
||||
|
||||
d = d.data;
|
||||
var k = d[0];
|
||||
|
||||
if (k == "pong")
|
||||
if (++hws_ok == hws.length) {
|
||||
clearTimeout(init);
|
||||
clearInterval(init);
|
||||
if (toast.tag == 'iwwt')
|
||||
toast.hide();
|
||||
go_next();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue