cefsimple_Helper crash on launch (macOS)

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

cefsimple_Helper crash on launch (macOS)

Postby kyr0 » Wed Aug 29, 2018 12:27 pm

Hi,

I guess I know why it happens, but unfortunately I'm unable to find a solution on my own...

I codesigned both, the cefsimple and cefsimple_Helper, I'm using Xcode and a pretty original code base.
When I start the cefsimple_Helper directly it immediately crashes:

Bildschirmfoto 2018-08-29 um 19.15.04.png
Bildschirmfoto 2018-08-29 um 19.15.04.png (122.43 KiB) Viewed 4672 times


I believe it's because the Chromium Embedded Framework.framework is not bundled directly and starting the helper directly is not intended at all.

So, why did I try to launch the helper directly?

My issue is, that I don't know why my code for Javascript integration isn't invoked at all.
I understood that on macOS I need the sub-process model and for me it looks like the helper would need to create an instance of a class that implements CefApp and some other interfaces like CefRenderProcessHandler, depending on what I want to do..., like the GeneralUsage docs explain...

Code: Select all
// Optional implementation of the CefApp interface.
  CefRefPtr<MyApp> app(new MyApp);


But when I try to set a breakpoint in the main() of the cefsimple_Helper and run the cefsimple from Xcode, the breakpoint is not reached.
So I don't know if the helper is even executed or if I need a better debug configuration for this case?

I was googleing, debugging and trying now for a few hours and finally decided to post a question here because I feel stuck.

I'm sorry, I'm a beginner with C++ and Obj-C but I'm willing to learn fast and read a lot :)

Thanks a lot!
Aron
kyr0
Newbie
 
Posts: 7
Joined: Wed Aug 29, 2018 7:03 am

Re: cefsimple_Helper crash on launch (macOS)

Postby magreenblatt » Wed Aug 29, 2018 1:01 pm

As you've noticed you can't launch the helper process directly. Instead, you should attach the debugger to the helper process after Chromium has launched it. See for example https://lists.apple.com/archives/Xcode- ... 00229.html
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: cefsimple_Helper crash on launch (macOS)

Postby kyr0 » Wed Aug 29, 2018 3:12 pm

Hi magreenblatt,

thanks a lot, I just needed this info... everything is working fine now, including the JS -> native and native -> JS calls.
I'm planning to pass a Float32Array forward and back using a v8 extension and CefRegisterExtension for the JS -> native call and a frame->ExecuteJavaScript(...) for the forward call native -> JS.

Passing the data from native -> JS seems to involve a string cast of all the data. We're talking about up to 4096 floats. I would like to call the JS function by transforming this data into a V8 wrapper datatype instead. The same goes for the way back... is there any way to get around the for loops to convert between CefV8ValueList and CefListValue?

I bet, there is none because we're talking about IPC here and there must be some kind of string serialization -- finally between the JS engine and it's wrapping API?

I'm a bit concerned of the performance impact. But anyways, thanks a lot, I'm already almost where I wanted to be :)

Best,
Aron
kyr0
Newbie
 
Posts: 7
Joined: Wed Aug 29, 2018 7:03 am

Re: cefsimple_Helper crash on launch (macOS)

Postby magreenblatt » Wed Aug 29, 2018 3:36 pm

kyr0 wrote:Passing the data from native -> JS seems to involve a string cast of all the data

If you're using a CefListValue of doubles to pass the array via IPC then there should be no string casts.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: cefsimple_Helper crash on launch (macOS)

Postby kyr0 » Wed Aug 29, 2018 3:49 pm

Awesome, precisely I do:

To receive the Float32Array from JS:

Code: Select all
bool ClientV8ExtensionHandler::Execute(const CefString &name, CefRefPtr<CefV8Value> object, const CefV8ValueList &arguments, CefRefPtr<CefV8Value> &retval, CefString &exception)
{
    if ( name == "passAudio" ) {
       
        if ((arguments.size() == 2) &&
            arguments[0]->IsArray() &&
            arguments[1]->IsArray()) {
           
            CefRefPtr<CefFrame> frame  = CefV8Context::GetCurrentContext()->GetBrowser()->GetMainFrame();

           // received the Float32Arrays from JS context
           // TODO: Probably will need to pass this data via IPC to the parent process to hand it to the DAW (audio workstation host)
           
            return true;
        }
    }


I don't know if there is a cast happening between the JS execution context in V8 and the point where ClientV8ExtensionHandler::Execute is called.

And now from native -> JS... it get's ugly:

Host DAW will hand me two float[] for left and right channel. I probably need to pass that to the sub-process via IPC and then...

Code: Select all
frame->ExecuteJavaScript("processAudio([0, 1], [7, 8]);", frame->GetURL(), 0);


Urgs, instad of [0, 1] and [7, 8] I need a serialized (like JSON serialized) form for the float[] data. Here's where the cast might be needed...?
One option would be to use a JSON serializer lib and generate me the arguments, but...

Well, is there a way to call window.processAudio (it is defined by the JS in the webapp atm) "directly" and pass the arguments -- maybe as a CefV8ValueList instead of invoking the V8 javascript parser/engine using a script as string (which will maybe lead to a super slow eval(...) call?) ?

Thanks in advance! :)

If it's not possible, I will just use the "ugly" way..

Best,
Aron
kyr0
Newbie
 
Posts: 7
Joined: Wed Aug 29, 2018 7:03 am

Re: cefsimple_Helper crash on launch (macOS)

Postby magreenblatt » Wed Aug 29, 2018 4:00 pm

Yes, you can call a JS function from native code. See https://bitbucket.org/chromiumembedded/ ... -functions
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: cefsimple_Helper crash on launch (macOS)

Postby kyr0 » Wed Aug 29, 2018 4:08 pm

Oh, my fault, I should have read the docs two times before asking. Thanks, all questions resolved. I will look into IPC between parent and sub-process now.

Have a nice day! :)
kyr0
Newbie
 
Posts: 7
Joined: Wed Aug 29, 2018 7:03 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 30 guests