Skip to content

macOS: dock menu can get into broken state #11159

Closed

Description

@bpasero
  • Electron version: 1.7.9
  • Operating system: macOS 10.12.6

Expected behavior

The dock menu of the application separates actions and recent entries.

Actual behavior

There are entries mixed.

How to reproduce

See this:

image

We are using a combination of app.clearRecentDocuments and app.addRecentDocument whenever a file or folder is opened with VS Code. We always first clear all recent documents and then add all the ones in MRU order.

What further information can I provide to find out more?

Activity

  1. sethlu commented on Nov 21, 2017

    @sethlu
    Contributor

    @bpasero Since the recent documents menu is only updated in historyMainService.ts, can you provide a sample mru = this.getRecentlyOpened() that causes the menu to fail? I can help debug if it's something fixable within Electron's scope.

  2. bpasero commented on Nov 22, 2017

    @bpasero
    ContributorAuthor

    @sethlu I can reproduce by the following recent documents:

    electron.app.clearRecentDocuments();
    electron.app.addRecentDocument('/Users/bpasero/Development/vscode.code-workspace');
    electron.app.addRecentDocument('/Users/bpasero/Desktop/test-js');
    electron.app.addRecentDocument('/Users/bpasero/Development/monaco/src/typings/electron.d.ts')
    electron.app.addRecentDocument('/Users/bpasero/Development/bpaser-chokidar');
    electron.app.addRecentDocument('/Users/bpasero/Development/bpaser-fsevents');
    electron.app.addRecentDocument('/Users/bpasero/Development/skype/patch-electron.code-workspace');

    Results in:

    image

  3. sethlu commented on Nov 22, 2017

    @sethlu
    Contributor

    @bpasero Great! 👍 Testing it now...

  4. sethlu commented on Nov 22, 2017

    @sethlu
    Contributor

    @bpasero From my testing with macOS 10.13.2 an overflowing of menu items seems working fine. What's your settings in "System Preferences" for recent items? 😕 It appears that bpaser-chokidar and bpaser-fsevents are overridden by the separator and the "Hello World!" in the screenshot...

    screenshot 2017-11-22 01 55 13

    Since MAX_MACOS_DOCK_RECENT_ENTRIES is set as 10 by default (vs/platform/history/electron-main/historyMainService.ts#L32), I'm wondering if the macOS settings may be conflicting with that. If that happens to be the case, an API may be exposed from Electron to get the actual allowance?

  5. bpasero commented on Nov 22, 2017

    @bpasero
    ContributorAuthor
  6. sethlu commented on Nov 22, 2017

    @sethlu
    Contributor

    @bpasero So far I could come up with 2 tests:

    1. If it's something happening on the OS level, the Atom editor should experience a similar issue
    2. If it's to do with VSCode specifically, probably commenting out vs/code/electron-main/menus.ts#L309-L316 would fix the broken layout... Probably worth trying this out, and see what this will point us to do next?
  7. bpasero commented on Nov 23, 2017

    @bpasero
    ContributorAuthor

    @sethlu how is this issue related to VS Code, I can reproduce it with the code I provided in a standalone electron application as outlined in #11159 (comment)?

  8. sethlu commented on Nov 23, 2017

    @sethlu
    Contributor

    Since Electron only offers a thin layer on top of the actual system API, I doubt if this is an issue with macOS itself. 😮 There was an app that I was using yesterday (OmniOutliner, non-Electron-based app) and it’s experiencing a same issue.

  9. sethlu commented on Nov 24, 2017

    @sethlu
    Contributor

    Mhm I’m finding difficulty reproducing the failing case. I'm wondering whether the recent document menu items are out of the scope of Electron’s layer (not set with NSApplication’s dockMenu) since they are managed with addRecentDocument/clearRecentDocuments. There seems to be also quite a short of documentation on the handling of menu model and how the dock menu we set is drawn in interference with the automatically populated items.

    There are two tests whose results I’m interested in investigating however:

    1. If we clear the recent documents first and afterwards add each link at an one-second interval, will the issue still occur?
    2. If we do not clear the recent documents but directly add all the recent documents (since repeating entries are accepted and managed by AppKit), will the menu items still overflow?
  10. bpasero commented on Nov 24, 2017

    @bpasero
    ContributorAuthor

    @sethlu I can still reproduce when I delay the addition of recent documents by 1s each.

  11. sethlu commented on Nov 24, 2017

    @sethlu
    Contributor

    @bpasero I think this may be an issue related to macOS rather than Electron... Can you provide a screenshot of the final result? Also did you leave the dock menu as default as well?

  12. bpasero commented on Nov 25, 2017

    @bpasero
    ContributorAuthor

    @sethlu screenshot is in #11159 (comment)

    Also did you leave the dock menu as default as well?

    Yes, I only added recent documents

  13. 6 remaining items

  14. bpasero commented on Jan 9, 2019

    @bpasero
    ContributorAuthor
  15. added and removed
    blocked/need-info ❌
    on Jan 9, 2019
  16. bpasero commented on Mar 11, 2019

    @bpasero
    ContributorAuthor

    I finally figured out what is triggering it: if you add an entry to the dock that does not exist on disk, the list gets into this broken state!

    @MarshallOfSound and others, I can do a PR on updating the docs or is this something that should be fixed by Electron itself?

  17. bpasero commented on Mar 11, 2019

    @bpasero
    ContributorAuthor
  18. clshortfuse commented on Mar 11, 2019

    @clshortfuse

    It could help to add support for:

    https://developer.apple.com/documentation/appkit/nsdocumentcontroller/1514976-recentdocumenturls

    If we can call recentdocumenturls, then we can do a cross-comparison of what we expect to be in the dock and what's actually in the dock. Then we can tell the app to clear and recreate the dock entries if there's a mismatch. Unfortunately, it doesn't seem like the Mac OS X API lets us manipulate entries one-by-one, but it's better then nothing.

  19. sofianguy commented on Aug 9, 2019

    @sofianguy
    Contributor

    @bpasero is this bug still happening on version 4.2.x or later?

  20. added
    blocked/need-info ❌
    on Aug 9, 2019
  21. bpasero commented on Aug 9, 2019

    @bpasero
    ContributorAuthor

    Yeah, nothing changed. The workaround for VSCode is to make sure that every entry in the dock we add exists on disk.

  22. added and removed
    blocked/need-info ❌
    on Aug 19, 2019
  23. electron-triage commented on Feb 19, 2020

    @electron-triage

    Thank you for taking the time to report this issue and helping to make Electron better.

    The version of Electron you reported this on has been superseded by newer releases.

    If you're still experiencing this issue in Electron 6.x.y or later, please add a comment specifying the version you're testing with and any other new information that a maintainer trying to reproduce the issue should know.

    I'm setting the blocked/need-info label for the above reasons. This issue will be closed 7 days from now if there is no response.

    Thanks in advance! Your help is appreciated.

  24. added
    blocked/need-info ❌
    on Feb 19, 2020
  25. electron-triage commented on Mar 6, 2020

    @electron-triage

    Thank you for your issue!

    We haven't gotten a response to our questions in our comment above. With only the information that is currently in the issue, we don't have enough information to take action. I'm going to close this but don't hesitate to reach out if you have or find the answers we need, we'll be happy to reopen the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions