Screen goes blank after getting V8Value

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.

Screen goes blank after getting V8Value

Postby DNR » Tue Apr 17, 2018 5:56 am

Hi all,

I'm a newbie and I'm exercising a bit. I want to pass a message from browser to renderer process, and then in renderer process get a V8Value from the global object in OnProcessMessageReceived, but when i try to "mess" with any V8Value (using get or set method) i'm ending with a blank/white screen. I created the "dialNumber" value in OnContextCreated event.
What can i possibly do wrong?

Code: Select all
  bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
                                ... ) {
    
     const std::string& message_name = message->GetName();

     if (message_name == "DialNumber")
     {
        std::string digit = message->GetArgumentList()->GetString(0);

        CefRefPtr<CefV8Context> context = browser->GetMainFrame()->GetV8Context();
        CefRefPtr<CefV8Value> obj = context->GetGlobal();
        CefRefPtr<CefV8Value> val = obj->GetValue("dialNumber"); // <- this makes the frame go blank/white
                 ....
DNR
Newbie
 
Posts: 8
Joined: Tue Apr 10, 2018 6:22 am

Re: Screen goes blank after getting V8Value

Postby magreenblatt » Tue Apr 17, 2018 10:40 am

You need to call Enter/Exit on the context.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Screen goes blank after getting V8Value

Postby DNR » Wed Apr 18, 2018 5:59 am

magreenblatt wrote:You need to call Enter/Exit on the context.


I tried this and didnt work, but when creating a context i kept the context and frame and use those to get the values - ofcourse entering and leaving the context - and it works fine now.
Thanks!
DNR
Newbie
 
Posts: 8
Joined: Tue Apr 10, 2018 6:22 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 43 guests