Skip to content
KENZ edited this page Aug 14, 2024 · 20 revisions

Firefox for Haiku

We're working to port the Firefox web browser to the Haiku.

See my Haiku forum post for the project progress.

Current status

  • It builds and run, but not usable at all yet.
  • It starts rendering a web content with UI, but some child processes crashes or hangs, it doesn't handle mouse operation, closing window crashes Haiku nightly ATM.
    it_shows_something

Build prerequisite

  • Memory: (maybe) 8GB RAM required, 96GB RAM known to work (I tested). 16GB RAM may work (worked on haiku102 branch).
  • Disk Space: At least 30GB of free disk space.
  • Python3, pip(3) installed.
  • cbindgen installed manually.
    1. Uninstall Haikuports' version's cbindgen
    2. cargo install cbindgen --force
    • as current Haikuports version was too old to build firefox esr128 based branch.
       0:10.29 DEBUG: trying cbindgen: /bin/cbindgen
       0:10.29 DEBUG: Executing: `/bin/cbindgen --version`
       0:10.29 DEBUG: /bin/cbindgen has version 0.24.3
       0:10.29 ERROR: cbindgen version 0.24.3 is too old. At least version 0.26.0 is required.
       0:10.29 Please update using 'cargo install cbindgen --force' or running
       0:10.29 './mach bootstrap', after removing the existing executable located at
       0:10.29 /bin/cbindgen.
      

How to build

Basically, it is the Haiku version of Building Firefox On Linux. There are some difference or tricky part.

  1. Checkout source code
    ~src> git clone --filter=blob:none -b haiku128 https://github.com/kenz-gelsoft/gecko-dev.git
    
    • Haiku sometimes fail to clone repo with such a large history. Specifying --filter=blob:none helps.
    • It takes about one hour, consumes about 5GB of disk space.
  2. Run ./mach bootstrap (First time only)
    This is Firefox's bootstraping script to set up your build enviroment. It takes 5-10min. See this page for mach detail.
    ~> cd src/gecko-dev/
    ~/src/gecko-dev> ./mach bootstrap
    
    Note on Artifact Mode:
    
    Artifact builds download prebuilt C++ components rather than building
    them locally. Artifact builds are faster!
    
    Artifact builds are recommended for people working on Firefox or
    Firefox for Android frontends, or the GeckoView Java API. They are unsuitable
    for those working on C++ code. For more information see:
    https://firefox-source-docs.mozilla.org/contributing/build/artifact_builds.html.
    
    Please choose the version of Firefox you want to build (see note above):
      1. Firefox for Desktop Artifact Mode [default]
      2. Firefox for Desktop
      3. GeckoView/Firefox for Android Artifact Mode
      4. GeckoView/Firefox for Android
      5. SpiderMonkey JavaScript engine
    Your choice: 2
    
    • Choose 2. Artifact mode is not supported on Haiku.
    • Additionally, will be asked if you consent build-time data collection by Mozilla. You can decline this safely.
    Collecting glean-sdk==60.1.1
      Using cached glean_sdk-60.1.1.tar.gz (228 kB)
      Installing build dependencies ... error
      error: subprocess-exited-with-error
      
      × pip subprocess to install build dependencies did not run successfully.
      │ exit code: 1
      ╰─> [739 lines of output]
    (snip)
          [end of output]
      
      note: This error originates from a subprocess, and is likely not a problem with pip.
    error: subprocess-exited-with-error
    
    × pip subprocess to install build dependencies did not run successfully.
    │ exit code: 1
    ╰─> See above for output.
    
    note: This error originates from a subprocess, and is likely not a problem with pip.
    Could not install glean-sdk, so telemetry will not be collected. Continuing.
    
    • Failed to build the glean-sdk, please ignore.
    • Glean is the telemetry library Mozilla uses, we don't use it (at least now).
    Collecting psutil<=5.9.4,>=5.4.2
      Using cached psutil-5.9.4.tar.gz (485 kB)
      Installing build dependencies ... done
      Getting requirements to build wheel ... error
      error: subprocess-exited-with-error
      
      × Getting requirements to build wheel did not run successfully.
      │ exit code: 1
      ╰─> [1 lines of output]
          platform haiku1 is not supported
          [end of output]
      
      note: This error originates from a subprocess, and is likely not a problem with pip.
    error: subprocess-exited-with-error
    
    × Getting requirements to build wheel did not run successfully.
    │ exit code: 1
    ╰─> See above for output.
    
    note: This error originates from a subprocess, and is likely not a problem with pip.
    Could not install psutil, so telemetry will be missing some data. Continuing.
    
    • bootstrap script try to find a version to compile, but all of these versions doesn't support Haiku, it fails.
    • This is also for telemetry. So you can ignore this for now.
    Requirement already satisfied: zstandard<=0.17.0,>=0.11.1 in /boot/home/.mozbuild/srcdirs/gecko-dev-843dd7383fa7/_virtualenvs/mach/non-packaged/lib/python3.9/site-packages (0.17.0)
    (snip)
    
    • bootstrap script installs required python packages using pip.
    Executing as root: pkgman install dbus_glib_devel gtk3_devel llvm12 nasm nodejs16
      100% repochecksum-1 [65 bytes]
    Validating checksum for Haiku...done.
      100% repochecksum-1 [64 bytes]
    Validating checksum for HaikuPorts...done.
    Encountered problems:
    problem 1: package llvm17-17.0.6-3 conflicts with llvm12 provided by llvm12-12.0.1-8
      solution 1:
        - allow deinstallation of llvm17-17.0.6-3
      solution 2:
        - do not install "providing llvm12"
    Please select a solution, skip the problem for now or quit.
    select [1...2/s/q]: 2
    Nothing to do.
    
    • bootstrap script installs (part of) required packages using Haiku's pkgman.
      • Please file a issue or ping me if your build fails with absense of some Haiku pacakges. I'll add them to required package list.
      • If you have installed LLVM17 toolchain, then you will asked as above. You can choose deinstall LLVM17 and use LLVM12, or don't install LLVM12. We'll change this.
    Your version of Rust (1.79.0) is new enough.
    
    Mozilla recommends using git-cinnabar to work with mozilla-central (or
    mozilla-unified).
    
    Would you like to run a few configuration steps to ensure Git is
    optimally configured? (Yn): n
    
    • Choose N. Maybe this will set up your git environment for upstreaming patches to Mozilla. But I've not yet tested.
    Will you be submitting commits to Mozilla? (Yn): n
    
    • Choose N. Maybe this will set up Mercurial or git-cinnabar to upstream patches to Mozilla. I've not yet tested this too.
    
    Paste the lines between the chevrons (>>> and <<<) into
    /boot/home/src/gecko-dev/mozconfig:
    
    >>>
    
    <<<
    
    Your system should be ready to build Firefox for Desktop!
    
    ~/src/gecko-dev> 
    
    • Done! If you are lucky enough, you can start building Firefox on your working copy now.
  3. Write mozconfig script
    • Or just ln -s haiku_mozconfig_dbg mozconfig in this branch.
  4. Run ./mach build
    • This should build Firefox successfully if enough dependencies were already installed.
    • It may take long time, 3 hours or so, depending on your PC power.
    • Finally it spends 20-30GB of disk space when the build completes.

How to run (This and following steps needs to be updated!!)

export MOZ_ANDROID_LIBDIR=your/checkout/dir/obj-ff-dbg/dist/bin/
export WAYLAND_DISPLAY=:0
./mach run
  • Set MOZ_ANDROID_LIBDIR environment variable to the directory built firefox binary. Normally this is obj-*/dist/bin in the source directory.
  • ANDROID sounds weird, due to re-using android code path to pass the build. We'll fix this. You don't need do this anymore. Thanks X512!

This should crash at following callstack now.

Debug information for team /boot/home/src/firefox-102.9.0/obj-ff-dbg/dist/bin/firefox (1231):
CPU(s): 8x Intel Core™ i7-3770
Memory: 15.89 GiB total, 679.07 MiB used
Haiku revision: hrev56578+81 May  2 2023 06:22: (x86_64)

Active Threads:
	thread 1239: firefox 
	thread 1240: team 1231 debug task 
	thread 1231: MainThread (main)
		state: Call (disp->Extensions.MESA_query_driver)

		Frame		IP			Function Name
		-----------------------------------------------
		00000000	0xbe89595097	_kern_debugger + 0x7 
			Disassembly:
				_kern_debugger:
				0x000000be89595090:   48c7c0e5000000  mov $0xe5, %rax
				0x000000be89595097:             0f05  syscall  <--

		0x7f6f8a78e8e0	0xbe8959d4e1	__assert_fail + 0x61 
		0x7f6f8a78e900	0x1c6382af45b	/boot/system/lib/libEGL.so.1.0.0 + 0x645b 
		0x7f6f8a78f1f0	0x10668b13cea	childgltest + 0x2da 
		0x7f6f8a78f220	0x10668b145a4	fire_glxtest_process() + 0xb4 
		0x7f6f8a78f380	0x10668b03808	XREMain::XRE_mainInit(bool*) + 0x628 
		0x7f6f8a78f400	0x10668b0f8a8	XREMain::XRE_main(int, char**, mozilla::BootstrapConfig const&) + 0x588 
		0x7f6f8a78f540	0x10668b10071	XRE_main(int, char**, mozilla::BootstrapConfig const&) + 0x101 
		0x7f6f8a78f550	0x10668b1aefc	mozilla::BootstrapImpl::XRE_main(int, char**, mozilla::BootstrapConfig const&) + 0xc 
		0x7f6f8a78f9c0	0x1d92225da82	main(int, char**, char**) + 0x1d2 
			Variables:
			result: 0

		0x7f6f8a78f9e0	0x1d92225d7fa	_start + 0x3a 
		0x7f6f8a78fa20	0x10689396ae3	runtime_loader + 0x103 
		00000000	0x7ffffecfc258	commpage_thread_exit + 0