Closed Bug 1797170 Opened 3 years ago Closed 3 years ago

Firefox opens new windows on other displays at the wrong DPI

Categories

(Core :: Widget: Win32, defect, P3)

Firefox 106
x86_64
Windows
defect

Tracking

()

VERIFIED FIXED
108 Branch
Tracking Status
firefox-esr102 --- unaffected
firefox106 --- wontfix
firefox107 --- wontfix
firefox108 --- verified

People

(Reporter: no.ka.oii, Assigned: hiro)

References

(Regression)

Details

(Keywords: regression, Whiteboard: [win:sizing])

Attachments

(3 files, 1 obsolete file)

Attached video Untitled Project.mp4

Steps to reproduce:

Two monitors hooked to my laptop. Both monitors are 1080p. Laptop is 4k.
Firefox is open full screen on 1080p monitor B.
On certain websites, clicking a link that spawns a new window places the new window on the laptop screen and not monitor B.

Prior to v104 (around there) Firefox would render the pop-up window as if it were opened on a 1080p monitor and not the 4k one. So you simply had to move the window if you wanted.

Actual results:

Now, the pop-up opens on the 4k main laptop screen with the DPI or resolution messed up and the entire contents of the pop-up are very small and not rendered within the full viewport of the pop-up. When this window with smaller content is dragged to the 1080p monitor it grows to the correct size of the viewport and stays that way no matter which screen it is then moved to after.

Expected results:

The pop-up should open on the same screen as the main Firefox window, however if it doesn't it should not render the contents of the pop-up incorrectly according to the resolution/DPI of the other monitor.

Component: Untriaged → Widget: Win32
OS: Unspecified → Windows 11
Product: Firefox → Core
Hardware: Unspecified → x86_64
Summary: new window resolution → Firefox opens new windows on the incorrect display at the wrong DPI
Attached file bug-1797170-testcase.html (obsolete) —

Thanks! I can reproduce this on a current Nightly, and have attached a local test case.

The pop-up should open on the same screen as the main Firefox window

This is worth opening a separate bug for already filed as bug 1266206. We may not be able to fix it for backwards-compatibility reasons, but it's probably worth looking into.

(Reduced margin in test case to prevent scrollbars from being applied a little too eagerly under some setups.)

Attachment #9300400 - Attachment is obsolete: true
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows 11 → Windows
Severity: -- → S3
Priority: -- → P3
Whiteboard: [win:sizing]
Regressed by: 1757410
Summary: Firefox opens new windows on the incorrect display at the wrong DPI → Firefox opens new windows on other displays at the wrong DPI

Set release status flags based on info from the regressing bug 1757410

:hiro, since you are the author of the regressor, bug 1757410, could you take a look?

For more information, please visit auto_nag documentation.

Flags: needinfo?(hikezoe.birchill)
Keywords: regression

(In reply to Ray Kraesig [:rkraesig] from comment #1)

This is worth opening a separate bug for already filed as bug 1266206. We may not be able to fix it for backwards-compatibility reasons, but it's probably worth looking into.

Interesting. Bug 1266206 was originally opened for Linux, but with the test case in comment 2 (Thanks Ray for the test case!), the popup window is opened in the same monitor at least on Wayland. I will have to set up Windows.

I am still struggling with finding out the place where we position newly created popup windows. What I've found so far is on Windows (11) we get two WM_DPICHANGED notifications, the first one is for the monitor where the original firefox window is positioned, the second one is for the monitor where the popup window will be appeared. Thus I am suspecting we (or Windows) tries to position the new window on the same monitor initially and move it to the other monitor. Of course there's definitely a flaw about DPI change notification in our code the second DPI change notification is ignored somewhere, the reason I am guessing is we consider the DPI isn't changed since the initial DPI value for the popup window is the monitor where the popup window appears.

(In reply to Hiroyuki Ikezoe (:hiro) from comment #5)

Of course there's definitely a flaw about DPI change notification in our code the second DPI change notification is ignored somewhere, the reason I am guessing is we consider the DPI isn't changed since the initial DPI value for the popup window is the monitor where the popup window appears.

This flaw might be inevitable since our DPI change notification is async.

I found the place where the problem is. The problem is here in ContentChild::ProvideWindowCommon. The code in question is;

    ParentShowInfo showInfo(                                                    
        u""_ns, /* fakeShowInfo = */ true, /* isTransparent = */ false,         
        aTabOpener->WebWidget()->GetDPI(),                                      
        aTabOpener->WebWidget()->RoundsWidgetCoordinatesTo(),                   
        aTabOpener->WebWidget()->GetDefaultScale().scale);

This aTabOpener->WebWidget() isn't the widget for the popup-ed content, it's rather for the original window. Thus the GetDPI() returns a wrong value. It will end up being used for DoFakeShow call in the same function and it will be propagated into the pres shell for the popup-ed content. And before bug 1757410, we did call UIResolutionChanged which is an async version of UIResolutionChangedSync which is now we use, thus the wrong DPI value had been clobbered by the async UIResolutionChanged call.

Note about the issue that newly popup window isn't opened in the same monitor where the original firefox window is positioned. TIL there's a spec text explaining where window.open-ed window should be positioned. In terms of the spec, the current Firefox behavior is correct. It's not an issue at all.

Flags: needinfo?(hikezoe.birchill)

Is the above also expected to fix bug 1550421?

Flags: needinfo?(hikezoe.birchill)

If I understand bug 1550421 correctly, the answer is yes. I confirmed D160875 fixes bug 1550421 on my macbook with an external monitor by using the Ray's test case in comment 2.

Flags: needinfo?(hikezoe.birchill)
Duplicate of this bug: 1550421
Assignee: nobody → hikezoe.birchill
Attachment #9301267 - Attachment description: WIP: Bug 1797170 - Use the proper widget to obtain per-monitor metrics (e.g. DPI) for doing a fake show. → Bug 1797170 - Use the proper widget to obtain per-monitor metrics (e.g. DPI) for doing a fake show. r?emilio
Status: NEW → ASSIGNED
Pushed by hikezoe.birchill@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1e74216b2cc9 Use the proper widget to obtain per-monitor metrics (e.g. DPI) for doing a fake show. r=emilio
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 108 Branch

I was able to reproduce this issue using the attached test case and Confirmed the Fix. This issue is Verified as fixed in our latest Nightly build 108.0a1 (2022-11-07).

Updating the Status flags for this issue.

Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: