Skip to content

Drop 32-bit and add ARM64 architecture check #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2025

Conversation

rbqvq
Copy link
Contributor

@rbqvq rbqvq commented Apr 26, 2025

New Git-For-Windows does not have Git-32-bit.exe, drop 32-Bit.
Add ARM64 architecture check, I find this check code in VSCode website.

I do not test it, So please test it at first

@rbqvq
Copy link
Contributor Author

rbqvq commented Apr 26, 2025

Here is new API browser compatibility
Mozilla MDN Docs

It may not work with earlier Windows browsers, and I didn't look to see if Git-For-Windows still supports earlier Windows versions (e.g. Windows 7 or Windows 10 earlier version)

If these earlier versions have been discarded, we can safely merge this PR.

@dscho
Copy link
Member

dscho commented Apr 28, 2025

Thank you for your contribution! You're absolutely correct, the i686 version should no longer be advertised, and the Windows/ARM64 version should be advertised.

Here is new API browser compatibility
Mozilla MDN Docs

Unfortunately, this does not seem to be supported very well:

image

Firefox, for example, seems not to support this at all:

image

It does seem as if your method is recommended, but I do want to have a fallback in case navigator.userAgentData is not available.

It does seem as if x64 is not present in the User-Agent string when using Firefox for Windows/ARM64, and that might be the case for other browsers that do not support navigator.userAgentData, either.

But the best course of action would most likely be to use uaparser.dev instead, i.e. vendor in https://github.com/faisalman/ua-parser-js/raw/refs/tags/2.0.3/dist/ua-parser.pack.js, import it in the <head> section, and then use something like this to detect Windows/ARM64:

const uap = new UAParser(navigator.userAgent)
const isWinARM64 = uap.getOS().name === 'Windows' && uap.getCPU() === 'arm64'

@rbqvq what do you think about this approach?

@rbqvq
Copy link
Contributor Author

rbqvq commented Apr 28, 2025

@dscho

I installed Firefox and Google Chrome arm64 version on my snapdragon computer.
But unlucky, all browser UA same with x64 version.

UserAgent

  • MS Edge
    Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 Edg/135.0.0.0
  • Firefox
    Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:137.0) Gecko/20100101 Firefox/137.0
  • Google Chrome
    Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36

I think the current implementation is sufficient, VSCode and Google Chrome official website cannot read the system architecture in Firefox

When this API call fails, the download link will not be replaced, but redirected to the release page for users to manually select

@rbqvq
Copy link
Contributor Author

rbqvq commented Apr 28, 2025

Of course, maybe we should let users manually select on all platforms. I'm not sure if a user mistakenly downloads an x64 browser on an arm64 platform, will this API still report it as arm64?

I just tested Google Chrome, and its automatic installation is arm64. Manually copying the x64 installation package fails to install (I'm not sure if the old version of Chrome has this check)

As for MS Edge, it comes with the system, so don't worry about it
Firefox itself does not support checking the system architecture, so it is not considered

@rbqvq
Copy link
Contributor Author

rbqvq commented Apr 28, 2025

image

It might be changed in firefox 127, See Release Notes

To reduce user fingerprinting information and the risk of some website compatibility issues, the CPU architecture for 32-bit x86 Linux will now be reported as x86_64 in Firefox's User-Agent string and navigator.platform and navigator.oscpu Web APIs.

And I find early version firefox UA at https://useragents.io/uas/mozilla-5-0-windows-nt-10-0-win64-arm64-rv121-0-gecko-20100101-firefox-121-0_8990edbc4e595b80909d7f0cf230d5b5

So if u want to add string arm64 check in UserAgent, Please tell me.
But I still think its not useful.
It depends on you.

@dscho
Copy link
Member

dscho commented Apr 28, 2025

So if u want to add string arm64 check in UserAgent, Please tell me.

You've got good points. Okay, so let's just go with a Chrome/Edge-only solution. Could you fix the code, though, so that it does not throw an exception in Firefox because navigator.userAgentData does not exist?

@rbqvq
Copy link
Contributor Author

rbqvq commented Apr 28, 2025

So if u want to add string arm64 check in UserAgent, Please tell me.

You've got good points. Okay, so let's just go with a Chrome/Edge-only solution. Could you fix the code, though, so that it does not throw an exception in Firefox because navigator.userAgentData does not exist?

try catch not working in firefox?

@dscho
Copy link
Member

dscho commented Apr 28, 2025

try catch not working in firefox?

I am thinking about a guard like if (navigator.userAgentData) or, if it works, navigator.userAgentData?.getHighEntropyValues(...). That way, we won't hide actual problems with that try { ... } catch(e) {} ellipsis.

@dscho
Copy link
Member

dscho commented Apr 28, 2025

if it works, navigator.userAgentData?.getHighEntropyValues(...).

In my hands, this works well in Edge and in Firefox (in the latter, it simply does not show anything):

navigator.userAgentData?.getHighEntropyValues(["architecture", "platform", "bitness"]).then(console.log)

@rbqvq
Copy link
Contributor Author

rbqvq commented Apr 28, 2025

if (!href || !version || !navigator.userAgentData)
	throw 0;

How about it?
I just updated PR with it

New Git-For-Windows does not have Git-32-bit.exe, drop 32-Bit.
Add ARM64 architecture check, I find this check code in VSCode website.

Signed-off-by: Coia Prant <coiaprant@gmail.com>
@rbqvq rbqvq force-pushed the drop-32-bit-and-add-arm64 branch from a1ad7f9 to 607efe1 Compare April 28, 2025 12:56
@rbqvq
Copy link
Contributor Author

rbqvq commented Apr 28, 2025

I already report this bug to firefox
https://bugzilla.mozilla.org/show_bug.cgi?id=1963050

Firefox said in Win11 it reported as x86_64
https://bugzilla.mozilla.org/show_bug.cgi?id=1763310

Copy link
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much! I agree with you that this is the best we can do for now.

@dscho dscho merged commit ed8701e into git-for-windows:main Apr 30, 2025
1 check 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.

2 participants