Repository navigation
Don't force the IE11 upload workaround on Safari - #847
Conversation
…fing The upload test reported low and unstable numbers on Safari (macOS and iOS) while the download test was correct. Cause: the "start" handler in speedtest_worker.js matched every Safari user agent and set settings.forceIE11Workaround = true. In ulTest() that flag selects a fundamentally different, less accurate measurement path: instead of sending one xhr_ul_blob_megabytes blob (20 MB by default) and accumulating event.loaded from upload.onprogress, it sends a stream of 256 KB requests and adds a fixed 256 KB to totLoaded on each onload. Progress is therefore quantised to whole requests and each request pays a full round trip before the next one starts, so on fast or high-latency links the measured speed is both too low and noisy. The workaround is not needed. Its comment claims it is only required for MPOT, but the block never checked settings.mpot. The same block also excludes crios and fxios, which on iOS run the very same WebKit networking stack as Safari, so the user agent test cannot have been guarding an engine-level bug in the first place. Current WebKit implements xhr.upload.onprogress, and the existing feature detection in ulTest() (the try/catch that probes xhr.upload.onprogress) already selects the workaround for browsers that genuinely lack it, without sniffing. Changes: - Remove the Safari user agent block. Safari now takes the regular upload path, the same one Chrome and Firefox on iOS already took. - Guard the Edge and PlayStation 4 blocks with typeof s.forceIE11Workaround === "undefined", matching how the other quirks avoid clobbering explicitly passed settings. Previously an explicit forceIE11Workaround: false in the start command was silently overwritten, so the workaround was not switchable from outside the worker. Default behaviour for those browsers is unchanged. - Add tests/e2e/worker-browser-quirks.spec.js, which loads the worker under spoofed user agents and asserts the resolved settings. - Update doc.md so Safari is no longer listed as affected. The Edge and PlayStation 4 blocks are deliberately left outside the enable_quirks condition: those browsers have no working upload.onprogress, so running them with enable_quirks: false would report 0 or Fail rather than a less precise number. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01S1bUKsok59shM69PwLMMRM
…ccwy5 Stop forcing the IE11 upload workaround on Safari via user agent sniffing
PR Summary by QodoUse accurate upload measurement by default on Safari
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo
1.
|
The previous wording claimed affected browsers are detected by checking whether xhr.upload is usable "not by sniffing the user agent", but Edge and the PlayStation 4 browser are still matched by user agent regex. Both mechanisms exist and for different reasons: feature detection only sees a missing xhr.upload object, while those two expose the object and simply never fire its events. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01S1bUKsok59shM69PwLMMRM
…ccwy5 docs: describe both detection paths for the IE11 upload workaround
Safari reports upload speeds well below the actual uplink, and the number jumps around between runs. Download is fine.
The quirk section in
speedtest_worker.jsmatches every Safari UA and turns the workaround on:That flag switches
ulTest()to a different measurement. Instead of one 20 MB blob with byte deltas fromupload.onprogress, it sends 256 KB requests and adds a flatreqsmall.sizeperonload. Each request waits out a full round trip that contributes nothing tototLoaded, so on fast or high-latency links most of the test is spent idle and the result comes out low. It also ignoresxhr_ul_blob_megabytes.Two reasons the block looks obsolete:
settings.mpotis never checked, so it applied to every test.criosandfxios. On iOS those run the same WebKit stack as Safari, so on one iPhone Safari measured low while Chrome measured correctly. An engine bug can't behave that way.WebKit has a working
xhr.upload.onprogress, and the try/catch already inulTest()covers browsers that don't.So the Safari block is gone. I also guarded the Edge and PS4 blocks with
typeof s.forceIE11Workaround === "undefined": an explicitforceIE11Workaround: falsein the start command was silently overwritten a few lines after being copied in, so the workaround wasn't switchable from outside the worker at all. Defaults for those two browsers are unchanged.Edge and PS4 stay outside
enable_quirkson purpose. Neither has a workingupload.onprogress, soenable_quirks: falsewould leave them at 0/Fail instead of a rougher number. Happy to move them in if you'd rather have the consistency.Added
tests/e2e/worker-browser-quirks.spec.js. It needs no docker services: it loads the worker under a spoofed UA, sendsstartwithtest_order: "_"(a no-op step, so no network) and checks the resolved settings. Four of its six tests fail on master and pass with this change; the Chrome-mobile 4 MB cap and the Edge/PS4 defaults pass either way. Lint output is unchanged (same 20 pre-existing warnings). I couldn't run the docker-backed suite locally, but nothing here touches those specs.In Safari's network panel during the upload phase you should now see a few dozen 20 MB POSTs instead of hundreds of 256 KB ones.
One thing I can't settle: whether MPOT ever actually needed this. I have no Safari pointed at an MPOT deployment. The code never implemented the claim and the crios/fxios exclusion argues against it, so I removed the block outright, but gating it on
settings.mpotwould be a small change if you know otherwise. Either wayforceIE11Workaround: truenow works as an override, which it didn't before.