Embedding/IPCLiteAPI
Jump to navigation
Jump to search
Lite-weight Embedding API for Mozilla based applications with native UI.
Basic architecture is very close to WebKit2, and MicroB
Story
Mozilla has bunch of technologies integrated recently:
- OMTC - Off Main thread compositing - keeping Gecko/XPCOM and Compositor in separate threads (Android Firefox)
- IPC - Multiprocess rendering - keeping Gecko/XPCOM and Compositor in separate processes (Firefox OS, Desktop Firefox Plugins)
In order to build Simple browser with native UI (Gtk/Qt/UiKit) similar to Android Firefox with Java UI, some internal API need to be exposed. Goal of this project to provide Generic embedding API which could be easily wrapped without bunch of extra code into Toolkit specific Widgets, and embed these widgets into platform UI applications.
Benefits of new architecture comparing to default mozilla embedding:
* No XUL/XPCOM heavy content in UI process/Thread (Best memory footprint (process case), fast startup) * Process/Thread communication between UI and Content(Gecko/XPCOM) Thread/Process - built on current Mozilla Chromium/IPDL implementation ([https://developer.mozilla.org/en-US/docs/IPDL/Tutorial IPDL Tutorial]) * Rendering based on Shadow/Shadowable layers tree which provide MultiThread/Process responsive rendering (same as content rendering in XUL Mobile FF/OMTC Android Firefox/Firefox OS) * Multi process model provide ability to load memory greedy content in child process and kill it without increasing memory usage for Main UI application process
New embedding expected initialization sequence
1. Native UI startup (android UI thread view or Gtk/Qt/UIKit event loop) 2. Load EmbedLite library and start point API (can be called in parallel thread) LoadEmbedLite(argc, argv);
3. Get EmbedLite application object, which allow to start Gecko in Child-Thread/Process, and create rendering views EmbedLiteApp* embedapp = XRE_GetEmbedLite(); 4. Setup EmbedLite application listener (Some notifications about main app lifecycle) EmbedLiteAppListener[Derived]* listener = new EmbedLiteAppListener[Derived](); embedapp->SetListener(listener); 5. Startup Embedding, blocking call, better to start UI first, and call this in some main loop event EmbedLite will not freeze application here, and continue native events processing along with Chromium Messages. embedapp->Start(EmbedLiteApp::EMBED_THREAD/PROCESS);
Core Embed Initialization example
6. After EmbedLiteAppListener[Derived] received "Initialized" notification, new EmbedLiteView can be created with: EmbedLiteView* view = embedapp->CreateView(); And setup related EmbedLiteViewListener in order to receive notifications from View actions (title,progress,invalidate et.c.) view->SetListener(MyEmbedLiteViewListener); View Embed Initialization example
Communication between UI and content process
* Load remote content JS (privileged script with full access) and interact using MessageMessenger (send/receive JSON messages) * Use embed messaging API (observe broadcast messages) * Build Custom Gecko C++/JS extensions
Source code path queue
BMO Bug 713681(IPC)
BMO Bug 746800(OMTC)
Build instructions:
git clone git://github.com/tmeshkova/mozilla-central.git cd mozilla-central git checkout embedlite cp embedding/embedlite/config/mozconfig.gtkdesktop mozconfig # or # for harmattan # cp embedding/embedlite/config/mozconfig.qtN9-qt mozconfig MOZCONFIG=$(pwd)/mozconfig make -f client.mk build_all
Try, Test, Report, Contribute:
Fell free to test it, submit issues to github issue tracker, or even better fork it, fix it, contribute changes via Pull Requests.
Pre compiled binaries:
Mer (ARMv7 hardfp)
http://romaxa.info/mer/mozbuild.tar.gz
Harmattan
http://romaxa.info/mer/mozbuildhm.tar.gz
Qt-Desktop and BeagleBoard Ubuntu
http://romaxa.info/fennec/IPCEmbedding/
Run test examples:
cd obj-*/dist/bin Basic core test ./embedLiteCoreInitTest EmbedLiteAPI wrapped into qt/qml widget Qt only, qml based UI with scrolling and zooming (no clicks): ./qmlMozEmbedTest -url linux.org.ru