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

chrome: Disable "Restore pages" popup after incorrect shutdown #3767

Closed
razor999920 opened this issue Aug 7, 2024 · 8 comments
Closed

chrome: Disable "Restore pages" popup after incorrect shutdown #3767

razor999920 opened this issue Aug 7, 2024 · 8 comments
Labels
chrome Related to the Chrome runtime enhancement Enhancement request

Comments

@razor999920
Copy link

Issue

I have a WPF application using Cefsharp 126.2.70. The changes from the 126.2.70 changes the cefsettings runtime to chrome. The ChromeRuntime bootstrap opens a random chrome tab when the WPF window is loaded. This does not happen every time but it happens on every other try of opening the application. Below the what the tab looks like:
cef

Reproduce

  • Keep opening the application multiple times, and in one of the instances, there will be an empty chromium tab along aside the application

Expected Behavior

  • There should be no chromium tab opening along side the window

**Versions **

  • CefSharp: 126.7.80

Code Example

App.xaml.cd
`
private void Application_Startup(object sender, StartupEventArgs e)
{
var settings = new CefSettings()
{
// ChromeRuntime = false,
LogFile = "Debug.log",
LogSeverity = LogSeverity.Verbose,
CachePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\Cache"),
};

    // //Perform dependency check to make sure all relevant resources are in our output directory.
    // settings.CefCommandLineArgs.Add("disable-gpu", "1");
    // settings.CefCommandLineArgs.Add("disable-gpu-compositing", "1");
    // settings.CefCommandLineArgs.Add("disable-extensions", "1");
    // Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);

    Cef.Initialize(settings);

    // Open Window
    MainWindow mainWindow = new MainWindow();
    mainWindow.Show();
}

`

MainWindow.xaml.cd
`
public MainWindow()
{
InitializeComponent();

    Browser.LoadUrl("www.google.com");

}
`

@magreenblatt
Copy link
Collaborator

Are you calling CefShutdown? Is your application crashing?

@magreenblatt magreenblatt added the needs user feedback Additional feedback required label Aug 7, 2024
@razor999920
Copy link
Author

No I'm not calling CefShutdown, and the application is running as intended.
When you run the application, it randomly opens a empty chromium tab along side the application. The tab serves no purpose.

I have also tested this on other machines, and get the same result.

@magreenblatt
Copy link
Collaborator

No I'm not calling CefShutdown

You need to call CefShutdown (or CefSharp equivalent) for proper shutdown. That is likely why you're getting the popup window with "Chromium didn't shut down correctly".

@magreenblatt magreenblatt changed the title WPF - New tab opens in Chromium Browser I run my WPF application #4903 chrome: Disable "Restore pages" popup after incorrect shutdown Aug 7, 2024
@magreenblatt magreenblatt added chrome Related to the Chrome runtime enhancement Enhancement request and removed needs user feedback Additional feedback required bug Bug report labels Aug 7, 2024
@razor999920
Copy link
Author

Sorry for the ignorance but why would I need to call CefShutdown? isn't its purpose to close the application?
cefsharp/CefSharp#2487 (comment)

The issue i'm encountering happens during the application startup

@magreenblatt
Copy link
Collaborator

magreenblatt commented Aug 7, 2024

You can try the --hide-crash-restore-bubble command-line flag, or setting CefSettings.persist_session_cookies to false.

This is related to prefs::kRestoreOnStartup which is configured here in CEF. A value of SessionStartupPref::kPrefValueLast will cause ShouldRestoreLastSession to return true in SessionService::ShouldRestore.

@magreenblatt
Copy link
Collaborator

Sorry for the ignorance but why would I need to call CefShutdown? The issue i'm encountering happens during the application startup

This issue is likely occurring because your previous application run did not shut down CEF/Chromium properly. From your link it sounds like CefSharp may call CefShutdown for you. I suggest you explore why that might not be occurring in your case. For example, maybe your application is crashing during shutdown.

@razor999920
Copy link
Author

@magreenblatt Thank you so much! that worked.
You are correct the issue was with the closing of the app and the command line flag helped.

@SinyimZhi
Copy link

@magreenblatt I encountered a similar problem In the cef_binary_128.4.9+g9840ad9+chromium-128.0.6613.120_windows64. My Win32 program needs to enable persist_session_cookies to save some tokens. Whether or not I add --hide-crash-restore-bubble to the command line flag, the program will pop up the page where it exited abnormally before. My application does call CefShutdown, but we cannot always expect the program have executed CefShutdown , such as killing processes from the task manager or the other processes. Now we can just disable persist_session_cookies to solve this problem, but I think we need a switch to individually control whether the infinite recovery function is enabled or not. Or our application can handle whenever to restore these sessions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chrome Related to the Chrome runtime enhancement Enhancement request
Projects
None yet
Development

No branches or pull requests

3 participants