V8 Context without a frame

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

V8 Context without a frame

Postby Desu » Fri Mar 27, 2015 6:31 am

Hello, is it possible to create v8 context to execute arbitary js code without a frame/browser.

What i am trying to achieve is this. I have a game/simulation engine that uses cef for ui and interaction with the application. Some game/engine functions are bound as js functions and called from the page shown by CEF.

For instance, there is a level loading function in the engine which takes a filename as it's arg , and this function is bound as explained on the JavaScriptIntegration page. And there is a html level selection page rendered off-screen on using cef in to a texture and shown inside the engine window. Clicking links/buttons from the page calls the function like load_level("test_level.xml");(js) . All fine and working awesome.

I am now at the point where i would like add scripting capabilities to the engine. I could in theory embed v8, bind/add my engine functions, and create something like scheduler/script manager to run js files/scripts to program a game and/or parts of the game. But that makes 2 different v8s in the engine, one inside cef and other for running game scripts. One of the main reasons i want this is instead of something like lua is being able to use js functions created for use in ui to be also usable in the game itself.

Now for my question, is it possible to use cef's v8 without a frame/window/browser(or whatever) for the purpose explained above? Or should i just spin my own v8 integration with engine? Or maybe just use a dummy frame window and do not show it on screen at all?


(ps. this is in fact not a game but a medical simulation/visualization app, so scripting could really be handy.)
Desu
Techie
 
Posts: 11
Joined: Mon Jun 24, 2013 3:05 pm

Re: V8 Context without a frame

Postby magreenblatt » Mon Mar 30, 2015 4:49 am

Desu wrote:is it possible to use cef's v8 without a frame/window/browser(or whatever) for the purpose explained above? Or should i just spin my own v8 integration with engine? Or maybe just use a dummy frame window and do not show it on screen at all?

What process do the scripts need to run in? Do they need to access bound native functions?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: V8 Context without a frame

Postby Desu » Sun Apr 05, 2015 7:04 am

Yes i need access to bound native functions.

For instance i would like the scripts to be able to call the said level_load function that i am already calling from ui page.

I want to user to be able to program the simulation/game logic in js. This has nothing to with dom/frames, scripts only need to be able to call native scripts.

now that i think about it io.js/nodejs could be a better candidate for such purpose, but they are not as easy to integrate and i already have cef integration.
Desu
Techie
 
Posts: 11
Joined: Mon Jun 24, 2013 3:05 pm

Re: V8 Context without a frame

Postby magreenblatt » Tue Apr 07, 2015 4:13 am

Using a WebWorker would be the JavaScript approach. You can't access native bound functions directly from a WebWorker thread but you could use the postMessage interface to communicate asynchronously with the main thread and build an API around that.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to CEF Discussion

Who is online

Users browsing this forum: No registered users and 134 guests