Skip to content

Fix the grey line rendered at the top of window on Mojave #15008

Closed

Description

@pronebird
  • Output of node_modules/.bin/electron --version: 3.0.2
  • Operating System (Platform and Version): macOS 10.14
  • Output of node_modules/.bin/electron --version on last known working Electron version (if applicable):

Expected Behavior
There should be no grey line rendered at the top of the window area in frameless window.

My conclusion is that Electron uses some obscure combination of window styles that cause this behaviour. I was able to reproduce the same appearance when using Cocoa API in the same fashion on a sample Xcode project.

Actual behavior
On macOS Mojave the grey line is rendered at the top of the window area even when the contents are transparent and the window is configured to be frameless.

To Reproduce
Fork and run https://github.com/pronebird/electron-mojave-titlebar-bug

If you provide a URL, please list the commands required to clone/setup/run your repo e.g.

$ git clone https://github.com/pronebird/electron-mojave-titlebar-bug.git
$ npm install
$ npm start

Screenshots
screenshot 2018-10-07 at 16 43 14

( The dark background is the standard wallpaper on Mojave)

Additional Information
Add any other context about the problem here.

Activity

  1. MarshallOfSound commented on Oct 7, 2018

    @MarshallOfSound
    Member

    @pronebird On all platforms frame: false hides the titlebar, not sure exactly what this issue is getting at? Can you explain more what bug / feature you are seeing / looking for here.

  2. pronebird commented on Oct 7, 2018

    @pronebird
    Author

    @MarshallOfSound on macOS Mojave the one gets the grey line rendered above "hidden" titlebar even if it's entirely transparent, the line is still there. Dropping the NSWindowStyleMaskTitled seems to remedy this.

  3. pronebird commented on Oct 7, 2018

    @pronebird
    Author

    I have tested my assumption on a new Xcode project and it seems that the combination of flags that Electron uses is not desirable.

    I was able to reproduce this by setting the following window configuration (which is pretty much what Electron does):

    window.backgroundColor = NSColor.clear
    window.isOpaque = false
    
    let defaultStyle: NSWindow.StyleMask = [.borderless, .titled]
    
    window.titleVisibility = .hidden
    window.titlebarAppearsTransparent = true
    window.styleMask = defaultStyle

    screenshot 2018-10-07 at 16 13 09

    Dropping the .titled style essentially removes the titlebar instead of making it button-less and transparent.

    window.backgroundColor = NSColor.clear
    window.isOpaque = false
            
    let defaultStyle: NSWindow.StyleMask = [.borderless]
    -window.titleVisibility = .hidden        
    window.titlebarAppearsTransparent = true
    window.styleMask = defaultStyle

    Which works as expected:

    screenshot 2018-10-07 at 16 19 34

  4. MarshallOfSound commented on Oct 7, 2018

    @MarshallOfSound
    Member

    @pronebird I'm still not 100% clear on what the issue you're having is. Can you refill out the issue template but instead of referencing electrons source code describe what isn't currently working and how it should be working.

    I think you're experiencing some kind of bug with frameless windows in Mojave but from it's still unclear from your comments.

    Also providing a way to reproduce whatever issue you are having would be very useful.

  5. changed the title [-]Add a way to handle the titlebar appearance on macOS[/-] [+]Fix the grey line rendered on top of window on Mojave[/+] on Oct 7, 2018
  6. changed the title [-]Fix the grey line rendered on top of window on Mojave[/-] [+]Fix the grey line rendered at the top of window on Mojave[/+] on Oct 7, 2018
  7. pronebird commented on Oct 7, 2018

    @pronebird
    Author

    @MarshallOfSound I've added a test project that you can run to reproduce the issue. Also updated the issue template. Please let me know if you need more information and sorry for starting by mentioning individual lines of code. I was too excited. 😄

  8. garshythoel commented on Oct 11, 2018

    @garshythoel
  9. laurentsenta commented on Nov 19, 2018

    @laurentsenta

    Hi there, thanks for maintaining Electron. And thanks for taking care of detailing the issue @pronebird !

    I'm waiting for a fix to release my app and it may be worth for me to figure out a workaround.
    Could you share a rough timeline?

  10. pronebird commented on Nov 21, 2018

    @pronebird
    Author

    @KevinHughes please do not spread fake news.

    All native apps are doing fine except Electron. The problem lays in fact that Electron does not remove the titlebar for frameless windows, but instead hides it. That's why the line is still there. See my investigation above that shows that removing the titlebar solves the mystery.

    @lsenta I hate to sound negative about Electron, but looking at the age of this issue which was raised well before the macOS Mojave was released, I don't think it's going to be solved anytime soon.

    The best suggestion I can give at this point is to look towards going native for macOS and not depend on a third-party framework like Electron.

  11. KevinHughes commented on Nov 21, 2018

    @KevinHughes

    All native apps are doing fine except Electron. The problem lays in fact that Electron does not remove the titlebar for frameless windows, but instead hides it. That's why the line is still there. See my investigation above that shows that removing the titlebar solves the mystery.

    @pronebird I see now - sorry about the misunderstanding! I depend on Electron since I know nothing about native macOS programming. It's too bad this issue is taking so long since it causes such a bad visual defect and the fix for this specific case appears to be so easy.

  12. floating commented on Jan 9, 2019

    @floating

    Has there been any progress on this?

  13. KevinHughes commented on Feb 2, 2019

    @KevinHughes

    As mentioned in #13164, there is a workaround: when creating a BrowserWindow, set titleBarStyle to 'customButtonsOnHover'. I've found that with transparent: true and frame: false this does everything I expected with no grey line, and I'm finding that window operations (setting the location, resizing, opacity changes) appear to be faster using this option.

    The downside is that it causes #10424, but I just set a CSS border-radius on what I'm rendering and it's fine. And of course, with customButtonsOnHover, moving the mouse to the upper left corner of the window shows the macOS title bar buttons.

    In light of this, my suggestion to @MarshallOfSound and @pronebird is to create a new transparent option to titleBarStyle that does everything customButtonsOnHover does but prevents the buttons from appearing on mouse hover. Does that make sense?

  14. floating commented on Feb 12, 2019

    @floating

    👍 Definitely would like a solution for this!

  15. MarshallOfSound commented on Feb 12, 2019

    @MarshallOfSound
    Member

    Didn't realize this was open, closing as duplicate of #13164

    See #13164 (comment) for final comments

  16. pronebird commented on May 20, 2019

    @pronebird
    Author

    @KevinHughes is there a tracking issue for this? I think it's a viable option.

  17. KevinHughes commented on May 23, 2019

    @KevinHughes

    @KevinHughes is there a tracking issue for this? I think it's a viable option.

    I haven't seen a separate issue for that - if you think it's viable please do make one! I haven't made one since I don't have the ability to test if it's really technically possible or not.

  18. pronebird commented on May 30, 2019

    @pronebird
    Author

    Since 6.0.0-beta.5 it's possible to fix this issue by using the following window configuration:

    titleBarStyle: 'customButtonsOnHover',
    minimizable: false,
    maximizable: false,
    closable: false,
    

    Then just before qutting the app, the one has to make sure to re-enable the closable attribute on window, otherwise the app will never quit, at least on macOS.

    window.setClosable(true);
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions