Recently I became aware of a very nice project that makes it possible to run a complete fullscreen borderless hardware accelerated webbrowser on the Raspberry Pi. As you might have read in one of the blog posts in the [DiY] Personal A.I. Assistant series, I would like to run it on the device and making it the default visual screen enclosure for Mycroft. Similar as the KDE Plasmoid GUI and the little screen on the soon to be delivered Mark-II device. Creating a small webserver on the device with standard info about that Mycroft instance to show as default URL. Drawing / Pushing additional information to it based on which skill and what is needed to be shown. But you can basically show any remote / online website if requested….
- Hey Mycroft, tell me about Abraham Lincoln.
- <Mycroft response>
- Hey Mycroft, show me on the screen.
Or perhaps something like;
- Hey Mycroft, play Hero of War from Rise Against from Youtube on the screen.
- Hey Mycroft, show me the babymonitor
- Hey Mycroft, show me the news (instead of; tell me the news)
As you can see! Countless possibilities, however more on that to come later in a new blog post in that particular serie. First we need to get it to work on our device! And that is what this post is about.
Compiling WPE Webkit for the RaspberryPi running Raspbian
The project linked above is using Resin.io where the docker is based on YOCTO. I really do not want to follow that route and just want to run the WPE browser on Raspbian without docker stuff etc. Now, I spent countless hours googling how to do that, but other than people asking the same question, nothing to be found. The only small handles I could find are on the trac wiki install documentation – Building WPE natively. Not much to go with and others asking the same question online already stated; It doesn’t work.
As there is no clear step-by-step information available, hereby my attempt to get it done. I am not there yet and keep running into small issues here and there, however slowly knocking them down one by one. As there is no other information available online, I decided to start this blog post as a Work In Progress type of blog post, where I just keep adding steps and information on the go. That way, others can join me and perhaps help me out whenever I get stuck again. In the end hopefully together we can get it done. Community efforts!
So here we go…..
First we need to install some dependencies. Most of these are figured out by the sourcecode configuration steps and/or compilation errors. This list might grow longer as we keep on going, but for now run the following command;
sudo apt-get install cmake ninja-build libegl1-mesa-dev mesa-common-dev \ libxkbcommon-dev gperf ruby-dev libcairo2-dev libepoxy-dev libharfbuzz-dev \ libgcrypt11-dev libsoup2.4-dev libsqlite3-dev libwebp-dev libtasn1-6-dev \ libxslt1-dev libgstreamer* ccache python-dev libjpeg-dev
Perhaps you might need some additional packages that you do not have already which I have by installing Mycroft. If so please let me know, and I will adjust above list accordingly.
One dependency of WPEWebkit is WPEBackend which are some libraries developed by the same guys. So before we get into compiling WPEWebkit, first we need to download, compile and install WPEBackend. I am running below commands within my home directory. You can choose otherwise, so I am leaving out all the “cd ~/” commands. Download the latest WPEbackend sourcecode tarball from their site. At current time this is version 0.2.0. Configure the code, build and install;
wget https://wpewebkit.org/releases/wpebackend-0.2.0.tar.xz tar xvf wpebackend-0.2.0.tar.xz cd wpebackend-0.2.0 cmake –GNinja ninja sudo ninja install
This step can easily be done on the Raspberry Pi itself. WPEBackend is not that big and compiling it only takes a few minutes.
Next on the list is actually downloading and building WPEWebkit itself. WPEWebkit is big and compiling it is taking a looooooooooooong time, so I recommend the cross compile it on a beefy machine. Just transfer the folder back to the Raspberry Pi before running the last “sudo ninja install” command. However sorting things out, I am currently compiling it both on another debian 9 machine and on the Raspberry Pi. On the build machine it still took 48 hrs (not a fancy machine), on the Raspberry Pi it is actually still running strong for alreaady 4 days and is at ~60% !!! (Just that you know)
Downloading the sourcecode. latest version is 2.20.2 at current time.
wget https://wpewebkit.org/releases/wpewebkit-2.20.2.tar.xz tar xvf wpewebkit-2.20.2.tar.xz cd wpewebkit-2.20.2/
One of the dependencies is libepoxy > 1.4.0 however Raspbian still contains 1.3.1 There is some debate about a bug being fixed or not, but because of it webkit bumped it to >1.4.0 More information here; https://github.com/WebKit/webkit/blob/master/ChangeLog-2018-01-01#L1669
For now decided to lower the requirement back to >1.3.0
Find and replace by;
find_package(LibEpoxy 1.4.0 REQUIRED) find_package(LibEpoxy 1.3.1 REQUIRED)
We can start to configure the sourcecode by;
cmake -DPORT=WPE -DCMAKE_BUILD_TYPE=Release -DUSE_WOFF2=OFF -DENABLE_JIT=OFF -GNinja
A quick explaination of above parameters. woff2-dev library package is not available for Raspbian so we turn is of with -DUSE_WOFF2=OF There is currently an ARM instruction type of issue which makes compiling the code fail. For it to compile we need to disable JIT by -DENABLE_JIT=OFF
If everything gooes well, the sourcecode should be configured with the following features;
-- Enabled features: -- ENABLE_ACCELERATED_2D_CANVAS .......... OFF -- ENABLE_ENCRYPTED_MEDIA OFF -- ENABLE_JIT ............................ OFF -- ENABLE_VIDEO ON -- ENABLE_WEBDRIVER ...................... ON -- ENABLE_WEB_AUDIO ON -- ENABLE_WEB_CRYPTO ..................... ON -- ENABLE_XSLT ON -- USE_SYSTEM_MALLOC ..................... OFF -- USE_WOFF2 OFF -- Configuring done -- Generating done -- Build files have been written to:
Accelerated 2D canvas is disabled because of an issue with cairo and OpenGL. Encrypted media, ditto problems with OpenGL. Later on when we have figured out all steps and we have WPEWebkit running, I will have a closer look at; WOFF2, ENCRYPTED_MEDIA, ACCELERATED_2D_CANVAS and ofcourse the LibEpoxy issue stated earlier. But let us get some working stuff first.
Now we are ready to start compiling the code. If you are going to compile it on the RPi you will run into “out of memory” problems, so if you do so you are better of adding some temporarily SWAP to get it to succeed.
sudo dd if=/dev/zero of=/swapfile bs=1M count=4096 sudo mkswap /swapfile sudo swapon /swapfile
This will give you 4 GB extra (very slow and inefficient) memory. All that is left is building the code with the ninja command.
Take a break, walk away, go do something else. This will take a while……
When all is done we can install the software simply again by (if you cross compile, move over the folder to your RPi again);
sudo ninja install
Clean up the swap stuff again if you where compiling on the Pi.
sudo swapoff /swapfile sudo rm -f /swapfile
That is it for WPEWekit. Next on the list is the Launcher to start WPE on the Framebuffer similar as with the resin.io project. That is where I am currently at…. There is a launcher which is deprecated and to be replaced by WPEFramework. So that is what I am currently looking at;
More to come as we go…..