MicrosoftDocs / edge-developer

Developer documentation for Edge.
https://learn.microsoft.com/microsoft-edge/developer/
Creative Commons Attribution 4.0 International
381 stars 507 forks source link

Feedback: "Detect Windows 11 and CPU architecture using User-Agent Client Hints" #2579

Open khelkun opened 1 year ago

khelkun commented 1 year ago

About this part fo the documentation, here is my usage about Hololens detection from Edge:

Afaik Windows platform version is 12.0.0 for "Windows Holographic for Business" which is the current Hololens 2 Windows edition.

Actually the values in "Detecting specific Windows versions" are not accurate. For example my Windows 21H2 Desktop as a value equal to 10.0.0 for navigator.userAgentData.getHighEntropyValues(["platformVersion"]) .then(r => r.platformVersion).
Also documenting the Hololens Windows edition would be nice: 12.0.0 for Hololens 2. What about Hololens 1 (11.0.0 ?). What about Windows phones ?


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

AB#44527596

captainbrosset commented 1 year ago

Thank you for reporting the inaccuracy. Let me make sure this is tracked by the team.

khelkun commented 12 months ago

Apparently the latest Windows platform on Hololens 2 is now 15.0.0. Is it also the case for the Windows 11 desktop (no hololens platform). I'm currently relying on this platform version to detect edge is running on hololens, because since some version 112+ of Edge the user agent of Edge is the same for the Windows Hololens 2 platform and the regular Windows Desktop platform.

However 15.0.0 is also the platform version when using Edge on the latest Windows 11 on a Desktop (Microsoft Surface), so I'm not able to detect Edge is running on Hololens from the HTTP headers anymore.

captainbrosset commented 12 months ago

Thank you for the additional detail on this. We have, unfortunately, not been able to work on this issue since you filed it, but this is very useful information. We'll keep it in mind when we find the time to tackle this issue.

khelkun commented 12 months ago

@captainbrosset I'm a bit deperate here to be honest: I've seek the web browser API and the HTTP headers, but I cannot find a single relevant difference between Edge running on a regular Windows 11 laptop up to date, and Edge running on Hololens 2 up to date. Any help would be very nice.

Well the latest Edge version on Hololens 2 is 117.0.2045.43 while the Edge version on a regular laptop Windows 11 up to date is 117.0.2045.47. But relying on the "117.0.2045.43" version as a condition for "I'm Edge running on Hololens 2" is not a solution.

captainbrosset commented 12 months ago

Let me try to see if I can get you an answer.

captainbrosset commented 12 months ago

One thought, although I don't have a hololens device to test, is to test for WebXR support. There might be differences in how the API is implemented/supported across devices. Would the XRInputSource.hand property be available for example?

khelkun commented 12 months ago

One thought, although I don't have a hololens device to test, is to test for WebXR support. There might be differences in how the API is implemented/supported across devices. Would the XRInputSource.hand property be available for example?

That's a possible option, but Edge exists on Android smartphones which would probably have WebXR support. And I wonder if latest Microsoft Surface devices also support WebXR on Edge.

But testing for XRInputSource.hand property could be a way to go, you're right. I'm gonna check that on Hololens, and hopr this is not supported by some Android devices and Microsoft Surface devices.

captainbrosset commented 12 months ago

Another lead, open https://webglreport.com/?v=2 on both devices and see if there are ways to differentiate the platform.

khelkun commented 12 months ago

Apparently XRInputSource.hand is not supported by any browser yet including Edge

khelkun commented 12 months ago

This OVR_multiview extension (and OVR_multiview2) is about stereo rendering, e.g per eye rendering, and could have been an option. But it's supported by chrome web browser on my workstation, so it's not an option.

An Edge extension may allow my website to detect it's browsed from Edge on Hololens by using some part of the extension API, for example the enterprise_hardwarePlatform which is supported according to the Edge documentation. It would not be an ideal solution but better than nothing.

Still I'm a bit confused about the user agent: is it possible for Edge to have a distinct user agent on Hololens? There was a difference before version 112.

khelkun commented 11 months ago

@captainbrosset any distinction in the HTTP header sent by Hololens Edge would be very nice.

Indeed I really have no other solution than developing an Edge extension to detect it runs from Hololens. For example any specific string like "Hololens Edge";"v=99" in the SEC-CH-UA HTTP header would allow to identify it's Edge for Hololens.

captainbrosset commented 11 months ago

@khelkun taking a step back, I never asked why you needed to detect Edge running on Hololens in the first place. It's usually much better to detect the presence of a feature on the web vs. detecting a particular device type. I assume that's not an option for you, but would love to understand why.

khelkun commented 11 months ago

@captainbrosset sorry that I've not explained that in the first place (I thought I did). We have a web portal in which you can click and open a 3D asset viewer implemented as a web app:

Sure, we could somehow put 2 distinct controls (buttons) to let the user choose to launch the web viewer or the hololens viewer in the web portal, but that's not nice, plus the fact that there's many places and shortcuts in the web portal to launch the viewer. So this alternative is not very user friendly in terms of UX.

captainbrosset commented 11 months ago

Good news. I'm not sure when this will be available in Edge (in theory, should be the next Canary build), but we're adding a new user agent model value for HoloLens.

This means that this code:

navigator.userAgentData.getHighEntropyValues(["model"]).then(values => {
  console.log(values.model);
});

Will now print Holographic (this is in line with Xbox, where the code would print Xbox).