Open Bug 1682136 Opened 5 years ago Updated 2 years ago

Window position not restored correctly on start (moved by 8px) when Session Restore is disabled

Categories

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

Firefox 83
x86_64
Windows 10
defect

Tracking

()

REOPENED

People

(Reporter: the.recliner, Assigned: emk)

References

Details

Attachments

(1 file, 1 obsolete file)

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

Steps to reproduce:

  1. Open Firefox (new installation, fresh profile).
  2. Change the window size/position (without maximizing) and place the window at the leftmost of the screen (x=0).
  3. Close Firefox (File > Quit, or the window's "X" button).
  4. Open Firefox again (same profile).

Actual results:

The window is shifted by 8px to the right exactly. The width/height of the window are preserved, it only gets moved to the right.

The data in "xulstorage.json" when the window is closed at the leftmost:
[...]
"screenX": "-8",
"screenY": "0",
[...]

Once you re-open and close Firefox without moving it (after it was shifted on start):
[...]
"screenX": "0",
"screenY": "0",
[...]

The measured distance is effectively 8px as shown in the attached screenshots.

Expected results:

The window should have been restored exactly where it was before closing.

If I close Firefox and the window is on the rightmost of the screen Firefox shifts its window to the left by 8px exactly too.

If I manually set the window to the whole width of the screen (not with the maximize button), the window is shifted 8px to the right with a part of the window out of the bound of the screen.

If the window is not on the leftmost or rightmost, the position is restored correctly/precisely.

If the window is maximized, it is restored correctly (in its maximized state).

I have checked this behavior with other applications (Chrome, Discord, Microsoft Outlook/Word/Excel) and they all restore their size/position correctly, no shifting.

I have tried deleting xulstorage.json but the issue is still present, and it also happen on a fresh install/profile of Firefox (and Windows).

Tested on Firefox version: 83.0, Fresh Install and Profile
OS: Windows 10 20H2 (19042.685), Fresh Install, Default Display/Window Settings (Also tested on Windows Server 2016, same behavior).

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → Widget: Win32
Product: Firefox → Core
Component: Widget: Win32 → Window Management
OS: Unspecified → Windows 10
Hardware: Unspecified → x86_64

I can confirm this with Firefox 87 in Windows 10.

The Window position and state is usually never restored correctly.

Looks like this is intentional:
https://searchfox.org/mozilla-central/rev/1758450798ae14492ba28b695f48143840ad6c5b/browser/components/sessionstore/SessionStore.jsm#4849-4863

"screenX": "-8",

This is because non-maximized window has a transparent border around the visible border on Windows 10.

Regressed by: 1276516

Bug 1276516 is not a regressor, rather it should have fixed this.

No longer regressed by: 1276516

I could not reproduce the bug...

This bug depends on the session restore setting (App menu > Options > General > Startup > Restore previous session).

If the session restore is enabled, the window will show at the wrong (shifted) position at first, then it will move to the correct (slightly off-screen) position. If the session restore is disabled, the window will stay at the wrong position.

I think ConstrainPosition will set the wrong initial position because the aAllowSlop argument is false:
https://searchfox.org/mozilla-central/rev/6c9ff2820d3aae683ec87c53c79e5108d54f3f76/xpfe/appshell/AppWindow.cpp#1307

Assignee: nobody → VYV03354
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Pushed by VYV03354@nifty.ne.jp: https://hg.mozilla.org/integration/autoland/rev/49744f943e16 Allow slop when the window position is persistent and it has no parent. r=xpcom-reviewers,nika
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 89 Branch
Depends on: 1705504
No longer regressions: 1705504

Backed out for putting browser window partially behind left and top taskbars on older Windows versions (bug 1705504)

backout: https://hg.mozilla.org/integration/autoland/rev/09908d752facc9c5ec5ddcc2e6fa33895a30070f

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

This got fixed by 1753836 - at least on my end. Please reopen the bug or comment if you can still reproduce the issue in the latest Nightly.

Status: REOPENED → RESOLVED
Closed: 4 years ago3 years ago
Resolution: --- → DUPLICATE

I can still reproduce this bug. Please make sure that Session Restore is disabled (as I wrote in comment #6).
Updating the title to clarify.

Status: RESOLVED → REOPENED
Flags: needinfo?(VYV03354)
Resolution: DUPLICATE → ---
Summary: Window position not restored correctly on start (moved by 8px) → Window position not restored correctly on start (moved by 8px) when Session Restore is disabled

There's a r+ patch which didn't land and no activity in this bug for 2 weeks.
:emk, 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 auto_nag documentation.

Flags: needinfo?(nika)
Flags: needinfo?(VYV03354)
Attachment #9211460 - Attachment is obsolete: true
Flags: needinfo?(nika)
Flags: needinfo?(VYV03354)

Sorry, there was a problem with the detection of inactive users. I'm reverting the change.

Assignee: nobody → VYV03354
Severity: -- → S3
Component: Window Management → Widget: Win32
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: