cefsharp / CefSharp

.NET (WPF and Windows Forms) bindings for the Chromium Embedded Framework
http://cefsharp.github.io/
Other
9.87k stars 2.92k forks source link

Browser goes blank after some time of browsing. #456

Closed rover886 closed 10 years ago

rover886 commented 10 years ago

I have CefSharp-master project with which is Built on Chromium- 31.0.1650.57. All is working fine and perfect. I am Initializing Cef as:

public static void Init()
{
    var settings = new CefSettings();
    settings.UserAgent = "MyBrowser";         
    if (!Cef.Initialize(settings))
    {
        if (Environment.GetCommandLineArgs().Contains("--type=renderer"))
        {
            Environment.Exit(0);
        }
        else
        {
            return;
        }
    }
}

I am not configuring settings.BrowserSubprocessPath while Initializing as per CEF c++ Doc this property is used to launch sub-processes. Is it necessary to set BrowserSubprocessPath. Is this the main reason for getting blank screen.

jornh commented 10 years ago

Is it necessary to set BrowserSubprocessPath. Is this the main reason for getting blank screen.

No, not if https://github.com/cefsharp/CefSharp/blob/v31.0.0-pre1/CefSharp/CefSettingsBase.cs#L10 still works :smile:. I guess you should be able to verify this if you set a breakpoint and look at settings on your Cef.Initialize() call.

So I guess to help you have to provide further details: Is it the CefSharp.Wpf.Example.exe or CefSharp.WinForms.Example.exe you are running or something else? By "going blank after some time of browsing" do you mean it does so by itself or, when you do what? Which site are you browsing? Steps to reproduce?

Is your "CefSharp.BrowserSubprocess.exe" still alive when this happens?

rover886 commented 10 years ago

I added as reference following DLL's to my .NET WinForms application : CefSharp.dll CefSharp.WinForms.dll CefSharp.dll

And in @ output path I am coping CefSharp.BrowserSubprocess.exe,libcef.dll,icudt.dll and some .pak files (locales.cef, and devtools_resources) from CefSharp-master project which i downloaded from https://codeload.github.com/cefsharp/CefSharp/zip/master. On my form_load I am init. webView as

webView = new WebView(getPropertyValue("NavigateURL").Trim()) { Dock = DockStyle.Fill, Width = wb.Width, Height = wb.Height, };

So I guess what I am doing is correct and same as CefSharp.WinForms.Example.exe.

-- By "going blank after some time of browsing" do you mean it does so by itself or, when you do what? I observed that , browser goes blank when I close and reopen application after some time of use. Let say I started my application and browsed my localhost website after some time of browsing I closed the browser application and If I re-open browser application immediately then It goes blank. In this case i close and re-open again then it works fine.
And one more think to observe that this is not happen always or on every machine (All machine have 64bit OS)

-- Is your "CefSharp.BrowserSubprocess.exe" still alive when this happens?

Yes, When I get blank browser I can see CefSharp.BrowserSubprocess.exe in task manager.

amaitland commented 10 years ago

Are you experiencing the same behavior when using CefSharp.WinForms.Example?

rover886 commented 10 years ago

actually I never tried with CefSharp.WinForms.Example, Do I need to try? Because I am using same DLL's as CefSharp.WinForms.Example.

amaitland commented 10 years ago

Give it a go with CefSharp.WinForms.Example and see if the problem is reproducible.

rover886 commented 10 years ago

I tried for CefSharp.WinForms.Example it's not getting blank :( where I am doing wrong in my application.

jornh commented 10 years ago

Let say I started my application and browsed my localhost website after some time of browsing I closed the browser application and If I re-open browser application immediately then It goes blank

Ah, now you start revealing stuff :smile: so there is something to work with (for both you and us). It could be related to this recent post to the google Group. The workarounds mentioned there might help but we should rather get to the bottom of this and fix it proper!

Does the debug.log file that CEF spits out out reveal any differences for good/bad cases? Maybe you should search/read/ask a bit in the CEF or Chromium projects upstream to see how to turn up the debug level for it first ...

rover886 commented 10 years ago

Hmm..till now debug.log remain blank and sometimes i found pipe error.

amaitland commented 10 years ago

I tried for CefSharp.WinForms.Example it's not getting blank :( where I am doing wrong in my application

Can you provide a sample application? A github fork of master that includes your sample project would be ideal, give us some idea of what your doing.

Example of what I mean looks like this https://github.com/amaitland/CefSharp/tree/bug/wpf-hosted-in-winforms You'll notice there's a new project included in the solution called WPFHostedInWinForm, which is a detailed example reproducing a different bug.

amaitland commented 10 years ago

I should also note that whilst working on the WinForms Tabbed version, there are some rendering quirks that I've noticed. The Google Groups article @jornh references has some fairly practical advice on how to get around those issues. I'm wondering if upgrading to the latest stable Cef might resolve some of the issues.

You can see my work in progress here https://github.com/amaitland/CefSharp/tree/feature/winforms-tabbed.

It would also appear that the parent control may have some relevance, currently the master WinForms example is hosted in a ToolStripContainer, when I combine that with the TabControl it consistently has problems rendering. Some basic experiments showed that removing the ToolStripContainer makes the control render correctly in almost all cases. So there are a couple of quirks.

What is your parent control for the ChromiumWebBrowser?

amaitland commented 10 years ago

Managed to find a little time this afternoon to progress my tabbed browser, found that keeping things simple worked best.

WinForms Tabbed

jornh commented 10 years ago

Nice teaser @amaitland. Did I just see you sneak a tiny pinch of DevTools in there? :wink: looks clean and neat!

amaitland commented 10 years ago

@jornh DevTools is indeed there :smile: Just need to iron out a few rough edges!

jornh commented 10 years ago

Closing due to no feedback from OP, see https://github.com/cefsharp/CefSharp/issues/456#issuecomment-53256433