Closed Bug 1860417 Opened 1 year ago Closed 7 months ago

Some samsung.com images don't load in Firefox Android because its navigator.appVersion doesn't include "Linux", "Mac", or "Win"

Categories

(Web Compatibility :: Interventions, defect, P2)

Firefox 119
All
Android

Tracking

(relnote-firefox -, firefox120 wontfix, firefox121 wontfix, firefox122 wontfix, firefox123 wontfix, firefox124 wontfix, firefox125 wontfix, firefox126 wontfix, firefox127 wontfix, firefox128 fixed)

RESOLVED FIXED
Tracking Status
relnote-firefox --- -
firefox120 --- wontfix
firefox121 --- wontfix
firefox122 --- wontfix
firefox123 --- wontfix
firefox124 --- wontfix
firefox125 --- wontfix
firefox126 --- wontfix
firefox127 --- wontfix
firefox128 --- fixed

People

(Reporter: yjbrowserjyt, Assigned: cpeterson)

References

()

Details

(Keywords: parity-chrome, site-compat, Whiteboard: [qa-triaged][necko-triaged])

Attachments

(1 file, 2 obsolete files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/118.0

Steps to reproduce:

Visit this website https://www.samsung.com/cn/smartphones/galaxy-s23-ultra/

Actual results:

found that the image cannot be loaded properly

Expected results:

After my development and debugging, I found thatCheckOS: (n=(n=navigator. appVersion. match (/(mac | win | Linux)/i))? N [1]. toLowerCase(): '', void document. documentElement. classList. add (n)) This code causesOn mobile Firefox, navigator.appVersion results in "5.0 (Android 13)";But on mobile browsers such as Chrome, you can get "5.0 (Linux; Android 13; LE2100 Build/TP1A. 220905.001) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.52499.126 Mobile Safari/537.36"Please add more information to navigator.appVersion to make it compatible like Chrome.

I guess it's Samsung 's site problem.

Key point is that
if n is "" , document.documentElement.classList.add(n) will raise an error Uncaught DOMException: DOMTokenList.add: The empty string is not a valid token. and cause that following code will not be executed (including the image loader related code).

So Samsung need to make their "checkos" more robust. Either making the failure of checkos not affecting following code , or make checkos more accurately.

Keywords: site-compat
Product: Fenix → GeckoView
Product: GeckoView → Fenix

(In reply to jackyzy823 from comment #1)

I guess it's Samsung 's site problem.

Key point is that
if n is "" , document.documentElement.classList.add(n) will raise an error Uncaught DOMException: DOMTokenList.add: The empty string is not a valid token. and cause that following code will not be executed (including the image loader related code).

So Samsung need to make their "checkos" more robust. Either making the failure of checkos not affecting following code , or make checkos more accurately.

Through searching on the search engine, I found that the checkos used by Samsung has become a common practice. However, it cannot be used on Firefox and can only cause problems on more websites. This result is undesirable. Ensuring Firefox catches up with Chrome in terms of website compatibility is a prerequisite for the better development of Firefox.

Thanks for hint.

I found a similar issue bug 1799968 and https://github.com/webcompat/web-bugs/issues/108993 based on the search of "navigator. appVersion. match (/(mac | win | Linux)/i)"

As suggested in https://github.com/webcompat/web-bugs/issues/108993#issuecomment-1224778264 , we could site-patch this by re-writing navigator.appVersion

See Also: → 1799968

The severity field is not set for this bug.
:jonalmeida, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(jonalmeida942)

Based on jackyzy823's comments, I'll mark this ticket as confirmed.

Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(jonalmeida942)
Whiteboard: [qa-triaged]

    There are also privacy concerns about the interface.
    See also: https://bugzilla.mozilla.org/show_bug.cgi?id=1868415

    And sincerely I do not understand why the site would require such information to load images...
    Looks like counter-productive design.

    If the site primarily targets Mainland China: may consider filing a complaint to the PRC MIIT (中华人民共和国工业和信息化部).
    Beyond reason data acquisition is prohibited... at least proclaimed:
    https://www.gov.cn/zhengce/2022-08/23/content_5722717.htm

    [ Quote jian @ CE 2023-10-22 14:46:13 UTC:
https://bugzilla.mozilla.org/show_bug.cgi?id=1860417#c2
    Ensuring Firefox catches up with Chrome in terms of website compatibility is a prerequisite for the better development of Firefox. ]
<^>    Significant aspects of Chrome are undesirable.
    In particular: security and privacy.

    What I attained in Chrome:
[[
    JavaScript navigator.userAgent
    = HTTP User-Agent
    = Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

    JavaScript navigator.appVersion
    = 5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
]]

    Setting "general.appversion.override" to "5.0 (Linux; rv:999) Firefox 999" works.

    It appears "navigator.userAgent" shall be derived from User-Agent:
    |*| If User-Agent begins with "Mozilla/": return User-Agent with the initial 8 Bytes (characters) (/^Mozilla\//) stripped.
    |*| Else:
    |*.1| If User-Agent is non-empty: "5.0 ${User-Agent}"
    |*.2| Else: return nothing.

    The above should occur when "general.appversion.override" is not set.

This code causesOn mobile Firefox, navigator.appVersion results in "5.0 (Android 13)";But on mobile browsers such as Chrome, you can get "5.0 (Linux; Android 13; LE2100 Build/TP1A. 220905.001) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.52499.126 Mobile Safari/537.36"

Maybe we should return something like 5.0 (Linux; Android 10) from navigator.appVersion on Android.

Component: General → Browser Engine

For comparison, Chrome's and Safari's navigator.appVersion return the User-Agent string without the Mozilla/ prefix. Firefox just returns a short string like 5.0 (Macintosh).

Changing Firefox's navigator.appVersion to return the User-Agent string without the Mozilla/ prefix still wouldn't fix this webcompat bug because Firefox Android's User-Agent string doesn't mention "Linux".

    For best compatibility, maybe adding "Linux" to Firefox's mobile UA? (also deploying the above logic)

    For reference, Chrome's mobile UA:
    Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36

Actual results:

found that the image cannot be loaded properly

For the record here, when I load https://www.samsung.com/cn/smartphones/galaxy-s23-ultra/ from the US, I'm redirected to https://www.samsung.com.cn/smartphones/galaxy-s23-ultra/. The page's header image loads. The smaller images lower on the page are the ones that don't load in Firefox.

    The redirection appears to be newly added.
    Not necessarily IP related.

    I also noted Firefox Nightly appears have been experimenting desktop User-Agent with this:
    https://github.com/MasterInQuestion/talk/discussions/10

    This could also extend to mobile: "(Linux; Mobile; rv:999)"
    And I believe the remote site mostly doesn't need to know the OS.

For future reference, Samsung's checkOS function is in https://www.samsung.com.cn/samsung/resources/global/galaxy-s23-ultra/common/js/common.min.js

checkOS: (n = (n = navigator.appVersion.match(/(mac|win|linux)/i)) ? n[1].toLowerCase() : ""

Assignee: nobody → cpeterson
Component: Browser Engine → Networking: HTTP
Priority: -- → P2
Product: Fenix → Core
Summary: Please add more information for navigator.appVersion → Some samsung.com images don't load in Firefox Android because its UA string doesn't include "Linux", "Mac", or "Win"
Whiteboard: [qa-triaged] → [qa-triaged][necko-triaged]

I have a patch to add "Linux" to Firefox Android's UA string in Fx 125.

Some examples for reference:

Firefox Android's current UA string just lists "Android":

  • UA string: Mozilla/5.0 (Android 10; Mobile; rv:124.0) Gecko/124.0 Firefox/124.0
  • navigator.appVersion: 5.0 (Android 10)

In contrast, Chrome's Android UA string lists "Linux; Android":

  • UA string: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36
  • navigator.appVersion: 5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36 (Same as its UA string without the Mozilla/ prefix)

I propose adding "Linux" to Firefox's Android UA string:

  • New UA string: Mozilla/5.0 (Linux; Android 10; Mobile; rv:124.0) Gecko/124.0 Firefox/124.0
  • New navigator.appVersion: 5.0 (Linux; Android 10)

Chrome's Android UA string lists "Linux; Android", while Firefox's lists only "Android". This has caused webcompat problems for at least one website (samsung.com) because it assumes every browser UA string will include one of "Windows", "Mac", or "Linux". Let's add "Linux; Android" to Firefox's UA string, like Chrome's, to satisfy that website assumption.

Firefox's current Android UA string:

Mozilla/5.0 (Android 10; Mobile; rv:125.0) Gecko/125.0 Firefox/125.0

Firefox's new Android UA string:

Mozilla/5.0 (Linux; Android 10; Mobile; rv:125.0) Gecko/125.0 Firefox/125.0

For comparison, an example of Chrome's Android UA string:

Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36

Unless there are many websites relying on "Linux" in the UA string, I think a better fix would be an intervention like the one added at https://github.com/mozilla-extensions/webcompat-addon/commit/df506ff0f3f66cd948a2825f6f74ca2c2eff7406

(In reply to Mathew Hodson from comment #20)

Unless there are many websites relying on "Linux" in the UA string, I think a better fix would be an intervention like the one added at https://github.com/mozilla-extensions/webcompat-addon/commit/df506ff0f3f66cd948a2825f6f74ca2c2eff7406

Thanks for the suggestion, Mathew. I didn't know about that samsung.com intervention for Linux. I just talked with Thomas Wisniewski (author of that intervention). He acknowledges adding "Linux" to the Android UA string has risk, but we think it's worth trying. He recommends I add a Nimbus feature flag so we can remotely turn off the "Linux; Android" UA if there is a problem.

Pushed by cpeterson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2b54764bcf29 Add "Linux" to Firefox's Android UA string. r=necko-reviewers,geckoview-reviewers,kershaw,amejiamarmol

Backed out for causing (part of commit message)

Could you please take a look at this?
Thank you!

Flags: needinfo?(cpeterson)

Some media tests failed because they had special cases for desktop Linux and checked for navigator.userAgent.includes("Linux"), which now matches both desktop Linux and Android. I will update the tests to check for "Linux && !Android".

https://searchfox.org/mozilla-central/search?q=navigator.%2BLinux&path=dom%2Fmedia&case=true&regexp=true

Flags: needinfo?(cpeterson)

I don't think these test issues with the new "Linux; Android" UA string indicate a high risk for webcompat issues with real websites.

I've tested the new "Linux; Android" UA string on some current UA parser libraries (client and server side) without problem:

https://uaparser.js.org/
https://bowser-js.github.io/bowser-online/
https://github.com/ua-parser/uap-core/tree/master (needs a client like https://github.com/ua-parser/uap-python)
https://exiguus.github.io/js.device.detector/

    Even much more aggressive change like I previously mentioned:
    https://bugzilla.mozilla.org/show_bug.cgi?id=1860417#c16
    ; is unlikely to cause any real issue.

(In reply to Master ? [:masterquestionable] from comment #26)

    Even much more aggressive change like I previously mentioned:
    https://bugzilla.mozilla.org/show_bug.cgi?id=1860417#c16
    ; is unlikely to cause any real issue.

We can't change the UA string from (Android ##; Mobile; rv:###.0) to something like generic like (Linux; Mobile; rv:999) at this time (or at least it would be outside the scope of this bug fix). Some websites depend on the Android OS name or version, such as:

  • Duo's "Trusted Endpoint" checks whether the user's Android OS version meets some minimum version requirement. This was broken in Fx 122 on Android in bug 1876742.
  • (For better or worse) some websites like Reddit want to encourage users to install a native Android or iOS app.

Now that Firefox's Android UA string includes "Linux" to more closely match Chrome's Android UA string (to fix some webcompat issues), tests need to check for "Linux && !Android" to distinguish desktop Linux from Android.

These tests' Linux checks were added in bug 1849108.

Attachment #9382442 - Attachment description: Bug 1860417 - Add "Linux" to Firefox's Android UA string. r?#necko-reviewers,#geckoview-reviewers → Bug 1860417 - Part 2: Add "Linux" to Firefox's Android UA string. r?#necko-reviewers,#geckoview-reviewers

    “Duo's "Trusted Endpoint" checks whether the user's Android OS version meets some minimum version requirement.”
<^>    This is eventually malconfigured administration policies by the user themselves: Bad assertions.
    To address similar: exposing the "general.useragent.override" straightforward, appears to be the most viable solution.
    (and I personally think "about:config" is a crucial part)

    "outside the scope"...
    不识 庐山 真面目: 只缘身在此山中.
+    Unable to tell Lú Mountain's true look: For self already in the mountain.
    .
    At many times the real problem is indeed "outside the scope".

    I'm also interested in deploying the logic I previously mentioned:
    https://bugzilla.mozilla.org/show_bug.cgi?id=1860417#c11

    Just not sure how to commit.

Pushed by cpeterson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/aa1041e84618 Part 1: Fix desktop Linux checks in WebRTC tests. r=webrtc-reviewers,pehrsons
Pushed by cpeterson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f04937624f9d Part 2: Add "Linux" to Firefox's Android UA string. r=necko-reviewers,geckoview-reviewers,kershaw,amejiamarmol
Status: NEW → RESOLVED
Closed: 10 months ago
Resolution: --- → FIXED
Target Milestone: --- → 126 Branch

I think we should add Linux to RFP spoofed mobile as well for better compat, in a new issue of course. If there are no objections, I'll open a ticket unless someone beats me to it cc: tjr

current RFP

  • "appVersion": "5.0 (Android 10)",
  • "ua_os": "Android 10; Mobile",

ni tjr

Flags: needinfo?(tom)
Flags: needinfo?(tom)

Release Note Request

[Why is this notable]: This change should fix some webcompat issues, but has a small risk of introducing new webcompat issues.

[Affects Firefox for Android]: Yes. It only affects Android.

[Suggested wording]: Add "Linux" to Firefox Android's User-Agent string to fix some website compatibility issues.

[Links (documentation, blog post, etc)]: None? We could point to MDN's Firefox User-Agent string reference but I haven't updated yet. I can try to update it before 126 ships. But if we later have to revert the new User-Agent string, I'll need to revert the MDN change, too.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox#android_version_41_and_above

relnote-firefox: --- → ?

Thanks, added to the Fx126 beta release notes, please allow 30 minutes for the site to update and review doc.
Keeping the relnote-firefox flag as ? to keep it on the radar for inclusion in the final Fx126 release notes

See Also: → 1868415
See Also: 1868415

This is breaking Tier 1 Google search.

Regressions: 1895513
Status: RESOLVED → REOPENED
Flags: needinfo?(cpeterson)
Resolution: FIXED → ---

Rejecting release note request since this will be backed out from central and release.

Regressions: 1895581

Putting Linux; after Android doesn't break Google search. We should check if it fixes these things.

Depends on: 1799968
Flags: needinfo?(cpeterson)
See Also: 1799968
Summary: Some samsung.com images don't load in Firefox Android because its UA string doesn't include "Linux", "Mac", or "Win" → Some samsung.com images don't load in Firefox Android because its navigator.appVersion doesn't include "Linux", "Mac", or "Win"

I submitted an intervention to the Webcompat System Addon (applying bug 1799968's intervention for samsung.com on Linux to Android):

https://github.com/mozilla-extensions/webcompat-addon/pull/342

There are some r+ patches which didn't land and no activity in this bug for 2 weeks.
:cpeterson, could you have a look please?
If you still have some work to do, you can add an action "Plan Changes" in Phabricator.
For more information, please visit BugBot documentation.

Flags: needinfo?(cpeterson)
Flags: needinfo?(apehrson)

Comment on attachment 9382442 [details]
Bug 1860417 - Part 2: Add "Linux" to Firefox's Android UA string. r?#necko-reviewers,#geckoview-reviewers

There are some r+ patches which didn't land and no activity in this bug for 2 weeks.

The attached patches will be obsoleted Webcompat System Addon fix https://github.com/mozilla-extensions/webcompat-addon/pull/342

Attachment #9382442 - Attachment is obsolete: true
Flags: needinfo?(cpeterson)
Flags: needinfo?(apehrson)
Attachment #9390689 - Attachment is obsolete: true
Target Milestone: 126 Branch → ---
Depends on: 1876368

(In reply to Chris Peterson [:cpeterson] from comment #46)

Comment on attachment 9382442 [details]
Bug 1860417 - Part 2: Add "Linux" to Firefox's Android UA string. r?#necko-reviewers,#geckoview-reviewers

There are some r+ patches which didn't land and no activity in this bug for 2 weeks.

The attached patches will be obsoleted Webcompat System Addon fix https://github.com/mozilla-extensions/webcompat-addon/pull/342

The WebCompat addon with this intervention landed in Firefox 128 in bug 1876368.

Status: REOPENED → RESOLVED
Closed: 10 months ago7 months ago
Component: Networking: HTTP → Interventions
Product: Core → Web Compatibility
Resolution: --- → FIXED
No longer regressions: 1895581
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: