Xilium.CefGlue/3 & CefGlue/1

Having problems with building or using the CefGlue .NET/Mono binding? Ask your questions here.

Moderator: fddima

Re: Xilium.CefGlue/3 & CefGlue/1

Postby sebarnolds » Mon Nov 12, 2012 4:00 am

Thanks for the fix, the manifest fixed the problem.

I do not need to handle tooltips myself but here is a small reproduction sample for the on_tooltip issue (it is never triggered) if you want to investigate it:
Code: Select all
<html>
<body>
This is a test: hover over the <span title="Tooltip test" style="background-color: red">red</span> text to see it.
</body>
</html>


Putting that in a html file and then opening it with the Windows Forms sample do not trigger a breakpoint in the on_tooltip method when hovering over the red text.
sebarnolds
Techie
 
Posts: 18
Joined: Fri Nov 09, 2012 10:16 am

Re: Xilium.CefGlue/3 & CefGlue/1

Postby fddima » Mon Nov 12, 2012 4:17 am

sebarnolds wrote:Putting that in a html file and then opening it with the Windows Forms sample do not trigger a breakpoint in the on_tooltip method when hovering over the red text.


Thanks for feedback. Looks like currently not implemented in CEF3. Follow issue 783 if you interested in this.
fddima
Master
 
Posts: 775
Joined: Tue Dec 07, 2010 6:10 am

Re: Xilium.CefGlue/3 & CefGlue/1

Postby sebarnolds » Mon Nov 12, 2012 4:23 am

Thanks for those quick answer as well as for the lib !
sebarnolds
Techie
 
Posts: 18
Joined: Fri Nov 09, 2012 10:16 am

Re: Xilium.CefGlue/3 & CefGlue/1

Postby sebarnolds » Thu Nov 15, 2012 10:38 am

Hello. It's me again.

I have a webpage that asks for a confirmation to the user. The problem is that cef doesn't handle the js popup correctly on specific configuration. You can see it for yourself on the picture here :
Image
On Windows XP, when using the Windows Classic theme, it is displayed correctly but if the Windows XP theme is used (the one with the big green startup menu and the blue taskbar) the display is not correct. As you can see, the upper part of the dialog box is transparent and the actual content is below, with the buttons almost not visibles.

I know that it is a cef bug (where should I go to report it ? forum ?) but I'd like to quickly fix it on my end with custom dialogs. I found that I could use CefJSDialogHandler but it seems you locked you CefWebClient class (many classes are internal or sealed). I had to modify your source to add a delegate parameter to the CefWebBrowser constructor and call that delegate when calling CreateBrowser() to create the CefClient. Above that, I had to duplicate your classes (CefWebLifeSpanHandler & CefWebDisplayHandler) because I couldn't use them in my own CefClient.

Here is some code:
Code: Select all
    [ToolboxBitmap(typeof(CefWebBrowser))]
    public sealed class CefWebBrowser : Control
    {
        public delegate CefClient CreateCefClientDelegate(CefWebBrowser core);
        private CreateCefClientDelegate _create_cef_client;

        private bool _handleCreated;

        private CefBrowser _browser;
        private IntPtr _browserWindowHandle;

        CefClient CreateDefaultCefClient(CefWebBrowser core)
        {
            return new CefWebClient(core);
        }

        public CefWebBrowser()
            : this(null)
        { }

        public CefWebBrowser(CreateCefClientDelegate create_cef_client)
        {
            if (create_cef_client == null)
                _create_cef_client = CreateDefaultCefClient;
            else
                _create_cef_client = create_cef_client;

            ....

        }

        protected override void OnHandleCreated(EventArgs e)
        {
            ....

                CefBrowserHost.CreateBrowser(windowInfo, _create_cef_client(this), settings, StartUrl);
            }

            _handleCreated = true;
        }


Is there an easier way to do specify a custom handle for js dialogs ? Are you interested in the patch I made ? What are your thoughts about this ?

Also, I had to add the following code in DemoApps.cs to be allowed to debug in Visual Studio (as it tries to use <project>.vshost.exe to spawn multiple process, which doesn't work):
Code: Select all
#if DEBUG
            settings.SingleProcess = true;
#endif


Thansk forward,
Sebastien

PS: Should I keep asking my questions here or should I create new topics ?
sebarnolds
Techie
 
Posts: 18
Joined: Fri Nov 09, 2012 10:16 am

Re: Xilium.CefGlue/3 & CefGlue/1

Postby fddima » Thu Nov 15, 2012 10:50 am

sebarnolds wrote:I know that it is a cef bug (where should I go to report it ? forum ?) but I'd like to quickly fix it on my end with custom dialogs. I found that I could use CefJSDialogHandler but it seems you locked you CefWebClient class (many classes are internal or sealed). I had to modify your source to add a delegate parameter to the CefWebBrowser constructor and call that delegate when calling CreateBrowser() to create the CefClient. Above that, I had to duplicate your classes (CefWebLifeSpanHandler & CefWebDisplayHandler) because I couldn't use them in my own CefClient.

It is issue already reported https://code.google.com/p/chromiumembed ... ail?id=760 .
About CefWebBrowser / CefWebClient - it is only sample code. Feel free to grab it into your project directly and modify forself.

sebarnolds wrote:Here is some code:
Is there an easier way to do specify a custom handle for js dialogs ? Are you interested in the patch I made ? What are your thoughts about this ?

As i say before - just modify cefwebclient for self.

sebarnolds wrote:Also, I had to add the following code in DemoApps.cs to be allowed to debug in Visual Studio (as it tries to use <project>.vshost.exe to spawn multiple process, which doesn't work):
Code: Select all
#if DEBUG
            settings.SingleProcess = true;
#endif


Yes, use singleprocess to simplify debugging, or disable vs hosting process in project properties.

PS: Should I keep asking my questions here or should I create new topics ?

Yes, new topics are more appropriated. This thread was be created only for info, but currently it is too dirty. :)
fddima
Master
 
Posts: 775
Joined: Tue Dec 07, 2010 6:10 am

Re: Xilium.CefGlue/3 & CefGlue/1

Postby sebarnolds » Thu Nov 15, 2012 11:02 am

Thanks for the quick reply. I'll be sure to create new topics for any further questions.

I find a bit disappointing that you aren't interested in patches as it could be interesting to extand the CefWebBrowser and provide users with a more complete solution / example. Anyway, that's your choice as you are the owner of the library and I understand it.

Thansk again,
Sebastien
sebarnolds
Techie
 
Posts: 18
Joined: Fri Nov 09, 2012 10:16 am

Re: Xilium.CefGlue/3 & CefGlue/1

Postby fddima » Thu Nov 15, 2012 11:24 am

sebarnolds wrote:Thanks for the quick reply. I'll be sure to create new topics for any further questions.

I find a bit disappointing that you aren't interested in patches as it could be interesting to extand the CefWebBrowser and provide users with a more complete solution / example. Anyway, that's your choice as you are the owner of the library and I understand it.

Thansk again,
Sebastien

Uff. We open to apply patches from community to demo projects.
Also project licensed under MIT license, that allow you modify it even without make your private changes public.
But, yes, just creating winforms control - it is not a target of cefglue project at all. From one side 'cause too many peoples use WPF (off-screen rendering required, and using winforms host in wpf it is not a true way). From other side - i doesn't see any sense in creating wrapper around cefglue, when it is possible use cefglue api directly (like providing own cefclient / etc...), and all my applications uses browser with unique way, without 'controls' at all.
And... we have some plans for future. ;)
fddima
Master
 
Posts: 775
Joined: Tue Dec 07, 2010 6:10 am

Re: Xilium.CefGlue/3 & CefGlue/1

Postby BdC » Fri Nov 16, 2012 8:06 pm

We have an application that cycles automatically through many different web pages and when we run the application in multi-process mode it seems like the render process is leaking memory (a few hours and it grows to about 1.5GB peak memory and then it gets automatically killed somehow). This leak does not seem to appear when we run the same application in SingleProcess mode. Is there anything special we need to do in the render process in order to have the c# garbage collection operate? I'm guessing that the render process doesn't have an actual message loop like the main process has, and it's my understanding that garbage collection in c# is tied to the message loop so that the GC runs while there's some idle time.
BdC
Newbie
 
Posts: 4
Joined: Fri Sep 07, 2012 10:50 pm

Re: Xilium.CefGlue/3 & CefGlue/1

Postby fddima » Sat Nov 17, 2012 1:40 am

BdC wrote:We have an application that cycles automatically through many different web pages and when we run the application in multi-process mode it seems like the render process is leaking memory (a few hours and it grows to about 1.5GB peak memory and then it gets automatically killed somehow). This leak does not seem to appear when we run the same application in SingleProcess mode. Is there anything special we need to do in the render process in order to have the c# garbage collection operate? I'm guessing that the render process doesn't have an actual message loop like the main process has, and it's my understanding that garbage collection in c# is tied to the message loop so that the GC runs while there's some idle time.

I'm think that it is doesn't rely on .NET GC at all. Try use cefclient.exe (fully native) instead of managed renderer. If you will get memory leaking in this case then it is probably chromium's bug. And .NET GC doesn't tied to message loop. In general case it is always working on different thread.
fddima
Master
 
Posts: 775
Joined: Tue Dec 07, 2010 6:10 am

Re: Xilium.CefGlue/3 & CefGlue/1

Postby BdC » Sun Nov 18, 2012 12:56 am

fddima wrote:
BdC wrote:We have an application that cycles automatically through many different web pages and when we run the application in multi-process mode it seems like the render process is leaking memory (a few hours and it grows to about 1.5GB peak memory and then it gets automatically killed somehow). This leak does not seem to appear when we run the same application in SingleProcess mode. Is there anything special we need to do in the render process in order to have the c# garbage collection operate? I'm guessing that the render process doesn't have an actual message loop like the main process has, and it's my understanding that garbage collection in c# is tied to the message loop so that the GC runs while there's some idle time.

I'm think that it is doesn't rely on .NET GC at all. Try use cefclient.exe (fully native) instead of managed renderer. If you will get memory leaking in this case then it is probably chromium's bug. And .NET GC doesn't tied to message loop. In general case it is always working on different thread.


I can't use the fully native cefclient.exe for the render process as I have a C# V8 context handler in the render processes and messaging between render and browser process using google IPC. I did solve the issue by forcing a GC.Collect in the render process and memory now stabilizes around 180MB (the only change was to call GC.Collect at each V8 context destroy callback). If I do GC.Collect with the optimize flag (so that GC can choose to collect or not) or if I never call it, then memory increases to about 1.5GB and the process self terminates. I know the GC is not necessarily called from the message loop, but I think it uses it to figure out how busy the process is and if it's a good time to collect (I could be wrong, I'm a c# novice but a c++ master). At least it seems to me like automatic GC is not working in render process, as if I add the optimize flag the fix doesn't work and the process never reclaims any memory (same as never calling GC.Collect at all), but if I force collect, then it works fine. Also worth noting, in single process mode, there is no leak and we don't need to force GC.Collect, it just works, but since we also occasionally have no active CefWebBrowser this no longer works with the latest 904 Cef build and is no longer a viable alternative so we need to move to multi-process with forced GC.Collect to get around the leak.

By the way, thanks a lot for your quick responses and support.
BdC
Newbie
 
Posts: 4
Joined: Fri Sep 07, 2012 10:50 pm

PreviousNext

Return to CefGlue Forum

Who is online

Users browsing this forum: No registered users and 5 guests