You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Windows 10 Browser Window Bounds Calculating Incorrectly #4045
The Browser Window width and x coordinates are being calculated incorrectly in Windows 10 (Windows 8.1 did not have this problem). Here you can see that the getBounds() function is showing that my x value is 0 but the desktop background is showing through. I'm guessing this may have something to do with a subtle shadow that each window in Windows 10 is now casting.
Not sure how to fix this, but would be nice to resolve as I have some window state management code written to pin windows in the correct location, and now they are not properly being positioned.
Reacted by Marek Lewandowski, Alex, Alex Kondratiuk, Brian, Daniel Nguyen, Christopher X Gerber, Rani, bohdanzhylavskyi and Peter Bridgman
Here is one more screenshot. In this screenshot the window should be positioned in the bottom left of the screen - you can see there is padding on the left, bottom, and right. Interestingly, the y value seems to be working correctly, so if you set y to zero it will appropriately put the window right at the top of the screen.
Windows 10 has a thinner frame than before, and in order to be compatible with existing apps it is returning wrong values in its win32 APIs. You can reproduce the same problem in Chrome browser:
Managed to reproduce this issue with both vs code and Discord on a 1920x1080 display. Based on my testing the window is exactly 10px to wide/tall. I am currently running Windows 10 18362.
I would be happy to help with testing and/or collecting more data if someone can tell me what information is required.
It's possible based on my investigation that BrowserWindow.getBounds() in Windows 10 should be returning the equivalent of window.innerHeight and window.innerWidth but isn't.
At the top of my devtools console, you can see the output of BrowserWindow.getBounds(), followed by dimensions from the browser's window object.
In my case, I'm setting the dimensions on a BrowserView to fit its parent BrowserWindow. When I set the dimensions on my BrowserView as follows, things seem to fit perfectly on Windows 10, and in Windows 7 (both basic and classic themes):
In my case I'm opening new child window alongside the right border of the parent window to fill the empty screen space. Right now my code looks like this. Looks hacky but works okay (Electron v9.1.0). Hope it helps:
"Thank you for taking the time to report this issue and helping to make Electron better! Your help is appreciated."
Ignore the bug report for 4 years -- TEN major releases -- and then close it due to it being reported against an unsupported version. "Brilliant" way to manage issue lists getting long.
I disabled my apps' features of remembering window size and position, as a temporary workaround to this problem. (Not really a workaround.) For a while I tested this problem on every major update, and was one of the people who confirmed it was still present, for a while, delaying that feature while I hoped an update might include a fix. I stopped retesting it after many major releases did not include any fix, or any sign of interest by Electron folks. Apparently, for those updates where I did retest it, I was wasting my time.
This is very discouraging, if not infuriating. And unfortunately this kind of policy will only damage code quality, especially as developers such as myself, see this as a clear reason to halt efforts to try to narrow down Electron bugs, to take the time to reproduce the problems and file bug reports against Electron, and instead begin the process of finding and migrating to different solutions to cross-platform development needs.
Reacted by Alex Kondratiuk, Dorian Boulc'h, Andy, Joseph A. Boyle and Simon Appelt
Activity
kirkouimet commentedon Jan 10, 2016
Here is one more screenshot. In this screenshot the window should be positioned in the bottom left of the screen - you can see there is padding on the left, bottom, and right. Interestingly, the
yvalue seems to be working correctly, so if you setyto zero it will appropriately put the window right at the top of the screen.kirkouimet commentedon Jan 10, 2016
And lastly, here is my code (specific to my window state management class) which addresses the issue until an official fix comes out:
zcbenz commentedon Jan 11, 2016
Windows 10 has a thinner frame than before, and in order to be compatible with existing apps it is returning wrong values in its win32 APIs. You can reproduce the same problem in Chrome browser:
I have reported the problem to upstream: https://crbug.com/576192.
lukeapage commentedon Jul 5, 2016
@zcbenz @kirkouimet I see the linked bug in chrome is closed as cannot reproduce - is this bug fixed or do you still have the problem?
intsrc commentedon Jul 6, 2016
the problem is still here!
kirkouimet commentedon Jul 6, 2016
Yeah someone is going to have to go and reopen that Chromium ticket and follow it through to the end
anaisbetts commentedon Feb 14, 2017
Would setting a new key in our App manifest opt us out of this?
zcbenz commentedon Feb 14, 2017
I hope so, but I can't find any documentation on it, even this behavior is not documented anywhere.
anaisbetts commentedon Feb 14, 2017
Alright, I sent an Email to the relevant Microsoft MVP mailing list, we'll see if anyone has any ideas
bsclifton commentedon Apr 26, 2017
Was this fixed with #9167 ?
kevinsawicki commentedon Apr 26, 2017
Perhaps, @kirkouimet could you confirm this as fixed in 1.6.7+?
kirkouimet commentedon Oct 31, 2017
@kevinsawicki and @bsclifton this is still an issue as of Electron 1.8.2 on Windows 10 updated October 2017
15 remaining items
appurist commentedon Dec 13, 2019
This is still a problem in Electron 6.1.5. It's going to be a major problem for my app.
I can fix (only) the left position by using a negative number, but it seems the width and height always fall short even if I set them larger.
pushkin- commentedon Mar 5, 2020
Can repro with Electron 8
Stanzilla commentedon Mar 7, 2020
@zcbenz @MarshallOfSound this is affecting high profile apps like Discord, any chance someone could look into it?
Ansraer commentedon Jun 4, 2020
Managed to reproduce this issue with both vs code and Discord on a 1920x1080 display. Based on my testing the window is exactly 10px to wide/tall. I am currently running Windows 10 18362.
I would be happy to help with testing and/or collecting more data if someone can tell me what information is required.
gerbus commentedon Jun 19, 2020
Still happening with Electron 8.2.2.
It's possible based on my investigation that
BrowserWindow.getBounds()in Windows 10 should be returning the equivalent ofwindow.innerHeightandwindow.innerWidthbut isn't.At the top of my devtools console, you can see the output of
BrowserWindow.getBounds(), followed by dimensions from the browser'swindowobject.In my case, I'm setting the dimensions on a BrowserView to fit its parent BrowserWindow. When I set the dimensions on my BrowserView as follows, things seem to fit perfectly on Windows 10, and in Windows 7 (both basic and classic themes):
nbanerje commentedon Aug 14, 2020
Is there an update on when this might be addressed or what the best workaround is?
lynxtaa commentedon Aug 18, 2020
In my case I'm opening new child window alongside the right border of the parent window to fill the empty screen space. Right now my code looks like this. Looks hacky but works okay (Electron v9.1.0). Hope it helps:
electron-triage commentedon Mar 9, 2021
The Electron version reported on this issue is no longer supported. See our supported versions documentation.
If this is still reproducible on a supported version, please open a new issue with any other new information that a maintainer should know.
Thank you for taking the time to report this issue and helping to make Electron better! Your help is appreciated.
Stanzilla commentedon Mar 9, 2021
Well that's an annoying bot. Could at least ask if it is still an issue and then update the label.
appurist commentedon Mar 9, 2021
Ignore the bug report for 4 years -- TEN major releases -- and then close it due to it being reported against an unsupported version. "Brilliant" way to manage issue lists getting long.
I disabled my apps' features of remembering window size and position, as a temporary workaround to this problem. (Not really a workaround.) For a while I tested this problem on every major update, and was one of the people who confirmed it was still present, for a while, delaying that feature while I hoped an update might include a fix. I stopped retesting it after many major releases did not include any fix, or any sign of interest by Electron folks. Apparently, for those updates where I did retest it, I was wasting my time.
This is very discouraging, if not infuriating. And unfortunately this kind of policy will only damage code quality, especially as developers such as myself, see this as a clear reason to halt efforts to try to narrow down Electron bugs, to take the time to reproduce the problems and file bug reports against Electron, and instead begin the process of finding and migrating to different solutions to cross-platform development needs.
junguksim commentedon Sep 29, 2022
Is this issue fixed? Still repro in 11.2.1
ricardomomm commentedon Apr 4, 2024
Still happening on Windows 11
ThaUnknown commentedon Jan 4, 2025