Mobile/e10s

From MozillaWiki
Jump to: navigation, search

This page is about the port of Mobile Firefox (Fennec) to the Electrolysis (e10s) multi-process architecture.

Weekly Meetings

The weekly meetings have been merged into the general mobile engineering meeting.

The archived meeting notes can be found at Agenda and notes

How to build

Setting up scratchbox (for Maemo devices only)

To build Fennec for Maemo devices like the N900, Nokia uses a scratchbox environment that keeps all of its packages separate from your Linux distribution. So you must:

  • Have Linux on your machine or in a VM
  • Set up scratchbox, which is a little painful

Below is the condensed version of Maemo install guide, intended for Ubuntu users. If you have questions or need something a little different, it is a good reference.

#
# Scratchbox: install these before doing your Maemo 5 scratchbox.
#

# Install instructions for scratchbox itself. Only need to do these steps once.
sudo echo "deb http://scratchbox.org/debian/ maemo5-sdk main" >> /etc/apt/sources.list
sudo apt-get update
sudo apt-get install scratchbox-toolchain-cs2007q3-glibc2.5-arm7

# Needed for Ubuntu.
sudo echo "vm.vdso_enabled = 0" >> /etc/sysctl.conf
sudo echo "vm.mmap_min_addr = 4096" >> /etc/sysctl.conf
sudo sysctl -p

#
# Maemo 5.0 scratchbox
#
wget http://repository.maemo.org/stable/5.0/maemo-scratchbox-install_5.0.sh \
  http://repository.maemo.org/stable/5.0/maemo-sdk-install_5.0.sh 
sudo sh ./maemo-scratchbox-install_5.0.sh -s /scratchbox
sudo /scratchbox/sbin/sbox_ctl start

# If this is your first scratchbox installation, run this and re-login.
sudo /scratchbox/sbin/sbox_adduser $USER yes

sh ./maemo-sdk-install_5.0.sh

(Note that for this to work, you need to logout and login - opening a new terminal is not enough. The Nokia instructions now continue...)


#
# Run /scratchbox/login.  You are now chroot'ed inside scratchbox environment.
#
sb-conf setup FREMANTLE_ARMEL -c cs2007q3-glibc2.5-arm7 \
  -d qemu:perl:debian-etch:doctools:svn:git -t qemu-arm-sb
wget http://repository.maemo.org/stable/5.0/armel/maemo-sdk-rootstrap_5.0_armel.tgz
sb-conf select FREMANTLE_ARMEL
sb-conf rootstrap maemo-sdk-rootstrap_5.0_armel.tgz
sb-conf install -edFL

# Unfortunately anything built with QT requires a EULA.
# Here you will need to go to http://tablets-dev.nokia.com/eula/index.php and
# accept their EULA. Add the deb repo you subsequently receive to /etc/apt/sources.list
fakeroot apt-get update
fakeroot apt-get install nokia-binaries nokia-apps

For Fennec e10s, you will need to install some additional packages.

# You are still logged in to scratchbox, right?
fakeroot apt-get install libqt4-dev libqt4-gui \
  libxaw7-dev libfreetype6-dev libxi-dev \
  libhildonmime-dev libosso-dev libidl-dev liblocation-dev \
  libasound2-dev libhildon1-dev libiw-dev \
  libxdamage-dev libxcomposite-dev libnotify-dev libhildonfm2-dev \
  libconic0-dev python

Getting the source

Get mozilla and mobile projects off mercurial:

hg clone http://hg.mozilla.org/mozilla-central

Building for desktop

Ubuntu package dependencies:

# Basic Firefox deps
sudo apt-get build-dep firefox
sudo apt-get install mercurial libasound2-dev libcurl4-openssl-dev \
  libnotify-dev libxt-dev libiw-dev mesa-common-dev autoconf2.13

# QT deps
sudo apt-get install libqt4-dev

Create your .mozconfig in your mozilla-central directory. Your .mozconfig should look something like this:

# For improved compile speeds, all optional.
export CCACHE_HARDLINK=1
export CC="ccache gcc"
export CXX="ccache g++"
mk_add_options MOZ_MAKE_FLAGS=-j3

# Make build w/ symbols.
export MOZ_DEBUG_SYMBOLS=1
ac_add_options --disable-debug
ac_add_options --enable-debugger-info-modules=yes

# important mobile options
mk_add_options MOZ_OBJDIR=mobilebase-qt-@CONFIG_GUESS@
ac_add_options --enable-application=mobile

# important qt options
# XXX QT builds currently not rendering content
# ac_add_options --enable-default-toolkit=cairo-qt
# ac_add_options --disable-crashreporter

# e10s
ac_add_options --enable-ipc

To build:

make -f client.mk

Building for Maemo devices

Create your .mozconfig in your mozilla-central directory. Your .mozconfig should look something like this:

# For improved compile speeds, all optional.
export CCACHE_HARDLINK=1
export CC="ccache gcc"
export CXX="ccache g++"
mk_add_options MOZ_MAKE_FLAGS=-j3

# Make an optimized debug build.
export MOZ_DEBUG_SYMBOLS=1
ac_add_options --enable-optimize
ac_add_options --disable-debug
ac_add_options --enable-debugger-info-modules=yes

# important mobile options
mk_add_options MOZ_OBJDIR=mobilebase-qt-@CONFIG_GUESS@
ac_add_options --enable-application=mobile
ac_add_options --with-arm-kuser

# important qt options
ac_add_options --enable-default-toolkit=cairo-qt
ac_add_options --disable-crashreporter
ac_add_options --with-maemo-version=5

# e10s
ac_add_options --enable-ipc

# Other important stuff to prevent build errors (missing glx.h, maybe other stuff)
ac_add_options --with-maemo-version=5
Pro tip: if you are building for desktop and device, take the environment variable MOZCONFIG to your advantage. Put your device mozconfig in your scratchbox home directory. Then, in your scratchbox session:
[scratchbox $] echo export MOZCONFIG=$HOME/.mozconfig >> .bash_profile
Finally, run:
make -f client.mk

How to run

Create an executable script fennectrolysis in your $PATH as:

#!/bin/bash
objdir=[$OBJDIR]/mobile/
export LD_LIBRARY_PATH="$objdir/dist/bin/xulrunner:/usr/lib/debug/lib:/usr/lib/debug/usr/lib"
cd $objdir/dist/bin && exec "$@" ./xulrunner/xulrunner-bin application.ini

replacing [$OBJDIR] with your fennec objdir.

If you are building a xulrunner-less version of Fennec, do this instead:

cd objdir/dist/bin
rm fennec
cp ../../mobile/app/fennec .
LD_LIBRARY_PATH=. ./fennec

The boolean pref browser.tabs.remote controls whether Fennec tabs run in a remote process. It defaults to "true" in electrolysis builds since 2010-06-24.

By default Necko-in-chrome is used. If that's not working for you, you can try setting NECKO_SEPARATE_STACKS=1 in your environment (see the necko docs), though this is not a method that will ever be supported in a release.

See Mobile/Build/Fennec for more tips on building, copying to the device, and so forth.