cef crashing when registering extension for calling dot net

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

Moderator: fddima

cef crashing when registering extension for calling dot net

Postby pkearan » Fri Feb 23, 2018 7:37 am

We have been using cefglue version 2623 and using the below extension to pass data from javascript to dot net. Now we are upgrading cefglue to version 3202 but the extension below results in error during initialization of browser. If I comment the RegisterExtension line then there is no crash.

[0223/161321.161:FATAL:V8Initializer.cpp(80)]
Is something changed between these versions which I am missing?

Code below
Code: Select all
internal sealed class RenderProcessHandler : CefRenderProcessHandler
    {
        MyCustomCefV8Handler myCefV8Handler = new MyCustomCefV8Handler();
        protected override void OnWebKitInitialized()
        {
            var nativeFunction = @"gmApi = function(jsonArg) {

            native function MyNativeFunction(jsonArg);
            return MyNativeFunction(jsonArg);
        };
        ";
            CefRuntime.RegisterExtension("MessageEvent", nativeFunction, myCefV8Handler);
            base.OnWebKitInitialized();
        }
    }
    internal class MyCustomCefV8Handler : CefV8Handler
    {
        protected override bool Execute(string name, CefV8Value obj, CefV8Value[] arguments, out CefV8Value returnValue, out string exception)
        {
            returnValue = CefV8Value.CreateString("");
            ReceiveJsFunctionCall(arguments, ref returnValue);
            exception = null;
            return true;
        }
    }
pkearan
Newbie
 
Posts: 2
Joined: Fri Feb 23, 2018 7:34 am

Re: cef crashing when registering extension for calling dot

Postby fddima » Sun Feb 25, 2018 11:55 am

From API perspective everything should be fine, but chromium internals... who knows.

Try move extension registration to OnBrowserCreated method (looks like cef tests uses this point). There is also have sense to pick CEF debug build and catch real stacktrace which probably can be useful.

PS: If nothing helps, almost same functionality can be done with CefV8Context::Eval in OnContextCreated. I'm use last way for years, because extensions was tricky from start (poor error reporting in case of syntax errors).
fddima
Master
 
Posts: 774
Joined: Tue Dec 07, 2010 6:10 am

Re: cef crashing when registering extension for calling dot

Postby amaitland » Mon Feb 26, 2018 4:36 am

Try window.gmApi =
Maintainer of the CefSharp project.
amaitland
Master
 
Posts: 708
Joined: Wed Jan 14, 2015 2:35 am

Re: cef crashing when registering extension for calling dot

Postby pkearan » Tue Feb 27, 2018 5:15 am

"var gmApi" solved the issue. I think the validations are more strict now.
pkearan
Newbie
 
Posts: 2
Joined: Fri Feb 23, 2018 7:34 am

Re: cef crashing when registering extension for calling dot

Postby ndesktop » Wed Feb 28, 2018 12:02 pm

Check the CEF issue 1944.
The same missing var was at fault.
ndesktop
Expert
 
Posts: 365
Joined: Thu Dec 03, 2015 10:10 am


Return to CefGlue Forum

Who is online

Users browsing this forum: No registered users and 1 guest