Closed Bug 1373607 Opened 7 years ago Closed 7 years ago

Expose layout.css.devPixelsPerPx to WebExtensions

Categories

(WebExtensions :: Untriaged, defect)

Unspecified
All
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: d, Unassigned)

References

Details

(Whiteboard: [design-decision-denied][triaged])

User Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0
Build ID: 20170526184742

Steps to reproduce:

Summary: WebExtensions currently can't control high DPI scaling, which prevents convenient adjustments to different screen pixel densities.

On some platforms, the OS or Firefox do not properly autodetect the pixel density of high DPI screens, or the user might have other preferences for scaling than what the OS chooses.

Users can override this decision by manually setting layout.css.devPixelsPerPx in about:config. This scales both the Firefox chrome and web page contents globally and is orthogonal to zooming contents, which doesn't affect the chrome and might still be necessary on a per-origin basis, for example if a web site uses really small text.

While navigating to about:config and updating the setting manually is acceptable if done seldomly, it is really inconvenient when switching between normal and high DPI screens. In my case, I use a 14" laptop and, when at my desk, a 24" external monitor, both showing 1920x1200 px. On the laptop screen, contents are uncomfortably small because they are not scaled up automatically. A scale factor of 1.4x feels optimal, but the OS only allows choosing between 1x and 2x (running Fedora 25 with Gnome 3).

To solve this problem, I built the fxdpi extension [0] which enables the user to toggle between a custom scale factor and the default with a button press. When I switch between monitors, I hit the fxdpi button and Firefox changes scale instantly. There's another extension which takes a slightly different approach but also uses the same setting [1].

[0] https://addons.mozilla.org/en-US/firefox/addon/fxdpi/
[1] https://addons.mozilla.org/en-US/firefox/addon/autohidpi/



Actual results:

I tried to port fxdpi to WebExtensions using the zoom API, but soon found out that this cannot be done properly:

* The chrome would not be scaled.
* per-origin zooming is not an option because it would store (and override!) a non-default per-origin zoom level for each page visited, which is not scalable.
* per-tab zooming is currently broken (bug 1286953) and would lead to a bad user experience because the zoom level would be reset on navigation so that an extension would need to restore it after page load, leading to flashing between zoom levels.



Expected results:

With an API for getting and setting layout.css.devPixelsPerPx, porting would be no problem.
OS: Unspecified → All
I think this was planned in the theming API.
Whiteboard: [design-decision-needed]
Hi Daniel, this has been added to the agenda for the July 18 WebExtensions APIs triage meeting. Would you be able to join us? 

Wiki: https://wiki.mozilla.org/Add-ons/Contribute/Triage#Next_Meeting

Agenda: https://docs.google.com/document/d/1gWszBunGAyOJ_V8_HMECXJuZ4Gd_HTM_M7xjDSwSxeo/edit#heading=h.du5ihvu5p6ro
Sure, I'll attend the meeting. See you on Tuesday.
Thanks for coming to the meeting Daniel. The main use case presented was moving Firefox between low and hi DPI monitors. In my time I've had this work pretty flawlessly on Windows and OS X. Daniel mentioned that he's on Linux and I'm a bit sketchy on the level of DPI support on Linux.

I feel like this is a bug in Firefox that we should aim to fix on Linux - instead of providing an API for a small audience of users. Those extensions have around 200 and 1,200 users.

I'm not sure where this bug should go, Gijs, any advice there?
Flags: needinfo?(gijskruitbosch+bugs)
(In reply to Andy McKay [:andym] from comment #4)
> Thanks for coming to the meeting Daniel. The main use case presented was
> moving Firefox between low and hi DPI monitors. In my time I've had this
> work pretty flawlessly on Windows and OS X. Daniel mentioned that he's on
> Linux and I'm a bit sketchy on the level of DPI support on Linux.
> 
> I feel like this is a bug in Firefox that we should aim to fix on Linux -
> instead of providing an API for a small audience of users. Those extensions
> have around 200 and 1,200 users.
> 
> I'm not sure where this bug should go, Gijs, any advice there?

I wasn't at the meeting and so I'm a bit confused.

The rounding of Linux dpi stuff mentioned in comment #0 is bug 1214470, AIUI, though my understanding is that we now do support a 1.5x step rather than just the int steps, per bug 1271893 (since Fx49).

More generally, the pref controls all windows, so I'm unclear on how it helps if you have windows split between multiple screens with different density. On Windows and OS X, it is possible for the different screens to have different DPI, and having multiple Firefox windows on the different screens should work correctly (ie the different windows will have different DPI). I don't know if/why that is(n't) possible on Linux, but I assume it would be a GTK widget issue if it is possible on a platform level and we don't follow user settings correctly.

I assume some of this was clarified in the meeting. What specifically do you think should get fixed in this bug, if not a webextensions API? If some of it is still not clear, you could redirect needinfo to Daniel and/or to :karlt, who should know more here.
Flags: needinfo?(gijskruitbosch+bugs) → needinfo?(amckay)
In an ideal world, I'd like to retire my extension and have Firefox scale itself according to the current monitor's DPI. However, Gnome and many other desktop environments currently don't support fractional scaling. On Gnome, GTK's DPI (which is used in Firefox) is always 96, with an optional integral scale factor [1]. Firefox therefore won't use 1.5x scaling when running on Gnome.

Interestingly, automatic scaling seems to be a partly unsolved problem on Windows, too. My extension has as many users on Windows as it has on Linux, so there seems to be some demand for customizing and quickly toggling between scale factors (probably for people on Windows before 10 where scaling got much better).

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=489771#c9 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=489771#c17
(In reply to Daniel Seither from comment #6)
> In an ideal world, I'd like to retire my extension and have Firefox scale
> itself according to the current monitor's DPI. However, Gnome and many other
> desktop environments currently don't support fractional scaling. On Gnome,
> GTK's DPI (which is used in Firefox) is always 96, with an optional integral
> scale factor [1]. Firefox therefore won't use 1.5x scaling when running on
> Gnome.

(Note that we also use our own scaling on top of what we obtain from gtk.  I attempted to provide a fix in bug 1366922 but the conversation there has been stalled.)
Daniel, it sounds like bug 1366922 would be what you need for Linux, thanks Ehsan for the heads up on that.
Flags: needinfo?(amckay)
Whiteboard: [design-decision-needed] → [design-decision-denied][triaged]
Just checked out the relevant Firefox sources as linked in bug 1366922 and found the reason for Firefox not scaling to my monitor DPI: Firefox uses the font scaling factor (floating point) of GTK, not (only) the window scaling factor (integer). When adjusting the former to for example 1.5, Firefox properly scales its content as introduced in Fx54 (bug 1335465), but many other programs look ugly or even are unusable, because controls which are not scaled can't accomodate the larger text. Bug 1366922 is only concerned with adding fractional scaling factors other than 1.5, so it's not really the problem I'm having.

The Gnome team is working on proper fractional scaling without abusing the font scaling factor [1], which hopefully will land in Gnome 3.26 being released in October, shortly before Firefox 57 which will block legacy extensions. So, thank you for the conversation and I'll keep my fingers crossed that with Gnome 3.26, my addon will no longer be needed.

[1] http://blog.3v1n0.net/informatica/linux/gnome-fractional-and-multi-monitor-scaling-hackfest-the-report/
Closing based on comment 9.
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → WONTFIX
I would still appreciate a WebExtensions API that exposes layout.css.devPixelsPerPx so I could still set custom devpx/px ratios, for example I view images at 1.0 and view webpages at 1.5, and sometimes 2.0. Being able to toggle through these settings at the click of a button [1] saves me the trouble of having to manually set the value each time.

[1] https://addons.mozilla.org/en-US/firefox/addon/custom-scaling-toggle/
Some websites that test the display [1] require a 1.0 ratio to function correctly, and having an extension (or just a built-in button) that can toggle the ratio would be helpful.

[1] http://www.lagom.nl/lcd-test/viewing_angle.php
I agree that having this supported via the WebExtensions API would be useful. I regularly use Firefox in a multi-monitor setup, where different monitors have different DPIs. To the best of my knowledge (tell me I'm wrong!), the scaling factor from Gnome is only checked by Firefox when Firefox starts up. This means that if I drag Firefox over to my other window, the scaling is wrong. I'm a long-time and multi-times-a-day user of this plugin:

https://github.com/saikocat/firefox-fontdpi

... which lets me change DPI on-the-fly depending on where my browser window is. Am I correct in understanding that without adding this capability to the WebExtensions API, an add-on like this is not possible?
(In reply to Daniel Seither from comment #9)
> The Gnome team is working on proper fractional scaling without abusing the
> font scaling factor [1], which hopefully will land in Gnome 3.26 being
> released in October.

For the record, Gnome 3.26 is now available on some distros. I just upgraded to it. I didn't see any scaling occurring when I moved Firefox from a non-DPI monitor to a DPI one. Per [1], it seems this feature is still hidden behind a gsetting pref. 

[1] https://bugzilla.gnome.org/show_bug.cgi?id=788040#c0
Disappointing that this is tagged as "RESOLVED WONTFIX"

On Windows Firefox is now unusable on my XPS13 with HighDPI and an external non-highDPI monitor. I'm advised that extensions such as:

https://addons.mozilla.org/en-US/firefox/addon/autohidpi/

are no longer possible due to lack of API support. Ideally I'd like Firefox to support autoscaling depending upon display device, but failing that the use of an extension will fit the bill.

As it stands I'm back to Chrome until this is resolved.

Mark
Hmm.. after investigating further I noticed that my layout.css.devPixelsPerPx was set to 1.0 and indicated as having been modified. On reverting this back to the default it changed to -1.0 which now scales Firefox correctly on both my non-HighDPI and HighDPI screens.

So looks as if this works fine.

Mark
I'm a bit confused, is or is there not a native way to support differing DPIs between monitors in firefox, in X11? How do I set the values? I don't use gnome proper, I use just a window manager.
I came here because my life used to depend on FxDPI - or close enough ;-) thank you Daniel!

I suggest we all express our interest for https://bugzilla.mozilla.org/show_bug.cgi?id=332275, which would hopefully and at long last address hiDPI use cases in FF natively.

It's been raised only 12 years ago but was tentatively scheduled for FF 57.  With a bit of sponsorship from users, it might finally happen sometime soon?
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.