Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: setBounds make BrowserWindows larger every time on Windows #27651

Open
3 tasks done
Fndroid opened this issue Feb 8, 2021 · 23 comments
Open
3 tasks done

[Bug]: setBounds make BrowserWindows larger every time on Windows #27651

Fndroid opened this issue Feb 8, 2021 · 23 comments
Labels
21-x-y 22-x-y bug 🪲 component/BrowserWindow has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/windows status/confirmed A maintainer reproduced the bug or agreed with the feature
Projects

Comments

@Fndroid
Copy link

Fndroid commented Feb 8, 2021

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 an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    • 11.2.3
  • Operating System:
    • Windows 10 20H2
  • Last Known Working Electron version:
    • unknow

Expected Behavior

setBounds to output of getBounds makes no effect to BrowserWindows size

Actual Behavior

setBounds to output of getBounds makes BrowserWindows size larger every time setBounds called

To Reproduce

main.js

const { app, BrowserWindow } = require('electron')

function createWindow () {
  const win = new BrowserWindow({
    width: 801,
    height: 601,
    webPreferences: {
      nodeIntegration: true
    }
  })

  win.loadFile('index.html')

  let bounds = null

  win.on('minimize', () => {
    bounds = win.getBounds()
  })

  win.on('restore', () => {
    win.setBounds(bounds)
    console.log(win.getBounds())
  })
}

app.whenReady().then(createWindow)

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

app.on('activate', () => {
  if (BrowserWindow.getAllWindows().length === 0) {
    createWindow()
  }
})

index.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Hello World!</title>
    <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
</head>
<body style="background: white;">
    <h1>Hello World!</h1>
    <p>
        We are using node <script>document.write(process.versions.node)</script>,
        Chrome <script>document.write(process.versions.chrome)</script>,
        and Electron <script>document.write(process.versions.electron)</script>.
    </p>
</body>
</html>

Screenshots

image

Additional Information

@pushkin-
Copy link

pushkin- commented Feb 8, 2021

Do you have a multi-monitor setup with different DPI settings? Kind of a related issue here with non-resizable windows.

@ckerr
Copy link
Member

ckerr commented Feb 8, 2021

@ckerr ckerr added 11-x-y bug 🪲 component/BrowserWindow platform/windows has-repro-gist Issue can be reproduced with code at https://gist.github.com/ labels Feb 8, 2021
@ckerr
Copy link
Member

ckerr commented Feb 8, 2021

Might be an issue requiring a specific setup, e.g. Windows-only.

I'm not able to reproduce this on Ubuntu 20.10 with reported version. Tested by running the gist in Fiddle with Electron v11.2.3 and repeatedly minimizing / restoring the application's window. As per @pushkin's suggestion about multimonitor being a factor, I tried minimizing / restoring from both monitors on a multimonitor setup.

Output looked like this:

$ electron .
(node:1496992) electron: The default of contextIsolation is deprecated and will be changing from false to true in a future release of Electron.  See https://github.com/electron/electron/issues/23506 for more information
{ x: 559, y: 576, width: 801, height: 601 }
{ x: 559, y: 576, width: 801, height: 601 }
{ x: 559, y: 576, width: 801, height: 601 }
{ x: 2248, y: 583, width: 801, height: 601 }
{ x: 2248, y: 583, width: 801, height: 601 }
{ x: 2248, y: 583, width: 801, height: 601 }
Done in 25.31s.

The change in x, y between lines 3 and 4 is from me dragging the window to the second monitor.

@ckerr ckerr added the status/reviewed A maintainer made an initial review but not reproduced the issue label Feb 8, 2021
@pushkin-
Copy link

pushkin- commented Feb 8, 2021

I can repro this exactly on Windows 10, 2 monitors, and different DPI settings (the latter bit was key). The primary monitor is set to 125% and the second to 100%. Seems very much related to the linked issue.

@Fndroid
Copy link
Author

Fndroid commented Feb 9, 2021

It seems that this issue is related to the zoom factor of the system.

I tried 125%, 150%, 175%, 200% and 225% on a 3840x2160 monitor and all even numbers are fine but odd numbers are not.

Besides, macOS do not have this issue whild testing.

I think it might be a lead to locate the glitch.

@deepak1556 deepak1556 added this to Unsorted Issues in 12-x-y Feb 10, 2021
@sofianguy sofianguy moved this from Unsorted Issues to Does Not Block Stable in 12-x-y Feb 11, 2021
@alectrocute
Copy link

alectrocute commented Feb 11, 2021

+1. Can confirm it’s related to mis-matched display zoom settings on >1 monitor setups with Windows 10.

@Fndroid’s explanation is the best I’ve seen so far! Does indeed look related to odd zoom numbers.

@reznikartem
Copy link

Having same issue on Windows 10, 11.2.2

Have 2 displays with 3840x2160 resolultion, both on 175% dpi.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2022

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Oct 6, 2022
@pushkin-
Copy link

pushkin- commented Oct 6, 2022

repros in Electron 21

@github-actions github-actions bot removed the stale label Oct 7, 2022
@liuyike98
Copy link

It seems that this issue is related to the zoom factor of the

same to you, any solution?

@deepak1556 deepak1556 removed their assignment Oct 10, 2022
@skandaswamygit
Copy link

I have the same problem when scaling a window across all displays of varying scale factor. I am presently sticking to an implementation that works only on monitors with same scale factor. It's not ideal. A solution for this is greatly appreciated.

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Jan 19, 2023
@mikekreeki
Copy link

Still an issue.

@github-actions github-actions bot removed the stale label Jan 20, 2023
@dsanders11 dsanders11 changed the title setBounds make BrowserWindows larger every time on Windows [Bug]: setBounds make BrowserWindows larger every time on Windows Feb 6, 2023
@eltonchan
Copy link

repros in Electron 20

@vavdav
Copy link

vavdav commented Mar 24, 2023

I had the same issue, it made infinite loop and frozen the app

@FE-Acmen
Copy link

FE-Acmen commented Jun 7, 2023

OK,I also had this problem

@electron-issue-triage
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@pushkin-
Copy link

pushkin- commented Sep 6, 2023

bump

@dsanders11 dsanders11 added status/confirmed A maintainer reproduced the bug or agreed with the feature and removed status/reviewed A maintainer made an initial review but not reproduced the issue labels Sep 11, 2023
@fanchenio
Copy link

Bump.

@davidtheweb-dev
Copy link

bump

@oalfroukh
Copy link

Hi Electron Team,
Any update for this old issue?

Thanks in advance!

@c-o-c-o
Copy link

c-o-c-o commented Mar 1, 2024

There is still an issue.

@courtsimas
Copy link

Yep still an issue in electron 30.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
21-x-y 22-x-y bug 🪲 component/BrowserWindow has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/windows status/confirmed A maintainer reproduced the bug or agreed with the feature
Projects
No open projects
12-x-y
Does Not Block Stable
Development

No branches or pull requests