Skip to content

Don't force the IE11 upload workaround on Safari - #847

Merged
sstidl merged 4 commits into
librespeed:masterfrom
marcel1702:master
Sep 12, 2026
Merged

sstidl merged 4 commits into
librespeed:masterfrom
marcel1702:master

Conversation

@marcel1702

Copy link
Copy Markdown
Contributor

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.js matches every Safari UA and turns the workaround on:

if (/^((?!chrome|android|crios|fxios).)*safari/i.test(ua)) {
    //Safari also needs the IE11 workaround but only for the MPOT version
    settings.forceIE11Workaround = true;
}

That flag switches ulTest() to a different measurement. Instead of one 20 MB blob with byte deltas from upload.onprogress, it sends 256 KB requests and adds a flat reqsmall.size per onload. Each request waits out a full round trip that contributes nothing to totLoaded, so on fast or high-latency links most of the test is spent idle and the result comes out low. It also ignores xhr_ul_blob_megabytes.

Two reasons the block looks obsolete:

  • The comment says MPOT only, but settings.mpot is never checked, so it applied to every test.
  • The regex skips crios and fxios. 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 in ulTest() 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 explicit forceIE11Workaround: false in 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_quirks on purpose. Neither has a working upload.onprogress, so enable_quirks: false would 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, sends start with test_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.mpot would be a small change if you know otherwise. Either way forceIE11Workaround: true now works as an override, which it didn't before.

claude and others added 2 commits September 7, 2026 20:21
…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
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Use accurate upload measurement by default on Safari

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Stops Safari from defaulting to the inaccurate small-request upload workaround.
• Preserves explicit overrides while retaining Edge and PlayStation 4 defaults.
• Adds browser-quirk regression coverage and aligns upload-test documentation.
Diagram

graph TD
  A["Start command"] --> B{"Override supplied?"} -->|Yes| C["Configured setting"] --> F{"Workaround enabled?"}
  B -->|No| D{"Edge or PS4?"} -->|Yes| H["Small requests"]
  D -->|No| E{"Usable upload progress?"} -->|Yes| G["Progress upload"]
  F -->|Yes| H
  F -->|No| E
  E -->|No| H
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Restrict Safari workaround to MPOT
  • ➕ Preserves behavior if legacy Safari MPOT deployments require small requests.
  • ➕ Matches the intent stated by the removed comment.
  • ➖ Retains inaccurate Safari measurements in MPOT mode without supporting evidence.
  • ➖ Continues user-agent sniffing despite equivalent WebKit behavior across iOS browsers.
2. Runtime progress-event validation
  • ➕ Could detect behavior without maintaining browser-specific user-agent rules.
  • ➕ May automatically support unknown browsers with broken upload progress events.
  • ➖ Requires network activity and timing heuristics before selecting an upload path.
  • ➖ Adds complexity and could misclassify slow or unusual connections.

Recommendation: The PR's approach is preferred: remove the unsupported Safari rule, retain existing runtime capability detection, and preserve known Edge/PS4 defaults. MPOT-only Safari gating should be reconsidered only if a reproducible affected deployment is identified.

Files changed (3) +100 / -9

Bug fix (1) +8 / -8
speedtest_worker.jsStop forcing Safari onto the legacy upload path +8/-8

Stop forcing Safari onto the legacy upload path

• Removes Safari user-agent forcing of the IE11 small-request workaround. Edge and PlayStation 4 retain their defaults unless the caller explicitly supplies forceIE11Workaround, allowing both true and false overrides to remain effective.

speedtest_worker.js

Tests (1) +91 / -0
worker-browser-quirks.spec.jsCover browser-specific upload setting resolution +91/-0

Cover browser-specific upload setting resolution

• Adds Playwright tests for Safari across macOS, iOS, and MPOT settings; verifies consistent iOS WebKit behavior; and protects Chrome mobile, Edge, and PlayStation 4 defaults. Tests also confirm explicit workaround overrides take precedence.

tests/e2e/worker-browser-quirks.spec.js

Documentation (1) +1 / -1
doc.mdClarify upload workaround browser detection +1/-1

Clarify upload workaround browser detection

• Documents Edge and PlayStation 4 as known affected browsers and explains that Safari uses the regular upload-progress measurement path. It also describes capability detection as the general fallback mechanism.

doc.md

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Maintainers get false browser guidance ✓ Resolved 🐞 Bug ⚙ Maintainability
Description
The upload documentation claims affected browsers are detected through xhr.upload capability
checks rather than user-agent sniffing. Edge and PlayStation 4 still reach the workaround through
navigator.userAgent regexes, while the generic check merely accesses the upload.onprogress
property and cannot detect an event that exists but never fires.
Code

doc.md[735]

+* Some browsers don't have a working `upload.onprogress` event. For this, we use a small blobs instead of a large one and we keep track of progress using the `onload` event. This is referred to as IE11 Workaround (the same bug was also found in some versions of Edge and in the PlayStation 4 browser). Affected browsers are detected by checking whether `xhr.upload` is usable, not by sniffing the user agent. Safari is __not__ affected and uses the regular, more accurate upload test
Evidence
The new documentation categorically denies user-agent sniffing, but the worker explicitly tests the
Edge and PlayStation 4 user agents to enable the workaround. Its separate generic fallback only
reads xhr[i].upload.onprogress inside a try/catch, so both detection mechanisms are part of the
implementation.

doc.md[733-736]
speedtest_worker.js[148-158]
speedtest_worker.js[464-475]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Correct the upload-test documentation, which currently says the workaround never uses user-agent sniffing even though Edge and PlayStation 4 are explicitly detected that way.
## Issue Context
The generic fallback checks whether `xhr.upload.onprogress` can be accessed, but known Edge and PlayStation 4 failures are handled through user-agent rules because their progress interface exists without producing working events.
## Fix Focus Areas
- doc.md[735-735]
- speedtest_worker.js[148-158]
- speedtest_worker.js[466-475]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can hide the parts of a finding you never read, like the evidence or the agent prompt

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread doc.md Resolved
claude and others added 2 commits September 7, 2026 21:23
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
@sstidl
sstidl merged commit 0603db7 into librespeed:master Sep 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants