Repository navigation
Description
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Electron Version
42.1.0
What operating system(s) are you using?
Windows
Operating System Version
Windows 11 (verified on 10.0.22631 and 10.0.26200)
What arch are you using?
x64
Last Known Working Electron version
41.2.0
Does the issue also appear in Chromium / Google Chrome?
I don't know how to test
Expected Behavior
For BrowserWindow({ frame: false, thickFrame: true, resizable: true }) on Windows, the on-screen HWND rect (read via user32!GetWindowRect) equals screen.dipToScreenRect(win.getBounds()). setBounds({ x, y, width: W, height: H }) produces a visible window of W × H DIP at (x, y). This held through Electron 41.3.0.
Actual Behavior
Starting in 41.3.0 (backport of #50706 via #50863) and 42.0.0 (via #50864), the HWND extends outward from getBounds() by SM_CXSIZEFRAME + SM_CXPADDEDBORDER DIP on left, right, and bottom, and by 0 on top. setBounds({ x, y, width: W, height: H }) produces a visible window of (W + 16) × (H + 8) DIP at (x - 8, y) at 100% DPI (scales with DPI). getBounds(), getNormalBounds(), and getContentBounds() continue to return the original logical (inset-subtracted) rect, so the getBounds() ↔ HWND identity is broken on this window class. No constructor option, runtime flag, or JS API to query the inset or restore pre-41.3 behavior.
Testcase Gist URL
Additional Information
How the break looks in numbers
Same BrowserWindow options, same display, measured locally with the repro at the bottom of this issue:
| Observation | Electron 41.2.0 (last working) | Electron 41.3.0 / 42.1.0 (same input) | Delta |
|---|---|---|---|
asymmetricInsetPhysical @ 100% DPI |
{0, 0, 0, 0} |
{left:8, top:0, right:8, bottom:8} |
new inset |
asymmetricInsetPhysical @ 137.5% DPI |
{0, 0, 0, 0} |
{left:12, top:0, right:12, bottom:11} |
new inset (scales with DPI) |
Visible window width for setBounds(w:500) |
500 DIP | 516 DIP | +16 DIP |
Visible window height for setBounds(h:400) |
400 DIP | 408 DIP | +8 DIP |
getBounds() vs HWND rect |
identical | HWND = bounds outset by TLBR(0, T, T, T) |
identity broken |
Center of getBounds() vs HWND center on Y |
identical | logical center is T/2 above HWND center |
−4 DIP |
setBounds(display.workArea) fills workArea |
yes | overflows workArea by T DIP on L / R / B |
window leaves work area |
Source of the change
Introduced by #50706 "fix: external resize hit targets for frameless windows on Windows" (shipped as #50864), with follow-up regression fix in #51252 / #51296. The relevant code in shell/browser/ui/views/[email protected]:
gfx::Insets WinFrameView::RestoredFrameBorderInsets() const {
if (window_->has_frame() || !window_->has_thick_frame() ||
!window_->IsResizable())
return {};
const int thickness =
display::win::GetScreenWin()->GetSystemMetricsInDIP(SM_CXSIZEFRAME) +
display::win::GetScreenWin()->GetSystemMetricsInDIP(SM_CXPADDEDBORDER);
return gfx::Insets::TLBR(0, thickness, thickness, thickness);
}Related
- #40505 — original Win11 frameless-resize bug
- #50706 — the fix on
main - #50863 — backport to
41-x-y(shipped in41.3.0) - #50864 — backport to
42-x-y(shipped in42.0.0) - #51244 — regression introduced by fix: external resize hit targets for frameless windows on Windows #50706
- #51252 — regression fix on
main - #51296 — regression-fix backport
- #51287 —
fix: remove insets on fullscreen windows on Windows(related follow-up)
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fields👍 Does Not Block Stable
Activity
nikwen commentedon May 18, 2026
Thanks for reporting!
As far as I understand, that change was intentional. I'm not sure we ever guaranteed
getBounds() ↔ HWNDidentity.@mitchchn knows this part of the code better. Maybe he has some ideas on how to get the outer bounds.
What do you need the outer bounds for?
gdavidkov commentedon May 19, 2026
Thanks @nikwen!
To your second question first — I don't strictly need outer bounds; what I need is for
setBounds(R)andgetBounds()to refer to the same rectangle the user actually sees. Exposing the inset is one possible fix, but restoring the round-trip (or makingsetBoundsoutset-aware) would work equally well. The concrete things that break under the new behaviour, all on aframe:false, thickFrame:true, resizable:truewindow:setBounds(display.workArea)no longer fills the work area — it overflows by the inset on L/R/B (16×8 DIP at 100% DPI, more at higher DPI). Any custom "maximize into work area" implementation is now wrong by that amount.setBounds, because the visible window extends past the rect you passed in.child.x = parent.x + parent.widthnow leaves a gap on one side and overlaps on the other (asymmetric inset: 0 on top,Ton L/R/B).getBounds()→ save →setBounds()on next launch) is no longer a fixed point: each restart shifts the window outward by the inset.getBounds()are now off by the inset with no API to bridge the two.On "I'm not sure we ever guaranteed
getBounds() ↔ HWNDidentity" — fair that it may not have been a formal contract, but it held for the entire history of the API until 41.3, and thesetBounds/getBoundsdocs describe them as the window's bounds, not a logical rectangle that diverges from what's on screen. If this is intentional, it's a breaking change for frameless apps that do their own window management, and at minimum I'd expect a note in the breaking-changes doc and some API to query the inset — right now it has to be reverse-engineered fromSM_CXSIZEFRAME + SM_CXPADDEDBORDERper-monitor DPI, which apps shouldn't have to do.Happy to test any fix on
41-x-y/42-x-y/main.nikwen commentedon May 19, 2026
setBounds(R)andgetBounds()to refer to the same rectangle the user actually sees": It seems to me like the x coordinate is 5 pixels off in my testing. Gist: https://gist.github.com/1926b6534e90feb4a0cfd947c5da3a9bmitchchn commentedon May 19, 2026
Thanks @gdavidkov.
Agreed. This is something we can work toward if it's not currently the case. What would help the most are gists demonstrating the edge cases and your expectations.
Let me address some of your other feedback:
Introducing insets can have one of two consequences. Either: 1) window bounds suddenly change, since they now include insets or 2) window bounds stay the same as before, but are computed from a different rectangle.
We opted for 2) to best preserve expectations for most people, especially since Electron's main use case is cross-platform apps.
A developer who creates an 800x600 frameless window would not expect the window to be smaller or located in a different position in Electron 41.3 compared to 41.2.
Perhaps more importantly, developers would not expect their frameless window to be smaller on Windows than it is on Mac. There is no reasonable way to manage the difference between platforms if window bounds include insets.
Bugs aside (which I agree with you we must fix), there are several alternatives: if you do not want insets at all, you can set
thickFrame: falseas before. This was already the best configuration for any app that needs to fill the work area in custom way or to have a level of precision that doesn't depend on OS decorations.And if you still need access to the HWND specifically, you can get it with
win.getNativeWindowHandle()and run whatever Windows-specific logic you need.estoykov commentedon May 19, 2026
If we have "frame: false" and thickFrame: false", then we'll lose rounded corners and drop shadows - the things that our clients dream about - don't know why, but hey do.
The previous approach - to have sizing areas inside the client area was an acceptable compromise in this case - sizing and the lovely rounded corners and drop shadows as I said.
And this could be an option - either inner sizing areas or "behind the scene" insets with outer sizing.
And talking about HWND, it will be nice to have a separate (Windows only) methods, like: setScreenBounds()/getScreenBounds().
In fact your screenToDipRect and dipToScreenRect (again Windows only) work pretty well. So in rich desktop applications, they can be used with these two new methods to achieve correct window placement as much as possible. Now we're forced to use a dirty tricks with native modules to achieve this.
This doesn't compensate an ability to choose between inner or outer sizing areas though.
(screenToDipRect and dipToScreenRect don't work well when target BrowserWindow is given, but the rectangle is in a another display with different scaling - this is another story).
About expected bounds:
bounds: { x: 568, y: 316, width: 800, height: 600 }
content bounds: { x: 567, y: 316, width: 802, height: 602 }
Cheers!
(This is not AI generated)
Edit: About multi-platform
Electron is a multi-platform for a window based rich desktop applications - it really is, thank you for that! :)
But we can't (or we shouldn't imho) to treat all platforms that Electron supports equally, because they simply are not.
Electron code is already polymorphic with different implementations (and methods as I said above) for the different platforms. So keeping it "pure" multi-platform, at least in window management, could introduce annoying/unwanted behavior for the developers. Instead to give what underlying OS provides in order to write the code that is close to it.
nikwen commentedon May 19, 2026
@mitchchn You messaged me on Slack that you can't repro the offset that I'm seeing.
Here's a screenshot using the gist from above:
If I draw a rectangle around the window, the top left corner is at
(395, 400). The bottom right corner is at(1205, 1205).These are my display settings:
The CLI output of the gist is as expected:
yuzw1007 commentedon May 20, 2026
这个应该都是那个边框改动造成的,跟我之前反馈的那个问题应该是同一个原因引起的,我反馈的那个问题最后一个正常工作版本:41.2.0,之后的版本都有这个边框问题。#51540
mitchchn commentedon May 20, 2026
Thanks for the gist and screenshot @nikwen. When I run your gist at 100% scale, I get the same exact results as as in earlier versions of Electron (41.0). The error starts to accumulate at higher display scales. Is this something you can also confirm? If so, the issue here is likely not the bounds rect, but rounding errors between screen and DIP.
@estoykov thank you as well for the followup. I agree with everything you say and I'm certainly not opposed to platform-specific APIs, as long as the basic ones work in a predictable way for non-experts. (That is, I hope developers don't need APIs to work around DPI/scaling/multi-monitor bugs: we needs to fix those in the framework.)
nikwen commentedon May 21, 2026
@mitchchn I don't know how to test it to be honest. I'm running on a Parallels VM, which seems to default back to 200% even if I change it.
It seems like a different issue than the original report about the HWND size though, so I've created a separate bug report for it here: #51730
@mitchchn Should we replace this issue (#51679) with a feature request to expose the window insets?
savely-krasovsky commentedon May 26, 2026
We also use
frameless: trueandthickFrame: true+menubar. Window started to shrink every time between hide and show:Scale is 100%, 3440x1440.
davidfrogley-appgate commentedon Jun 26, 2026
Hitting what looks like the same regression after upgrading from Electron 41.1 to 42.4, but with a slightly different config than the one in the title. Posting in case the additional data points help narrow the cause.
Our config (Windows 11):
frame: falsetitleBarStyle: 'hidden'resizable: false← nottrueas in the original reportthickFramesetting (Electron default)width: 375, height: 667What we observed at 100% DPI:
new BrowserWindow({ width: 375, height: 667, resizable: false, ... }): bothgetSize()andgetContentSize()returned327 × 643.mainWindow.setSize(375, 667):getSize()andgetContentSize()both returned359 × 659.The relevance: the symptom in the title is frameless + thickFrame + resizable: true → HWND grows by 16×8. We're seeing frameless + resizable: false → renderer shrinks by 16×8. Same magnitude, same Electron versions, looks like the same
RestoredFrameBorderInsets()accounting, applied to a different config path.On DPI scaling: the original report says the inset scales with DPI (12/11 at 137.5%). We tested our workaround at 100%, 125%, and 150% on Windows 11 and the rendered layout was identical at every scaling level — i.e. for the
resizable: falsecode path the delta appears to be a constant[16, 8]DIP regardless of DPI, not DPI-scaled. Possibly worth checking whether the two code paths (resizable true vs. false) hit different inset accounting.Workaround we shipped (for anyone else landing here):
Verified across 100%/125%/150% DPI on Windows 11.
SpoilerJones commentedon Aug 14, 2026
I came very close to submitting my own bug report but noticed this one at the last second thanks to the potential-duplicates detector.
Here's the gist I made. I used that code in Electron Fiddle to confirm that 43.4.0 is still affected, and to nail down the exact version that introduced the issue.
41.2.1 (2026-04-16) is the first release containing #50863. (I see @mitchchn is already on board here, so sorry if this is overexplaining...)
I'd also point out that the "outer" geometry that JS code on the page sees (
window.outerWidth/outerHeight/screenLeft/screenTop) is also in disagreement withgetBounds. This is biting my app where we have a fair number of pages shown in floating windows whose JS reads their bounds to save it to the DB (behind the web server) and restore those bounds on next launch. I have a workaround, but it's pretty sweaty and I'd love to get rid of it.Nantris commentedon Oct 6, 2026
Any update on this? This is a big headache and a bummer to be dealing with and it requires lots of bandaids in JS to mitigate.
mini player: no system frame on Windows, and sing-along lyrics