Personal tools


From MozillaWiki

Jump to: navigation, search


Lite-weight Embedding API for Mozilla based applications with native UI.

Basic architecture is very close to WebKit2, and MicroB


Mozilla has bunch of technologies integrated recently:

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 ([ 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]();
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.
 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 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)

Development Build instructions:

Clone repository with submodules structure

git clone git://

Build it with simple script run:

cd xulrunner-package

# Pull all latest changes

# Not after each pull.all especially after major engine updates it make sense to do rm -f objdir-xxxx-xxx/full_*

# Check list of available options
./ -h 

# Haramttan
./ -t harmattan

# Fremantle
./ -t fremantle

# Desktop - Qt is default
./ -t desktop

# For debug builds add -d argument

After build is finished you fill see inline message about how to run test UI
You can also export SWRENDER=1 - if your desktop or device does not support HW acceleration

Packaged Build instructions (debian desktop, N9):

Clone repositories

mkdir ~/mozembed
cd ~/mozembed
# Gecko Engine with EmbedLite API
git clone git://

# Embedlite toolkit independent components (History,prompt et.c.)
git clone

# qtmozembed - Qt wrapper library around EmbedLite API for quick integration into QML.
git clone

# qmlmozbrowser UI application which works as simple reference UI
git clone

Build with dpkg-buildpackage

cd ~/mozembed/mozilla-central
dpkg-buildpackage -us -uc -b -nc
dpkg -i ../xulrunner*.deb

cd ~/mozembed/embedlite-components
dpkg-buildpackage -us -uc -b -nc
dpkg -i ../embedlite-components*.deb

cd ~/mozembed/qtmozembed
dpkg-buildpackage -us -uc -b -nc
dpkg -i ../libqtmozembed*.deb

cd ~/mozembed/qmlmozbrowser
dpkg-buildpackage -us -uc -b -nc
dpkg -i ../qmlmozbrowser*.deb
  1. Simple test to check
  1. For development it is better to link xulrunner objdir to system (on desktop or on device with ~/mozembed mounted via NFS)
cd ~/mozembed/mozilla-central
./ obj-xr-qt /usr
# for embedlite-components, qtmozembed, qmlmozbrowser just run 

Finally run test example:

qmlMozEmbedTest -url about:license

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)


Qt-Desktop and BeagleBoard Ubuntu

Run test examples:

cd obj-*/dist/bin

Basic core test

EmbedLiteAPI wrapped into qt/qml widget
Qt only, qml based UI with scrolling and zooming (no clicks):
./qmlMozEmbedTest -url


  • If embedding does not start and location differs from what has been used while building QtMozEmbed, then export path to GRE_HOME (path to folder with
ex: export GRE_HOME=/opt/mozilla/xulrunner

Basic view of new architecture: