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]: tray.getBounds() initially returns the incorrect x and y values on macOS #35984

Open
3 tasks done
davej opened this issue Oct 11, 2022 · 8 comments
Open
3 tasks done
Labels
bug 🪲 component/tray has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/macOS status/confirmed A maintainer reproduced the bug or agreed with the feature

Comments

@davej
Copy link
Contributor

davej commented Oct 11, 2022

Preflight Checklist

Electron Version

21.1.0

What operating system are you using?

macOS

Operating System Version

12.6 (Monterey)

What arch are you using?

arm64 (including Apple Silicon)

Last Known Working Electron version

No response

Expected Behavior

tray.getBounds() should return current bounds when called shortly after the initialisation of the Tray. If this is not possible then the tray instance should emit a ready event so that we know when getBounds() will return the correct bounds.

Actual Behavior

tray.getBounds() returns an incorrect value until some arbitrary time has passed. In my testcase it takes approx 500ms for the correct value to be returned.

Testcase Gist URL

https://gist.github.com/davej/be1503e76acb237fc2ef513445d80b70

Additional Information

Output of my test case above. Only setTimeout:500 is correct.

Electron v21.1.0 started.
sync { x: 0, y: 956, width: 16, height: 36 }
setImmediate { x: 0, y: 956, width: 16, height: 36 }
setTimeout:50 { x: 0, y: 956, width: 16, height: 36 }
setTimeout:500 { x: 931, y: 0, width: 16, height: 36 }

This is probably the same bug as reported in #33515.

@davej davej added the bug 🪲 label Oct 11, 2022
@clavin clavin added platform/macOS component/tray status/confirmed A maintainer reproduced the bug or agreed with the feature has-repro-gist Issue can be reproduced with code at https://gist.github.com/ labels Oct 12, 2022
@clavin
Copy link
Member

clavin commented Oct 14, 2022

Just to note: there's some additional details/investigation into the cause of this in #36031, which I closed as a duplicate of this issue.

@piotrpawlik
Copy link

Looking forward to the fix

@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2023

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 Mar 7, 2023
@davej
Copy link
Contributor Author

davej commented Mar 7, 2023

Still an issue.

@github-actions github-actions bot removed the stale label Mar 8, 2023
@10n37
Copy link

10n37 commented May 3, 2023

Facing same shit when trying to create window based on tray bounds instantly after creating tray

image

@github-actions
Copy link
Contributor

github-actions bot commented Aug 2, 2023

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 Aug 2, 2023
@github-actions github-actions bot removed the stale label Aug 26, 2023
@ScottSavarie
Copy link

bump

@harshit-budhraja
Copy link

@clavin Is there any update on this issue? I'm facing it too. Here's some information to help out with debugging:

Expected Behaviour: trayIcon.getBounds() should return the correct values for x, and y which are needed for me to set my window position correctly w.r.t. the tray icon.

Extended Context: I checked getting these bound values using setTimeout too. Even after 10 * 1000 (10 seconds) of delay, the values are incorrect.

System:

Electron Version: 26.2.1
OS: Mac OS
OS Version: Sonoma (14.0)
Arch: arm64 (Apple Silicon)

Values:

trayIcon.getBounds() = { x: 0, y: 900, width: 32, height: 24 }
mainWindow.getBounds() = { x: 520, y: 287, width: 400, height: 327 }
app.isPackaged = false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 component/tray has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/macOS status/confirmed A maintainer reproduced the bug or agreed with the feature
Projects
None yet
Development

No branches or pull requests

6 participants