cefcapi icon indicating copy to clipboard operation
cefcapi copied to clipboard

Life span handler.

Open dlannan-fmad opened this issue 4 years ago • 10 comments

I really dont know if people are using this. But heres how you register the missing life_span handler.

///
// Return the handler for browser life span events.
///
struct _cef_life_span_handler_t* CEF_CALLBACK get_life_span_handler(
        struct _cef_client_t* self) {
    DEBUG_CALLBACK("get_life_span_handler\n");

    cef_life_span_handler_t *life_span_handler = (cef_life_span_handler_t *)calloc(1, sizeof(cef_life_span_handler_t)); 
    initialize_cef_life_span_handler(life_span_handler);

    // Implemented!
    return life_span_handler;
}

I added a g_exit method in the initialise on do_close and now the application cleanly exits. Hope this helps.

dlannan-fmad avatar Aug 11 '20 15:08 dlannan-fmad

It's already implemented: https://github.com/cztomczak/cefcapi/blob/3cf3ac16a5972405f6d0acb1c4d441cc3663f2cc/capi/cef_client.h#L115

cztomczak avatar Aug 11 '20 16:08 cztomczak

I couldn't get the global one to work with do_close. That is why I used the above method. I still use the same handler initialiser you have - sorry should have mentioned that.

dlannan-fmad avatar Aug 11 '20 23:08 dlannan-fmad

What was exactly your problem, was it not called? The code works the same, it doesn't make sense to me.

cztomczak avatar Aug 12 '20 08:08 cztomczak

I dont know if its a platform/implementation thing. I was receiving segfaults when using the global variable to run the cefsimple. My setup: Debian 10, i7 32GB, x64 build env. Im also building it with the following gcc flags:

CC			= gcc
CFLAGS		= -Wall -Werror -I../../thirdparty/cef -I. -I..
LDLIBDIR	= -Wl,-rpath,$(RUNPATH)
LDFLAGS		= -L$(OUTPATH) -lX11 -lcef -lm -ldl

I'm now building other packages into it as well (hence the lm and ldl). These were not in it originally. I'll try to replicate and capture a trace or gdb stack in a few days(currently a bit busy).

dlannan-fmad avatar Aug 12 '20 10:08 dlannan-fmad

Yeah, because this code is supposed to run with the main_linux.cc and main_win.cc examples which set the g_life_span_handler global variable.

cztomczak avatar Aug 12 '20 11:08 cztomczak

Yeah. I thought there might be some MT or MP issues with the way CEF works (not sure if that is a problem with global handlers on the main proc). Thanks anyway for the hard work - its working wonderfully well. I'll share a github repo once I get the thing stable. Its a little like NodeJS, but with a luajit backend instead (mainly so I can run torch and and some other luajit based tools with it).

dlannan-fmad avatar Aug 12 '20 11:08 dlannan-fmad

Sure, feel free to share your code.

cztomczak avatar Aug 12 '20 12:08 cztomczak

Well. I got it working, but it turns out its CEF itself. And Ive already spent 4 weeks trying to get CEF to work as needed, so Im moving to a different web engine. Webkit, khtml and Gecko (Goanno) are now something Im going to try out instead. Thanks again for the help. Really appreciated.

dlannan-fmad avatar Aug 18 '20 12:08 dlannan-fmad

Well. I got it working, but it turns out its CEF itself. And Ive already spent 4 weeks trying to get CEF to work as needed, so Im moving to a different web engine. Webkit, khtml and Gecko (Goanno) are now something Im going to try out instead. Thanks again for the help. Really appreciated.

Сould you please tell me if you managed to switch to another browser engine ? This CEF does not work.

Staxcelrom avatar Feb 02 '22 11:02 Staxcelrom

This was quite a while ago. I ended up trying webkit here: https://github.com/kakutai/nodelj It works quite well, but its a weird implementation with luajit :) .. CEF ended up being too nasty in terms of managing the processes and execution flow. The above is for Linux only atm. Its difficult to get it working on Win, but should work on OSX with the right changes.

dlannan avatar Feb 02 '22 12:02 dlannan