Closed Bug 1790516 Opened 2 years ago Closed 5 days ago

Should GeckoView default to desktop mode UA on tablets? (like iPad Safari)

Categories

(GeckoView :: General, enhancement, P3)

All
Android
enhancement

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1910768

People

(Reporter: cpeterson, Assigned: calu)

References

(Depends on 1 open bug, Blocks 2 open bugs, Regressed 1 open bug)

Details

(Keywords: parity-chrome, parity-safari, Whiteboard: [fxdroid] [group4])

Attachments

(2 obsolete files)

We have some long-standing issues on Android tablets because Fenix sends a "Mobile" UA on tablets, but some mobile sites aren't usable on a large tablet screen. (For example, see like https://github.com/mozilla-mobile/fenix/issues/1848 and https://github.com/webcompat/web-bugs/issues/107331.)

These tablet issues don't affect other mobile browsers because:

  • iPad Safari's UA matches desktop Safari's UA. Users can switch to an iPhone UA if the desktop site is unusable.
  • Chrome's UA on tablets mentions "Android", but not "Mobile" or "Tablet". Users can switch to a desktop UA if the Android-without-Mobile site is unusable.
  • Legacy Fennec used to send a "Tablet" UA instead of "Mobile". Fenix never implemented this, so it always sends "Mobile". Users can switch to a desktop UA if the mobile site is unusable.

We'd like to follow Safari's approach: when running on a tablet, default to the desktop mode UA and allow users to switch back to the mobile UA. We debated following Chrome's approach, sending an Android-without-Mobile UA, but that is riskier because that's a new and untested UA string. Also, websites would detect "Android" in the UA and show annoying popups promoting their Android apps.

We want to make this change in GeckoView instead of the Fenix frontend because we want all GeckoView-based apps (including Focus and third-party apps) to have an improved user experience on tablets.

I think we can fix this without adding an new UI by changing GeckoView to check if it's running on a tablet when it initializes mDesktopMode:

https://searchfox.org/mozilla-central/search?q=mDesktopMode&redirect=false

How do we know if we are running on a tablet? I don't know.

Before committing to this approach, we need to test whether the desktop mode UA or the Android-without-Mobile UA fixes more of the sites reported to be unusable on tablets.

See Also: → 1555035
Whiteboard: [geckoview:m107?]
Priority: P2 → P3

iPadOS14+ has both UA and default setting is desktop UA. So I think that we change Fenix's (android-component) default to USER_AGENT_MODE_DESKTOP if the device is Tablet.

I found that we return Tablet UA until Fennec 68. But the latest GV returns Mobile UA. As long as our code, we should return tablet UA if tablet. But due to the bug that is explained by bug 1798617, we returns Mobile UA unfortunately.

Has this been implemented recently? Version 109 has caused websites to serve desktop (tablet?) versions on my Surface Duo. Please see bug 1807209 for details.

Has this been implemented recently? Version 109 has caused websites to serve desktop (tablet?) versions on my Surface Duo. Please see bug 1807209 for details.

Even if 109, UA on tablet device keep mobile. We don't decide future plan yet.

Tasks and enhancements should have severity N/A.

Severity: S3 → N/A
Component: General → Core
Summary: GeckoView should default to desktop mode UA on tablets → Should GeckoView should default to desktop mode UA on tablets? (like iPad Safari)
Blocks: 1825465

Google now doing this with Chrome on "premium" tablets https://developer.chrome.com/blog/desktop-mode?hl=en

Chrome's criteria for deciding whether an Android tablet is "premium" is defined by display size (in inches), display pixels, and memory here:

https://source.chromium.org/chromium/chromium/src/+/main:chrome/android/java/src/org/chromium/chrome/browser/tab/RequestDesktopUtils.java;l=223-250;drc=38dd4544f7d62fa087627be4c827af525b65be59

    /**
     * Determines whether the desktop site global setting should be enabled by default.
     * @param displaySizeInInches The device primary display size, in inches.
     * @param context The current context.
     * @return Whether the desktop site global setting should be default-enabled.
     */
    static boolean shouldDefaultEnableGlobalSetting(double displaySizeInInches, Context context) {
        // Do not default-enable if memory is below threshold.
        if (SysUtils.amountOfPhysicalMemoryKB()
                < DEFAULT_GLOBAL_SETTING_DEFAULT_ON_MEMORY_LIMIT_THRESHOLD_MB
                        * ConversionUtils.KILOBYTES_PER_MEGABYTE) {
            return false;
        }

        // Do not default-enable for x86 devices.
        if (!isCpuArchitectureArm()) {
            return false;
        }

        // Do not default-enable on external display.
        if (isOnExternalDisplay(context)) {
            return false;
        }

        // Do not default-enable if the screen size in inches is below threshold.
        if (displaySizeInInches < DEFAULT_GLOBAL_SETTING_DEFAULT_ON_DISPLAY_SIZE_THRESHOLD_INCHES) {
            return false;
        }

        // Do not default-enable if the smallest screen size in dp is below threshold.
        if (context.getResources().getConfiguration().smallestScreenWidthDp
                < DEFAULT_GLOBAL_SETTING_DEFAULT_ON_SMALLEST_SCREEN_WIDTH_THRESHOLD_DP) {
            return false;
        }

        ...

And the default values are defined here:

https://source.chromium.org/chromium/chromium/src/+/main:chrome/android/java/src/org/chromium/chrome/browser/tab/RequestDesktopUtils.java;l=73-75;drc=aaed62d98a863a6ba93615e538321525a11bdebd

    static final double DEFAULT_GLOBAL_SETTING_DEFAULT_ON_DISPLAY_SIZE_THRESHOLD_INCHES = 10.0;
    static final int DEFAULT_GLOBAL_SETTING_DEFAULT_ON_SMALLEST_SCREEN_WIDTH_THRESHOLD_DP = 600;
    static final int DEFAULT_GLOBAL_SETTING_DEFAULT_ON_MEMORY_LIMIT_THRESHOLD_MB = 6500;

https://bugzilla.mozilla.org/show_bug.cgi?id=1790516#c8

The decision to exclude all but ARM from this seems strange. RISC-V and especially x86* devices can certainly benefit from the same logic afforded to ARM devices — my x86-64 (LINX 1010b) tablets are smaller than my ARM tablets.

Component: Core → General
Whiteboard: [fxdroid] [group4]
Assignee: nobody → calu
Attachment #9416885 - Attachment description: WIP: Bug 1790516 - Default desktop mode for tablets → Bug 1790516 - Default desktop mode for tablets
Blocks: 1910768
Blocks: 1912488
Pushed by calu@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7ae3f62621b8 Default desktop mode for tablets r=geckoview-reviewers,android-reviewers,owlish,007

Backed out for causing gv-unit failures on GeckoInputStreamTest#multipleWriters.

[task 2024-09-05T14:59:53.678Z] 14:59:53     INFO -  TEST-START | org.mozilla.geckoview.GeckoInputStreamTest#multipleWriters
[task 2024-09-05T14:59:53.710Z] 14:59:53     INFO -  org.mozilla.geckoview.test | INSTRUMENTATION_STATUS: numtests=1162
[task 2024-09-05T14:59:53.710Z] 14:59:53     INFO -  org.mozilla.geckoview.test | INSTRUMENTATION_STATUS: stream=
[task 2024-09-05T14:59:53.710Z] 14:59:53     INFO -  org.mozilla.geckoview.test | Error in multipleWriters(org.mozilla.geckoview.GeckoInputStreamTest):
[task 2024-09-05T14:59:53.710Z] 14:59:53     INFO -  org.mozilla.geckoview.test | java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
[task 2024-09-05T14:59:53.711Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.gecko.util.HardwareUtils.init(HardwareUtils.java:29)
[task 2024-09-05T14:59:53.711Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.gecko.util.HardwareUtils.isTablet(HardwareUtils.java:42)
[task 2024-09-05T14:59:53.711Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.gecko.GeckoAppShell.isTablet(GeckoAppShell.java:1253)
[task 2024-09-05T14:59:53.711Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.geckoview.GeckoSessionSettings.<init>(GeckoSessionSettings.java:382)
[task 2024-09-05T14:59:53.711Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.geckoview.GeckoSessionSettings.<init>(GeckoSessionSettings.java:354)
[task 2024-09-05T14:59:53.711Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.geckoview.GeckoSessionSettings$Builder.<init>(GeckoSessionSettings.java:32)
[task 2024-09-05T14:59:53.711Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.geckoview.test.rule.GeckoSessionTestRule.<init>(GeckoSessionTestRule.java:875)
[task 2024-09-05T14:59:53.711Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.geckoview.test.rule.GeckoSessionTestRule.<init>(GeckoSessionTestRule.java:886)
[task 2024-09-05T14:59:53.711Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.geckoview.test.BaseSessionTest.<init>(BaseSessionTest.kt:156)
[task 2024-09-05T14:59:53.712Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.geckoview.test.BaseSessionTest.<init>(BaseSessionTest.kt:30)
[task 2024-09-05T14:59:53.712Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.geckoview.test.BaseSessionTest.<init>(BaseSessionTest.kt)
[task 2024-09-05T14:59:53.712Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.geckoview.GeckoInputStreamTest.<init>(GeckoInputStreamTest.java:25)
[task 2024-09-05T14:59:53.712Z] 14:59:53     INFO -  org.mozilla.geckoview.test |
[task 2024-09-05T14:59:53.712Z] 14:59:53     INFO -  org.mozilla.geckoview.test | INSTRUMENTATION_STATUS: id=AndroidJUnitRunner
[task 2024-09-05T14:59:53.712Z] 14:59:53     INFO -  org.mozilla.geckoview.test | INSTRUMENTATION_STATUS: test=multipleWriters
[task 2024-09-05T14:59:53.712Z] 14:59:53     INFO -  org.mozilla.geckoview.test | INSTRUMENTATION_STATUS: class=org.mozilla.geckoview.GeckoInputStreamTest
[task 2024-09-05T14:59:53.712Z] 14:59:53     INFO -  org.mozilla.geckoview.test | INSTRUMENTATION_STATUS: stack=java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
[task 2024-09-05T14:59:53.714Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.gecko.util.HardwareUtils.init(HardwareUtils.java:29)
[task 2024-09-05T14:59:53.714Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.gecko.util.HardwareUtils.isTablet(HardwareUtils.java:42)
[task 2024-09-05T14:59:53.714Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.gecko.GeckoAppShell.isTablet(GeckoAppShell.java:1253)
[task 2024-09-05T14:59:53.714Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.geckoview.GeckoSessionSettings.<init>(GeckoSessionSettings.java:382)
[task 2024-09-05T14:59:53.714Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.geckoview.GeckoSessionSettings.<init>(GeckoSessionSettings.java:354)
[task 2024-09-05T14:59:53.714Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.geckoview.GeckoSessionSettings$Builder.<init>(GeckoSessionSettings.java:32)
[task 2024-09-05T14:59:53.714Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.geckoview.test.rule.GeckoSessionTestRule.<init>(GeckoSessionTestRule.java:875)
[task 2024-09-05T14:59:53.714Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.geckoview.test.rule.GeckoSessionTestRule.<init>(GeckoSessionTestRule.java:886)
[task 2024-09-05T14:59:53.714Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.geckoview.test.BaseSessionTest.<init>(BaseSessionTest.kt:156)
[task 2024-09-05T14:59:53.714Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.geckoview.test.BaseSessionTest.<init>(BaseSessionTest.kt:30)
[task 2024-09-05T14:59:53.714Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.geckoview.test.BaseSessionTest.<init>(BaseSessionTest.kt)
[task 2024-09-05T14:59:53.714Z] 14:59:53     INFO -  org.mozilla.geckoview.test | 	at org.mozilla.geckoview.GeckoInputStreamTest.<init>(GeckoInputStreamTest.java:25)
[task 2024-09-05T14:59:53.714Z] 14:59:53     INFO -  org.mozilla.geckoview.test |
[task 2024-09-05T14:59:53.714Z] 14:59:53     INFO -  org.mozilla.geckoview.test | INSTRUMENTATION_STATUS: current=1
[task 2024-09-05T14:59:53.714Z] 14:59:53     INFO -  org.mozilla.geckoview.test | INSTRUMENTATION_STATUS_CODE: -2
[task 2024-09-05T14:59:53.714Z] 14:59:53     INFO -  Printing logcat for test:
[task 2024-09-05T14:59:53.806Z] 14:59:53     INFO -  None
[task 2024-09-05T14:59:53.806Z] 14:59:53  WARNING -  TEST-UNEXPECTED-FAIL | org.mozilla.geckoview.GeckoInputStreamTest#multipleWriters | java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
[task 2024-09-05T14:59:53.807Z] 14:59:53     INFO -  TEST-INFO took 128ms
[task 2024-09-05T14:59:53.807Z] 14:59:53     INFO -  org.mozilla.geckoview.test | INSTRUMENTATION_STATUS: numtests=1162
[task 2024-09-05T14:59:53.807Z] 14:59:53     INFO -  org.mozilla.geckoview.test | INSTRUMENTATION_STATUS: stream=
[task 2024-09-05T14:59:53.807Z] 14:59:53     INFO -  org.mozilla.geckoview.test | INSTRUMENTATION_STATUS: id=AndroidJUnitRunner
[task 2024-09-05T14:59:53.807Z] 14:59:53     INFO -  org.mozilla.geckoview.test | INSTRUMENTATION_STATUS: test=writeError
[task 2024-09-05T14:59:53.808Z] 14:59:53     INFO -  org.mozilla.geckoview.test | INSTRUMENTATION_STATUS: class=org.mozilla.geckoview.GeckoInputStreamTest
[task 2024-09-05T14:59:53.808Z] 14:59:53     INFO -  org.mozilla.geckoview.test | INSTRUMENTATION_STATUS: current=2
[task 2024-09-05T14:59:53.808Z] 14:59:53     INFO -  org.mozilla.geckoview.test | INSTRUMENTATION_STATUS_CODE: 1
[task 2024-09-05T14:59:53.812Z] 14:59:53     INFO -  TEST-START | org.mozilla.geckoview.GeckoInputStreamTest#writeError
Flags: needinfo?(calu)
Pushed by calu@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/9c1d0c3ff431 Default desktop mode for tablets r=geckoview-reviewers,android-reviewers,owlish,007
Status: NEW → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 132 Branch

I'm guessing we want to nominate this for the Fx132 relnotes. Please go ahead and set the relnote-firefox flag on the bug and fill out the form to do so.

Can QE verify that desktop browsing mode is on default for tablets and large screens and off for mobile devices? Thank you

Flags: needinfo?(calu) → qe-verify+

QE, this will need to be tested for a variety of sites, including ones with video and popular sites.

We should test a foldable device and a large phone (phablet). Those devices are sometimes detected as "tablets", but the desktop site experience might not be appropriate for their screens.

For example, someone on Reddit said Firefox Nightly is detecting their Nokia X20 phone has a tablet and defaulting to desktop sites:

https://www.gsmarena.com/nokia_x20-10838.php

Another device mentioned from this bug (https://bugzilla.mozilla.org/show_bug.cgi?id=1917504) is the Google Pixel 9 Pro XL. It should open mobile viewing, since it is not a tablet, but user says it opened desktop mode. I was not able to reproduce the bug with a Firebase device.

Running Fenix Nightly, buildid 20240907092150, I started having the FastMail webpage showing something similar to the desktop view. Forcing it to desktop view then disabling gets me back the correct view.

Repro on Sony Xperia I V, Android 14.

When it happens to me (I just repro'd, it's really trivial for me) what would be the thing to check to make sure the issue is related to that bug? Given the timeline and the behavior, I'm confident, but ...

Flags: needinfo?(cpeterson)
Depends on: 1917730

Sounds like Fenix is treating some large phones as "small tablets". GeckoView's HardwareUtils checks for "large" and "small" tablets. If large phones are detected as "small tablets", maybe we should only default to the desktop UA string on large tablets.

https://searchfox.org/mozilla-central/rev/0386e3e47504286ee176ab373a0562262e7c98b4/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/HardwareUtils.java#28-35

I filed bug 1917730 to investigate that.

No longer blocks: 1910768, 1912488
Depends on: 1912488, 1910768
Flags: needinfo?(cpeterson)
Summary: Should GeckoView should default to desktop mode UA on tablets? (like iPad Safari) → Should GeckoView default to desktop mode UA on tablets? (like iPad Safari)
Regressions: 1917730
No longer depends on: 1917730
Regressions: 1918029

Verified on the Fenix Nightly 132.0a1 build from 9/11 with the following tablets:

  • Samsung Galaxy Tab S9 Ultra (Android 14),
  • Lenovo TB X606X (Android 10),
  • Huawei MediaPad M3 Lite (Android 7),

and the following foldable phones:

  • Honor Magic V2 (Android 13) - 7.92 inches screen size unfolded,
  • Samsung GalaxyZ Fold 4 (Android 13) - 7.6 inches screen size unfolded.

We do not have phablets to test on.

On all the above mentioned devices, we've verified that desktop browsing mode is on default for tablets and large screens.

We've also verified on the following phones that the desktop mode is not ON by default, unless required by the user:

  • Google Pixel 6 (Android 15),
  • Oppo Find N2 Flip (Android 14),
  • Samsung Galaxy S24 (Android 14),
  • Oppo Find X3 Lite (Android 11).
Flags: qe-verify+

A patch has been attached on this bug, which was already closed. Filing a separate bug will ensure better tracking. If this was not by mistake and further action is needed, please alert the appropriate party. (Or: if the patch doesn't change behavior -- e.g. landing a test case, or fixing a typo -- then feel free to disregard this message)

Attachment #9424526 - Attachment is obsolete: true

Backed out as requested by developer

Backout link

Status: RESOLVED → REOPENED
Flags: needinfo?(calu)
Resolution: FIXED → ---
Target Milestone: 132 Branch → ---
Flags: needinfo?(calu)

Closing as this work is being handled by https://bugzilla.mozilla.org/show_bug.cgi?id=1910768.

Status: REOPENED → RESOLVED
Closed: 1 month ago5 days ago
Duplicate of bug: 1910768
Resolution: --- → DUPLICATE
Attachment #9416885 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: