We have an MFC based game client that currently embeds Gecko for rendering web pages in the client. I am currently working on a CEF based prototype to evaluate the feasibility of migrating to CEF. I have a few queries related to the same. Just to give some background, all the browser embedding support is all built into a Multi threaded DLL and the MFC client uses C++ interfaces provided by the DLL.
Since the DLL was built with /MD flag, I have already rebuilt cef_wrapper with the same flag and was able to successfully link the stub library to our DLL. I am also able to instantiate browser windows. Now to my queries
1. One of the most important things that we require is the ability to invoke In Page Java Script functions from the client C++ code. For instance if the loaded page has a Java Script function called MyFunction which takes some arguments and returns a result. I should be able to somehow invoke the function from my client C++ code, pass the requisite arguments and get the result back (Have to wait till the function is executed). From what I have explored there is a Execute method in the Frame class, but it takes the JS code itself instead of a function name. Is there any way to achieve this? If it is not already there, is there some way to get it by modifying the CEF/Chromium codebase.
2. When I create a browser Instance using CefBrowser::CreateBrowser, I guess the browser instance is created asynchronously. Is there any way to make the application wait till the browser instance is actually created? The issue we are facing is that our DLL exposes separate interfaces for Creating Browser instance and for navigating to an URL. So in a lot of cases, the client has code sequences comprised of a browser instance creation call followed by a url navigation call. If the URL navigation call happens before the browser instance is actually created, then that would lead to a crash. I guess this is because the multi-threading flag is enabled while calling CefInitialize. For the time being, overcome the issue by delegating the browser creation to the navigation function call. Alternatively If we do choose to run CEF in single threaded mode, how do I get the Cef events to happen at regular intervals, I am aware that there is a method to force the Cef work, but what is the best way to call it. Should I just use a timer?
3. There is the question of distributable size as well. Size is very important to us as the client installs/upgrades over the internet. Our Gecko distributable's amount to 4.3Mb in size after compression. Bare minimal CEF distributables (libcef.dll and icudt.dll) take up 12Mb odd after the same sort of compression. I have been reading the other thread where it was stated that the size can be reduced by switching of webkit features that are not required. How do I go about it. Do I simply regenerate the project files and build the cef wrapper project or is something else required?