CEF 5005 cefclient: MacOS fullscreen unpredictable

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

CEF 5005 cefclient: MacOS fullscreen unpredictable

Postby acs » Fri May 20, 2022 1:22 pm

Greetings,

Use case: we use fullscreen with additional options to put users into a 'kiosk'/secured mode. This issue is only on MacOS Big Sur/Monterey; Windows 10/11 & Ubuntu do not exhibit this behavior.

With 4951 and prior versions going back at least as far as 3729, we could turn on a slew of fullscreen options at the very end of root_window_mac.mm's RootWindowMacImpl::CreateRootWindow method, and the app would go to fullscreen mode and the browser's content would reliably be visible.

Starting with CEF 5005, there's about a 50% chance of the browser content being visible, otherwise a white screen is shown, which seems to be the root window. Without the other presentation options active, I can press Command+backtick to toggle between the browser and the root, so the browser window is there but isn't at the forefront like it used to be. So the app isn't crashing, but there does seem to now be a race condition on whether the browser window is visible upon invoking the fullscreen. I am able to reproduce in cefclient and I pared down the options to just the bare minimum.

Interestingly, I NEVER encounter the race condition/whitescreen issue when I open the app from a terminal-- the issue ONLY happens when invoked from Finder or XCode, and not consistently, but as mentioned, maybe 40-60% of the time. Maybe something about launchd invocation or relative paths somewhere down within chromium is different? Maybe I should be invoking fullscreen in a different manner or location?

Code: Select all
void RootWindowMacImpl::CreateRootWindow(const CefBrowserSettings& settings,
                                         bool initially_hidden) {
  REQUIRE_MAIN_THREAD();
  .
  .
  .
  if (!initially_hidden) {
    // Show the window.
    Show(RootWindow::ShowNormal);

    // fullscreen additions ------------------------->>
    NSApplicationPresentationOptions options =
    [NSApp presentationOptions]; //                         |
    // additional options we use but which aren't needed to reproduce issue
    // NSApplicationPresentationFullScreen;
    // NSApplicationPresentationHideDock                   |
    // NSApplicationPresentationHideMenuBar                |
    // NSApplicationPresentationDisableAppleMenu           |
    // fair warning: don't uncomment this one until issue is resolved or you enjoy hard restart in safe mode
    // NSApplicationPresentationDisableProcessSwitching;
    NSDictionary *fullScreenOptions = @{NSFullScreenModeApplicationPresentationOptions: @(options)};

    [window_ setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
    // [window_ setLevel:CGShieldingWindowLevel()];

    [[window_ contentView] enterFullScreenMode:GetOriginScreen() withOptions:fullScreenOptions];
    [[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
    // end fullscreen additions ------------------------->>
  }



Side note: for my local testing of MacOS cefclient (and our production derivative), I also edited cefclient_mac.mm's tryToTerminateApplication method by adding exit(0); because of a close/quit issue that we originally saw on linux but now see happening in MacOS (4951 & 5005).
acs
Techie
 
Posts: 12
Joined: Thu Apr 08, 2021 9:03 am

Re: CEF 5005 cefclient: MacOS fullscreen unpredictable

Postby acs » Fri May 20, 2022 2:57 pm

Addendum: I can get into the whitescreen state after a successful Finder/XCode launch or even the command line launch by pressing Command+backtick. So there definitely seems to be something with window focus and how browser and root are linked.
acs
Techie
 
Posts: 12
Joined: Thu Apr 08, 2021 9:03 am

Re: CEF 5005 cefclient: MacOS fullscreen unpredictable

Postby acs » Wed May 25, 2022 2:48 pm

In the meantime we're keeping our macOS code on CEF 4951 because the fullscreen invocation reliably works. I just tested again using latest CEF 5005 and the fullscreen invocation is actually worse than earlier 5005 iterations. Previously I was seeing the whitescreen overlay 20% of the time, now it's 80% of the time. I've tried to invoke those options from additional stages of browser opening, showing screen etc, to no avail.
acs
Techie
 
Posts: 12
Joined: Thu Apr 08, 2021 9:03 am

Re: CEF 5005 cefclient: MacOS fullscreen unpredictable

Postby acs » Fri Jun 10, 2022 4:15 pm

Just to wrap up this saga: we also started seeing the whitescreen state on fullscreen invocation in 4951. I found a workaround in our counterpart of cefclient_mac.mm. Near the end of RunMain method, where the delegate creates the application, I wound up changing the value of the waitUntilDone param from NO to YES and could consistently avoid the whitescreen race condition issue:

Code: Select all
    ClientAppDelegate* delegate = [[ClientAppDelegate alloc]
        initWithControls:!command_line->HasSwitch(switches::kHideControls)
                  andOsr:settings.windowless_rendering_enabled ? true : false];
    [delegate performSelectorOnMainThread:@selector(createApplication:)
                               withObject:nil
                            waitUntilDone:YES];


And, of course, once we discovered that by rebuilding our app and using CEF 5060, the whitescreen state on fullscreen invocation is gone entirely, I opted to use that and restore that waitUntilDone to its original value.
acs
Techie
 
Posts: 12
Joined: Thu Apr 08, 2021 9:03 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 41 guests