How do I start chromium-browser in headless mode? extension "RANDR" missing on display ":99"
Ubuntu
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.4 LTS
Release: 14.04
Codename: trusty
Chromium
chromium-browser --version
Chromium 48.0.2564.116 Ubuntu 14.04
I am serving a Flask web application on localhost
and I want to browse to it in headless mode.
Following this lead on stackoverflow
Prerequisite
$ apt-get install xvfb imagemagick
X virtual frame buffer xvfb-run
Running Chromium with the following options
--allow-running-insecure-content // trying to get passed
--ignore-certificate-errors // the self-signed certs
--ignore-urlfetcher-cert-requests //
--disable-gpu
--no-sandbox
the command
xvfb-run --server-args='-screen 0, 1024x768x24' chromium-browser --allow-running-insecure-content --ignore-certificate-errors --ignore-urlfetcher-cert-requests --disable-gpu --no-sandbox https://admin:password@localhost
Xlib: extension "RANDR" missing on display ":99".
[2596:2596:0407/170544:ERROR:browser_main_loop.cc(206)] Running without the SUID sandbox! See https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment for more information on developing with the sandbox on.
Xlib: extension "RANDR" missing on display ":99".
Xlib: extension "RANDR" missing on display ":99".
[2596:2596:0407/170544:ERROR:desktop_window_tree_host_x11.cc(892)] Not implemented reached in virtual void views::DesktopWindowTreeHostX11::InitModalType(ui::ModalType)
[2596:2596:0407/170545:ERROR:logging.h(808)] Failed to call method: org.freedesktop.DBus.ObjectManager.GetManagedObjects: object_path= /: org.freedesktop.DBus.Error.UnknownMethod: Method "GetManagedObjects" with signature "" on interface "org.freedesktop.DBus.ObjectManager" doesn't exist
[2596:2596:0407/170545:ERROR:logging.h(808)] Failed to call method: org.freedesktop.DBus.ObjectManager.GetManagedObjects: object_path= /: org.freedesktop.DBus.Error.UnknownMethod: Method "GetManagedObjects" with signature "" on interface "org.freedesktop.DBus.ObjectManager" doesn't exist
[2596:2596:0407/170629:ERROR:chrome_browser_main_extra_parts_x11.cc(62)] X IO error received (X server probably went away)
Without --disable-gpu
and --no-sandbox
[3122:3122:0407/172728:ERROR:sandbox_linux.cc(338)] InitializeSandbox() called with multiple threads in process gpu-process
[3062:3099:0407/172728:ERROR:browser_gpu_channel_host_factory.cc(144)] Failed to create channel.
UPDATE 20160407
$ sudo Xvfb :1 -screen 0 1024x768x24 -ac +extension GLX +extension RANDR +render -noreset &
$ export DISPLAY=":1"
$ chromium-browser --allow-running-insecure-content --ignore-certificate-errors --ignore-urlfetcher-cert-requests --disable-gpu --no-sandbox https://admin:password@localhost
getting
[3413:3413:0407/174058:ERROR:browser_main_loop.cc(206)] Running without the SUID sandbox! See https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment for more information on developing with the sandbox on.
[3413:3413:0407/174058:ERROR:browser_main_loop.cc(256)] Gtk: cannot open display: :1
[3422:3422:0100/000000:ERROR:zygote_linux.cc(674)] write: Broken pipe
Also tried with google-chrome
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get install google-chrome-stable
Version
google-chrome --version
Google Chrome 49.0.2623.110
and I am getting the same errors including extension "RANDR" missing on display ":99".
Related posts
any-way-to-start-google-chrome-in-headless-mode
how-to-add-the-missing-randr-extension
unable-to-launch-chrome-ubuntu
Solution 1:
I did something similar on a non-Ubuntu Linux distro. For testing purposes I will use my HTPC running Ubuntu (14.04) to make sure it works there as well with minimal changes.
Distro Information
htpc@HTPC:[~]:$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.4 LTS
Release: 14.04
Codename: trusty
Making sure the display we want to use isn't present yet
htpc@HTPC:[~]:$ DISPLAY=:1 xset q
xset: unable to open display ":1"
Starting Xvfb
Sudo is not needed. I run it as the same user who also starts the browser.
Xvfb :1 -screen 0 '1280x1024x16' -ac &> /dev/null &
Make sure the display is present and owned by yourself
htpc@HTPC:[~]:$ ls -l /tmp/.X11-unix/X1
srwxrwxrwx 1 htpc htpc 0 Apr 15 11:37 /tmp/.X11-unix/X1
Export current display to the :1 we just created.
We can also add DISPLAY=:1 before every command we want to run on the display. However exporting makes sure this will be saved for the current session so you don't have to provide it for every command.
export DISPLAY=:1
Another check to make sure the screen is present and is working (and also that the export bit is working)
htpc@HTPC:[~]:$ xset q
Keyboard Control:
auto repeat: on key click percent: 0 LED mask: 00000000
XKB indicators:
00: Caps Lock: off 01: Num Lock: off 02: Scroll Lock: off
03: Compose: off 04: Kana: off 05: Sleep: off
06: Suspend: off 07: Mute: off 08: Misc: off
09: Mail: off 10: Charging: off 11: Shift Lock: off
12: Group 2: off 13: Mouse Keys: off
auto repeat delay: 660 repeat rate: 25
auto repeating keys: 00ffffffdffffbbf
fadfffefffedffff
9fffffffffffffff
fff7ffffffffffff
bell percent: 50 bell pitch: 400 bell duration: 100
Pointer Control:
acceleration: 2/1 threshold: 4
Screen Saver:
prefer blanking: yes allow exposures: yes
timeout: 600 cycle: 600
Colors:
default colormap: 0x20 BlackPixel: 0x0 WhitePixel: 0xffff
Font Path:
/usr/share/fonts/X11/misc,/usr/share/fonts/X11/Type1,built-ins
DPMS (Energy Star):
Display is not capable of DPMS
Extra debugging step
I will be running nc which will print verbosely if Chrome is trying to contact it. So we'll know whether this setup works. Another way is to run a VNC server on the same display and connect to it so you can see what the browser is doing and whether is Chrome is starting up properly. Which I would recommend! Chrome might be giving different errors in the UI which cannot be seen in the console in your case.
htpc@HTPC:[~]:$ echo Testing... | nc -l 9999 -v &
[2] 8416
htpc@HTPC:[~]:$ Listening on [0.0.0.0] (family 0, port 9999)
Time to start Chrome!
htpc@HTPC:[~]:$ google-chrome --disable-gpu 'http://localhost:9999' &
[3] 8512
htpc@HTPC:[~]:$ [8512:8512:0415/115726:ERROR:browser_main_loop.cc(271)] Gtk: Locale not supported by C library.
Using the fallback 'C' locale.
Xlib: extension "RANDR" missing on display ":1".
Xlib: extension "RANDR" missing on display ":1".
Connection from [127.0.0.1] port 9999 [tcp/*] accepted (family 2, sport 40050)
GET / HTTP/1.1
Host: localhost:9999
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
As you can see above the RANDR error it still present, just ignore it. Below it you see the HTTP request done by Chrome (see User-Agent bit) to the nc process we started. Seems Chrome is starting up as expected and visiting the URL provided.
Trying the same with Chromium
htpc@HTPC:[~]:$ chromium-browser --disable-gpu 'http://localhost:9999' &
[3] 13108
htpc@HTPC:[~]:$ Xlib: extension "RANDR" missing on display ":1".
Xlib: extension "RANDR" missing on display ":1".
[13108:13108:0415/145854:ERROR:logging.h(813)] Failed to call method: org.freedesktop.DBus.ObjectManager.GetManagedObjects: object_path= /: org.freedesktop.DBus.Error.UnknownMethod: Method "GetManagedObjects" with signature "" on interface "org.freedesktop.DBus.ObjectManager" doesn't exist
Connection from [127.0.0.1] port 9999 [tcp/*] accepted (family 2, sport 40542)
[13108:13108:0415/145854:ERROR:logging.h(813)] Failed to call method: org.freedesktop.DBus.ObjectManager.GetManagedObjects: object_path= /: org.freedesktop.DBus.Error.UnknownMethod: Method "GetManagedObjects" with signature "" on interface "org.freedesktop.DBus.ObjectManager" doesn't exist
GET / HTTP/1.1
Host: localhost:9999
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/49.0.2623.108 Chrome/49.0.2623.108 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
Doing the same has pretty much the same effect, with some other additional warnings. The User-Agent is Chromium as expected.
Extra
If you want to keep it all running do not forget to issue the disown command per process and keep them running in the background to make sure that they are not killed when you logout. See http://www.cyberciti.biz/faq/unix-linux-disown-command-examples-usage-syntax/ for more info about disown.