lol android

This commit is contained in:
ed 2022-08-10 20:35:12 +02:00
parent 5ce9060e5c
commit 7de9775dd9
4 changed files with 52 additions and 23 deletions

View File

@ -117,7 +117,7 @@ var Ls = {
"cut_az": "upload files in alphabetical order, rather than smallest-file-first$N$Nalphabetical order can make it easier to eyeball if something went wrong on the server, but it makes uploading slightly slower on fiber / LAN", "cut_az": "upload files in alphabetical order, rather than smallest-file-first$N$Nalphabetical order can make it easier to eyeball if something went wrong on the server, but it makes uploading slightly slower on fiber / LAN",
"cut_mt": "use multithreading to accelerate file hashing$N$Nthis uses web-workers and requires$Nmore RAM (up to 512 MiB extra)$N$N35% faster https, 450% faster http", "cut_mt": "use multithreading to accelerate file hashing$N$Nthis uses web-workers and requires$Nmore RAM (up to 512 MiB extra)$N$N30% faster https, 4.5x faster http,$Nand 5.3x faster on android phones",
"cft_text": "favicon text (blank and refresh to disable)", "cft_text": "favicon text (blank and refresh to disable)",
"cft_fg": "foreground color", "cft_fg": "foreground color",
@ -289,7 +289,7 @@ var Ls = {
"u_https1": "you should", "u_https1": "you should",
"u_https2": "switch to https", "u_https2": "switch to https",
"u_https3": "for much better performance", "u_https3": "for better performance",
"u_ancient": 'your browser is impressively ancient -- maybe you should <a href="#" onclick="goto(\'bup\')">use bup instead</a>', "u_ancient": 'your browser is impressively ancient -- maybe you should <a href="#" onclick="goto(\'bup\')">use bup instead</a>',
"u_nowork": "need firefox 53+ or chrome 57+ or iOS 11+", "u_nowork": "need firefox 53+ or chrome 57+ or iOS 11+",
"u_enpot": 'switch to <a href="#">potato UI</a> (may improve upload speed)', "u_enpot": 'switch to <a href="#">potato UI</a> (may improve upload speed)',
@ -454,7 +454,7 @@ var Ls = {
"cut_az": "last opp filer i alfabetisk rekkefølge, istedenfor minste-fil-først$N$Nalfabetisk kan gjøre det lettere å anslå om alt gikk bra, men er bittelitt tregere på fiber / LAN", "cut_az": "last opp filer i alfabetisk rekkefølge, istedenfor minste-fil-først$N$Nalfabetisk kan gjøre det lettere å anslå om alt gikk bra, men er bittelitt tregere på fiber / LAN",
"cut_mt": "raskere befaring ved å bruke hele CPU'en$N$Ndenne funksjonen anvender web-workers$Nog krever mer RAM (opptil 512 MiB ekstra)$N$N35% raskere https, 450% raskere http", "cut_mt": "raskere befaring ved å bruke hele CPU'en$N$Ndenne funksjonen anvender web-workers$Nog krever mer RAM (opptil 512 MiB ekstra)$N$N30% raskere https, 4.5x raskere http,$Nog 5.3x raskere på android-telefoner",
"cft_text": "ikontekst (blank ut og last siden på nytt for å deaktivere)", "cft_text": "ikontekst (blank ut og last siden på nytt for å deaktivere)",
"cft_fg": "farge", "cft_fg": "farge",
@ -626,7 +626,7 @@ var Ls = {
"u_https1": "du burde", "u_https1": "du burde",
"u_https2": "bytte til https", "u_https2": "bytte til https",
"u_https3": "for mye høyere hastighet", "u_https3": "for høyere hastighet",
"u_ancient": 'nettleseren din er prehistorisk -- mulig du burde <a href="#" onclick="goto(\'bup\')">bruke bup istedenfor</a>', "u_ancient": 'nettleseren din er prehistorisk -- mulig du burde <a href="#" onclick="goto(\'bup\')">bruke bup istedenfor</a>',
"u_nowork": "krever firefox 53+, chrome 57+, eller iOS 11+", "u_nowork": "krever firefox 53+, chrome 57+, eller iOS 11+",
"u_enpot": 'bytt til <a href="#">enkelt UI</a> (gir sannsynlig raskere opplastning)', "u_enpot": 'bytt til <a href="#">enkelt UI</a> (gir sannsynlig raskere opplastning)',
@ -921,7 +921,7 @@ function opclick(e) {
goto(dest); goto(dest);
var input = QS('.opview.act input:not([type="hidden"])') var input = QS('.opview.act input:not([type="hidden"])')
if (input && !is_touch) { if (input && !TOUCH) {
tt.skip = true; tt.skip = true;
input.focus(); input.focus();
} }
@ -1691,7 +1691,7 @@ var vbar = (function () {
if (e.button === 0) if (e.button === 0)
can.onmousemove = null; can.onmousemove = null;
}; };
if (is_touch) { if (TOUCH) {
can.ontouchstart = mousedown; can.ontouchstart = mousedown;
can.ontouchmove = mousemove; can.ontouchmove = mousemove;
} }
@ -1796,7 +1796,7 @@ function playpause(e) {
seek_au_mul(x * 1.0 / rect.width); seek_au_mul(x * 1.0 / rect.width);
}; };
if (!is_touch) if (!TOUCH)
bar.onwheel = function (e) { bar.onwheel = function (e) {
var dist = Math.sign(e.deltaY) * 10; var dist = Math.sign(e.deltaY) * 10;
if (Math.abs(e.deltaY) < 30 && !e.deltaMode) if (Math.abs(e.deltaY) < 30 && !e.deltaMode)
@ -1836,7 +1836,7 @@ var mpui = (function () {
if (++nth > 69) { if (++nth > 69) {
// android-chrome breaks aspect ratio with unannounced viewport changes // android-chrome breaks aspect ratio with unannounced viewport changes
nth = 0; nth = 0;
if (is_touch) { if (MOBILE) {
nth = 1; nth = 1;
pbar.onresize(); pbar.onresize();
vbar.onresize(); vbar.onresize();
@ -4214,7 +4214,7 @@ document.onkeydown = function (e) {
clearTimeout(defer_timeout); clearTimeout(defer_timeout);
clearTimeout(search_timeout); clearTimeout(search_timeout);
search_timeout = setTimeout(do_search, search_timeout = setTimeout(do_search,
v && v.length < (is_touch ? 4 : 3) ? 1000 : 500); v && v.length < (MOBILE ? 4 : 3) ? 1000 : 500);
} }
} }

View File

@ -755,7 +755,7 @@ function up2k_init(subtle) {
showmodal('<h1>loading ' + fn + '</h1>'); showmodal('<h1>loading ' + fn + '</h1>');
import_js('/.cpr/deps/' + fn, unmodal); import_js('/.cpr/deps/' + fn, unmodal);
if (is_https) { if (HTTPS) {
// chrome<37 firefox<34 edge<12 opera<24 safari<7 // chrome<37 firefox<34 edge<12 opera<24 safari<7
m = L.u_ancient; m = L.u_ancient;
setmsg(''); setmsg('');
@ -846,6 +846,7 @@ function up2k_init(subtle) {
"t": "" "t": ""
}, },
"car": 0, "car": 0,
"slow_io": null,
"modn": 0, "modn": 0,
"modv": 0, "modv": 0,
"mod0": null "mod0": null
@ -1298,9 +1299,10 @@ function up2k_init(subtle) {
var h = L.u_etadone.format(humansize(st.bytes.hashed), pvis.ctr.ok + pvis.ctr.ng); var h = L.u_etadone.format(humansize(st.bytes.hashed), pvis.ctr.ok + pvis.ctr.ng);
if (st.eta.h !== h) { if (st.eta.h !== h) {
st.eta.h = ebi('u2etah').innerHTML = h; st.eta.h = ebi('u2etah').innerHTML = h;
console.log('{0} hash, {1} up'.format( console.log('{0} hash, {1} up, {2} busy'.format(
f2f(st.time.hashing, 2), f2f(st.time.hashing, 1),
f2f(st.time.uploading, 2))); f2f(st.time.uploading, 1),
f2f(st.time.busy, 1)));
} }
} }
@ -1688,7 +1690,7 @@ function up2k_init(subtle) {
pvis.setab(t.n, nchunks); pvis.setab(t.n, nchunks);
pvis.move(t.n, 'bz'); pvis.move(t.n, 'bz');
if (hws.length && uc.hashw) if (nchunks > 1 && hws.length && uc.hashw)
return wexec_hash(t, chunksize, nchunks); return wexec_hash(t, chunksize, nchunks);
var segm_next = function () { var segm_next = function () {
@ -1790,12 +1792,13 @@ function up2k_init(subtle) {
function wexec_hash(t, chunksize, nchunks) { function wexec_hash(t, chunksize, nchunks) {
var nchunk = 0, var nchunk = 0,
reading = 0, reading = 0,
max_readers = 1, //uc.multitask ? 2 : 1, max_readers = 1,
opt_readers = 2,
free = [], free = [],
busy = {}, busy = {},
nbusy = 0, nbusy = 0,
hashtab = {}, hashtab = {},
mem = (is_touch ? 128 : 256) * 1024 * 1024; mem = (MOBILE ? 128 : 256) * 1024 * 1024;
for (var a = 0; a < hws.length; a++) { for (var a = 0; a < hws.length; a++) {
var w = hws[a]; var w = hws[a];
@ -1807,6 +1810,11 @@ function up2k_init(subtle) {
} }
function go_next() { function go_next() {
if (st.slow_io && uc.multitask)
// android-chrome filereader latency is ridiculous but scales linearly
// (unlike every other platform which instead suffers on parallel reads...)
max_readers = opt_readers = free.length;
if (reading >= max_readers || !free.length || nchunk >= nchunks) if (reading >= max_readers || !free.length || nchunk >= nchunks)
return; return;
@ -1845,6 +1853,11 @@ function up2k_init(subtle) {
if (k == "read") { if (k == "read") {
reading--; reading--;
if (MOBILE && CHROME && st.slow_io === null && d[1] == 1 && d[2] > 1024 * 512) {
var spd = Math.floor(d[2] / d[3]);
st.slow_io = spd < 40 * 1024;
console.log('spd {0}, slow: {1}'.format(spd, st.slow_io));
}
//console.log('[P ] %d read DONE (%d reading, %d busy)', d[1], reading, nbusy); //console.log('[P ] %d read DONE (%d reading, %d busy)', d[1], reading, nbusy);
return go_next(); return go_next();
} }
@ -1866,7 +1879,7 @@ function up2k_init(subtle) {
pvis.hashed(t); pvis.hashed(t);
if (t.hash.length < nchunks) if (t.hash.length < nchunks)
return nbusy < 2 && go_next(); return nbusy < opt_readers && go_next();
t.hash = []; t.hash = [];
for (var a = 0; a < nchunks; a++) for (var a = 0; a < nchunks; a++)
@ -2309,7 +2322,7 @@ function up2k_init(subtle) {
window.addEventListener('resize', onresize); window.addEventListener('resize', onresize);
onresize(); onresize();
if (is_touch) { if (MOBILE) {
// android-chrome wobbles for a bit; firefox / iOS-safari are OK // android-chrome wobbles for a bit; firefox / iOS-safari are OK
setTimeout(onresize, 20); setTimeout(onresize, 20);
setTimeout(onresize, 100); setTimeout(onresize, 100);

View File

@ -8,12 +8,27 @@ if (!window['console'])
var wah = '', var wah = '',
HALFMAX = 8192 * 8192 * 8192 * 8192, HALFMAX = 8192 * 8192 * 8192 * 8192,
is_touch = 'ontouchstart' in window, HTTPS = (window.location + '').indexOf('https:') === 0,
is_https = (window.location + '').indexOf('https:') === 0, TOUCH = 'ontouchstart' in window,
IPHONE = is_touch && /iPhone|iPad|iPod/i.test(navigator.userAgent), MOBILE = TOUCH,
CHROME = !!window.chrome,
IPHONE = TOUCH && /iPhone|iPad|iPod/i.test(navigator.userAgent),
WINDOWS = navigator.platform ? navigator.platform == 'Win32' : /Windows/.test(navigator.userAgent); WINDOWS = navigator.platform ? navigator.platform == 'Win32' : /Windows/.test(navigator.userAgent);
try {
if (navigator.userAgentData.mobile)
MOBILE = true;
if (navigator.userAgentData.platform == 'Windows')
WINDOWS = true;
if (navigator.userAgentData.brands.some(function (d) { return d.brand == 'Chromium' }))
CHROME = true;
}
catch (ex) { }
var ebi = document.getElementById.bind(document), var ebi = document.getElementById.bind(document),
QS = document.querySelector.bind(document), QS = document.querySelector.bind(document),
QSA = document.querySelectorAll.bind(document), QSA = document.querySelectorAll.bind(document),
@ -946,7 +961,7 @@ var tt = (function () {
return r.show.bind(this)(); return r.show.bind(this)();
tev = setTimeout(r.show.bind(this), 800); tev = setTimeout(r.show.bind(this), 800);
if (is_touch) if (TOUCH)
return; return;
this.addEventListener('mousemove', r.move); this.addEventListener('mousemove', r.move);

View File

@ -25,12 +25,13 @@ function load_fb() {
onmessage = (d) => { onmessage = (d) => {
var [nchunk, fobj, car, cdr] = d.data, var [nchunk, fobj, car, cdr] = d.data,
t0 = Date.now(),
reader = new FileReader(); reader = new FileReader();
reader.onload = function (e) { reader.onload = function (e) {
try { try {
//console.log('[ w] %d HASH bgin', nchunk); //console.log('[ w] %d HASH bgin', nchunk);
postMessage(["read", nchunk]); postMessage(["read", nchunk, cdr - car, Date.now() - t0]);
hash_calc(e.target.result); hash_calc(e.target.result);
} }
catch (ex) { catch (ex) {