Automatically determine the currect download URL also in Firefox again - #95
Conversation
When Git for Windows started to distribute ARM64 binaries along the x86 and x64 ones, the logic to choose the appropriate download URL on Git for Windows' home page was adjusted in 607efe1 (Drop 32-bit and add ARM64 architecture check, 2025-04-26) to detect when running on Windows/ARM64. Sadly, this new logic does not work on Firefox, and while the commit message of above-mentioned commit omits mentioning it, this was immediately spotted as a problem and there was an extensive discussion revolving around it, with the sad outcome that the download button does not link directly to the installer in Firefox, see #61. In the meantime, I stumbled across a neat trick to determine the CPU architecture that is used in the WebAssembly version of TensorFlow, which I traced all the way back to this commit: google/XNNPACK@466b52379d (Use GEMM/IGEMM micro-kernels with Swizzle on WAsm SIMD, 2019-10-09). Technically, it does not allow us to determine whether the CPU architecture is ARM64 (but only if it is not x86). For our purposes, this is enough for now: At present, Windows only supports Intel-compatible CPU architectures and ARM64. Let's use this trick as a fallback on Firefox (and really, any browser that isn't (based on) Chrome). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dennisameling
left a comment
There was a problem hiding this comment.
Nice, thanks! Regarding Firefox, I think there's some privacy concerns around the navigator.userAgentData API: https://bugzilla.mozilla.org/show_bug.cgi?id=1750143.
The XNNPACK workaround is very creative for sure 👀 Confirming that it works correctly on Firefox arm64:
|
edit: Sorry, it look like this change isn't live yet? Then I don't understand why the download is suddenly broken on Firefox (it worked fine a few weeks ago). When will this be deployed? @dscho It looks like this isn't working. The download button on the homepage now downloads the ARM version of Git for me when using Firefox, even though I'm on x64. Edge still correctly downloads the x64 version. Firefox 155.0.1 (64-Bit) |
No, this is deployed. And I see the same behavior, it also suggests for me to download the ARM64 version, whether I am on ARM64 or not. Will investigate.
|
|
Aha! Running |
Running `hugo --minify`, as the regular deployment workflow does, replaces `Infinity` with the shorter `1/0`. This transformation is correct in general, but we just introduced logic that exploits undefined behavior that is different between x64 and ARM64, i.e. the exact outcome of `Infinity - Infinity`, which is _different_ on these CPU architectures, whereas `1/0 - 1/0` is _not_. As a consequence, the logic failed in the deployed website, and _all_ users, even those with a x64 OS were offered the ARM64 version, see #95 (comment) Fix this by switching to `window.Infinity`, which `--minify` leaves alone, and which still exposes the same behavioral difference between these CPU architectures that we want to use as a tell-tale. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
|
I can confirm the fix, thanks! |
When Git for Windows started to distribute ARM64 binaries along the x86 and x64 ones, the logic to choose the appropriate download URL on Git for Windows' home page was adjusted in 607efe1 to detect when running on Windows/ARM64.
Sadly, this new logic does not work on Firefox, and while the commit message of above-mentioned commit omits mentioning it, this was immediately spotted as a problem and there was an extensive discussion revolving around it, with the sad outcome that the download button does not link directly to the installer in Firefox, see #61.
In the meantime, I stumbled across a neat trick to determine the CPU architecture that is used in the WebAssembly version of TensorFlow, which I traced all the way back to google/XNNPACK@466b52379d.
Technically, it does not allow us to determine whether the CPU architecture is ARM64 (but only if it is not x86). For our purposes, this is enough for now: At present, Windows only supports Intel-compatible CPU architectures and ARM64. Let's use this trick as a fallback on Firefox (and really, any browser that isn't (based on) Chrome).