-
Notifications
You must be signed in to change notification settings - Fork 13
Description
I would like to see this working on at least macOS and Windows. I started with macOS and I couldn't get the example working. After a while I decided to started from scratch with OF 0.9.8, Xcode 8.3.2, and macOS Sierra 10.12.4.
I tried to make this process a bit more automatic by using the ProjectGenerator as much as possible. This is why the folder structure is a bit different and the building phases are much simpler.
Here is my fork with a cef-test example (To get this working you need to do the first 6 steps anyway).
This is what I did to get it working:
-
Download the latest Mac OS X 64-bit Build from the Spotify Automated Builds site. (I downloaded the Standard Distribution
3.2987.1601.gf035232) -
cmake -G "Xcode"in the root of the downloaded folder. -
Open the Xcode project and compile the
cefclient- I switched in
Product->Scheme->Edit Scheme…the Build Configuration toRelease.
- I switched in
-
Copy
Chromium Embedded Framework.frameworkandcefclient Helper.appfromtests/cefclient/Release/cefclient.app/Contents/Frameworksinto the ofxCEF folder inlibs/CEF/lib/osx- The Helper app might be a separate target in the future again but I wanted to eliminate any potential source of failure, so I simply copied this one.
-
Also copy
libcef_dll_wrapper/Release/libcef_dll_wrapper.ainto the same folderlibs/CEF/lib/osx. -
And copy the contents of the
includefolder intolibs/CEF/include -
Now open the project generator and create a new project with ofxCef as addon selected.
-
Open the Xcode project and drag and drop the
cefclient Helper.appintoaddons/ofxCef/libs/CEF/lib/osx -
In the project settings got to Build Phases and add a Copy Files Phase. This is for
Chromium Embedded Framework.frameworkandcefclient Helper.app, the Destination should be set toFrameworks. There might already be aCopy FilesPhase to Frameworks in withChromium Embedded Framework.framework, in that case just add thecefclient Helper.app. -
We need another build phase this time a script phase. In there goes:
install_name_tool -change "@rpath/Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework" "@executable_path/../Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework" "${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}" rm -rf "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/$PRODUCT_NAME Helper.app" mv "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/cefclient Helper.app" "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/$PRODUCT_NAME Helper.app" mv "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/$PRODUCT_NAME Helper.app/Contents/MacOS/cefclient Helper" "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Frameworks/$PRODUCT_NAME Helper.app/Contents/MacOS/$PRODUCT_NAME Helper"With that I think I replaced all the other script phases and the additional script.
As far as I understand only the Helper app and executable name needs to be changed to *appName* + Helper. For some reason we also need to change "@rpath/Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework" of the app executable, which I don't understand because it already seems to point to the right place?! -
Also remove
process_helper_mac.ccfrom theCompile Sourcesphase. -
Now select each .cpp file in
addons/ofxCef/srcand set the type in the file inspector toObjective-C++ Source. Do the same forofApp.cpp. (If we have separate source files for macOS and windows we could change the extension for the macOS sources to.mmto skip this step) -
Copy the contents from my cef-test project
main.cpp,ofApp.cpp, andofApp.h
Now your project should be in the same state as my cef-test project in my fork and it should hopefully compile and show a website.
Well, sometimes at least. I'm running into a few problems:
-
The web content only showed up when resizing the window.
OnPaintisn't called when the the browser initially loads the website, which I don't understand. A dirty workaround was to add this:ofSleepMillis(10); // Seems to help a bit reshape(ofGetWidth(), ofGetHeight());at the end of
void ofxCEF::setup() -
Sometimes the site doesn't seem to show at all. Even after I resize the window a few times. Although I see through Little Snitch that the app makes a connection.
-
Sometimes the memory skyrockets to ~3GB at the start and after a few laggy seconds it goes back to ~1GB. I wasn't able to find out what is using the memory. Looking at the app and the Helper app with Instruments only shows few MB. Normally the Debugging Navigator in Xcode shows around 40MB.
-
The menu bar isn't useable. I also can't cmd+q the app which is annoying.
I looked at cef and the ofxCef code and tried a few things. For example when calling void ofxCEF::setup() in ofApp::setup() NSView * view = [ cocoaWindow contentView]; isn't available. I guess OF hasn't created the window yet. So I moved that into offApp::update() but it didn't really improve a lot.
Is there anyone else who wants to see this production ready? I would appreciate some feedback on the steps I took to get it working and the problems I run into. Maybe I missed something.
And I'm sorry to put all this in one Issue, it's pretty general and everything might be connected after all ;)