Skip to content

Starting in fullscreen then toggling to windowed mode results in black screen (1.2.x) #6036

Closed

Description

@marwanhilmi
  • Electron version: 1.2.0, 1.2.1, 1.2.2
  • Operating system: Windows

If you start an browser window in fullscreen and then attempt to toggle to windowed mode, the window will just black out and become unresponsive. Attempting to toggle back again still results in a black screen.

However, if you start the window in windowed mode and then toggle to fullscreen, it works as expected.

This maybe related to the fixes made to the fullscreen API in 1.2.x. It only occurs on Windows. It does not happen on 1.1.3.

You can reproduce easily with the electron-api-demos application and 1.2.2.
https://github.com/electron/electron-api-demos

Update window-options to set fullscreen: true
https://github.com/electron/electron-api-demos/blob/master/main.js#L22

var windowOptions = {
      width: 1080,
      minWidth: 680,
      height: 840,
      title: app.getName(),
      fullscreen: true
    }

Start the application and hit F11 to switch to windowed mode and you'll get a black screen.

Activity

  1. jeremyrajan commented on Aug 11, 2016

    @jeremyrajan

    This is pretty much happening for us as well. With a windowed application if we minimise it to task-bar and then click the icon, results in the black screen. Once we alt-tab it, works fine.

    Electron: 1.2.5
    OS: Windows

    image

  2. CharlieHess commented on Aug 11, 2016

    @CharlieHess
    Contributor

    Probably the same as #6033?

  3. kevinsawicki commented on Aug 11, 2016

    @kevinsawicki
    Contributor

    Probably the same as #6033?

    I don't think so, this issue is only reproducible on Windows and the window becomes completely unusable.

  4. MaherFa commented on Oct 25, 2016

    @MaherFa

    @kevinsawicki thanks you and sorry about the duplicate.
    to narrow down the bug, it seem to occur when fullscreen is called before the window is shown, as I mentioned I was able to start in full screen if I set it to true after win.show()

  5. greggman commented on Nov 27, 2016

    @greggman
    Contributor

    This is happening for me as well in 1.4.5

  6. greggman commented on Nov 27, 2016

    @greggman
    Contributor

    BTW: I wasn't calling win.setFullScreen(true) I was just passing in {fullscreen: true} as an option to new BrowserWindow

    My workaround ATM is to instead pass on {fullscreenable: true} and then use something like

      webContents.on('dom-ready', () => {
          window.setFullScreen(true);
      });
    

    Note that if I don't pass in {fullscreenable: true} then window.setFullScreen(true) has no effect even though the docs say {fullscreenable: true} is the default

  7. jeremyrajan commented on Nov 28, 2016

    @jeremyrajan

    I didn't try this one. Will give it a shot and see if helps us :)

    Thank you 👍

  8. MaherFa commented on Mar 15, 2017

    @MaherFa

    @George35mk you mean maximize?

  9. KoenLav commented on Mar 22, 2017

    @KoenLav
    Contributor

    Same issue here.

    I can confirm that setting the window to fullscreen after the domready event solves the issue. For meteor-desktop as follows:

        eventsBus.on('windowCreated', (window) => {
            window.webContents.on('dom-ready', () => {
              window.setFullScreen(true);
            });
        });
    
  10. added 2 commits that reference this issue on Jun 1, 2017
    4c09b35
    723c69e
  11. dharders commented on Jun 1, 2017

    @dharders

    I just submitted PR #9645 that hopefully fixes this issue. After it's merged you won't need any of the above workarounds and can just use { fullscreen: true } and avoid the two step startup animation of normal->fullscreen. i.e. It should be possible to render straight to fullscreen and still have a responsive window after leaving the fullscreen state.

    FYI: The WS_VISIBLE flag wasn't being set for the GWL_STYLE on return to the ui::SHOW_STATE_NORMAL window state, thus the window couldn't receive any OS events and appeared unresponsive.

  12. added 2 commits that reference this issue on Jun 1, 2017
    ce27507
    aeb68c2
  13. dharders commented on Jun 29, 2017

    @dharders

    Fix: upgrade your electron dependency, fix now released in "electron": "1.7.4 beta"

  14. lishoulong commented on Jan 15, 2019

    @lishoulong

    Hi, @dharders , I also encounter this same question, the version of electron is 2.0.10.

    I have two browserWindows, jump from A browserWindow to B browserWindow. Full screen the B browserWindow, and then click the x icon(close B window), my logic is to hide the B browserWindow, and show A browserWindow.

    But at this time, I find the B BrowserWindow is black, and the A browserWindow shows normal.

    Looking for your help!

  15. lishoulong commented on Jan 15, 2019

    @lishoulong

    I solved this question using isFullScreen method, mentioned in this issue #6033.

  16. meetDeveloper commented on Aug 14, 2019

    @meetDeveloper

    If I construct a browser window with window options as,

    var windowOptions = {
          width: 1080,
          minWidth: 680,
          height: 840,
          title: app.getName(),
          show: false
          fullscreen: true
        }
    

    and then do window.show(), window does not go to full screen mode. @dharders

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