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

Life span handler. #18

Open
dlannan-fmad opened this issue Aug 11, 2020 · 10 comments
Open

Life span handler. #18

dlannan-fmad opened this issue Aug 11, 2020 · 10 comments

Comments

@dlannan-fmad
Copy link

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.

@cztomczak
Copy link
Owner

It's already implemented:

return &g_life_span_handler;

@dlannan-fmad
Copy link
Author

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.

@cztomczak
Copy link
Owner

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

@dlannan-fmad
Copy link
Author

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).

@cztomczak
Copy link
Owner

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.

@dlannan-fmad
Copy link
Author

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).

@cztomczak
Copy link
Owner

Sure, feel free to share your code.

@dlannan-fmad
Copy link
Author

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
Copy link

dlannan commented Feb 2, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@cztomczak @dlannan @dlannan-fmad and others