balena-labs-projects / xserver Goto Github PK
View Code? Open in Web Editor NEWA simple X11 server block
License: Apache License 2.0
A simple X11 server block
License: Apache License 2.0
Sometimes DISPLAY is :0, sometimes :1, sometimes higher.
Seems to be related to reboots of the machine, but might also occurs on service restart.
It doesn't happen every time so it's hard to pin down the conditions.
Tested on x86 with service installed from dockerhub.
xserver:
image: balenablocks/xserver
restart: always
privileged: true
volumes:
- "x11:/tmp/.X11-unix"
environment:
- CURSOR=false
Note that there's always only one entry in /tmp/.X11-unix/
but not always X0
My current workaround is to add this to my service start script :
while [ `ls /tmp/.X11-unix/ | wc -l` == 0 ]; do echo "display not created yet"; sleep 0.5; done; echo "display created";
DISPLAY=`ls /tmp/.X11-unix/ | sed s/X/:/`
export DISPLAY
echo "DISPLAY is set to $DISPLAY"
while ! xset -q; do echo "display doesn't accept connection yet"; sleep 0.5; done; echo "display ready";
I've just copied over the project and pushed it over to my Jetson Nano device. The xserver does start and i get a mouse cursor on the screen that i can move if I've got a mouse plugged in. However, the application glxgear doesn't show on the screen..
Heres the logs:
[Logs] [2/24/2023, 09:43:05] [xserver] Kernel command line: tegraid=21.1.2.0.0 ddr_die=4096M@2048M section=512M memtype=0 vpr_resize usb_port_owner_info=0 lane_owner_info=0 emc_max_dvfs=0 touch_id=0@63 video=tegrafb no_console_suspend=1 console=ttyS0,115200n8 debug_uartport=lsport,4 earlyprintk=uart8250-32bit,0x70006000 maxcpus=4 usbcore.old_scheme_first=1 lp0_vec=0x1000@0xff780000 core_edp_mv=1125 core_edp_ma=4000 gpt tegra_fbmem=0x800000@0x92cb4000 is_hdmi_initialised=1 console=ttyS0,115200 console=tty0 fbcon=map:0 net.ifnames=0 sdhci_tegra.en_boot_part_access=1 root=UUID=ba1eadef-c4b9-4612-b8d5-353312751614 ro rootwait l4tver=32.7.1 console=null quiet splash vt.global_cursor_default=0 consoleblank=0 sdhci_tegra.en_boot_part_access=1
[Logs] [2/24/2023, 09:43:05] [xserver] Build Date: 01 February 2023 02:11:18PM
[Logs] [2/24/2023, 09:43:05] [xserver] xorg-server 2:1.20.11-1+deb11u5 (https://www.debian.org/support)
[Logs] [2/24/2023, 09:43:05] [xserver] Current version of pixman: 0.40.0
[Logs] [2/24/2023, 09:43:05] [xserver] Before reporting problems, check http://wiki.x.org
[Logs] [2/24/2023, 09:43:05] [xserver] to make sure that you have the latest version.
[Logs] [2/24/2023, 09:43:05] [xserver] Markers: (--) probed, (**) from config file, (==) default setting,
[Logs] [2/24/2023, 09:43:05] [xserver] (++) from command line, (!!) notice, (II) informational,
[Logs] [2/24/2023, 09:43:05] [xserver] (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
[Logs] [2/24/2023, 09:43:05] [xserver] (==) Log file: "/var/log/Xorg.0.log", Time: Fri Feb 24 08:43:05 2023
[Logs] [2/24/2023, 09:43:05] [xserver] (==) Using system config directory "/usr/share/X11/xorg.conf.d"
[Logs] [2/24/2023, 09:43:06] [xserver] non-network local connections being added to access control list
[Logs] [2/24/2023, 09:43:06] [xserver] xrandr: Failed to get size of gamma for output default
[Logs] [2/24/2023, 09:43:19] Starting service 'glxgear sha256:6ec2bff917fcc6cedad49e55423734f59f15dee3402f4a8e1ad8d913b42a0bb0'
[Logs] [2/24/2023, 09:43:52] Starting service 'glxgear sha256:6ec2bff917fcc6cedad49e55423734f59f15dee3402f4a8e1ad8d913b42a0bb0'
[Logs] [2/24/2023, 09:44:56] Starting service 'glxgear sha256:6ec2bff917fcc6cedad49e55423734f59f15dee3402f4a8e1ad8d913b42a0bb0'
E.g on x64 device:
[Logs] [9/28/2021, 15:34:50] [browser] /opt/xserver/entry.sh: 16: vcgencmd: not found
[Logs] [9/28/2021, 15:34:50] [browser] /opt/xserver/entry.sh: 16: [: Illegal number:
Hi,
I have tried this out on a FinCM3. It seems that sometimes a lockfile is created after a reboot and this prevents the X server to start on $FORCE_DISPLAY
. The container then gets stuck in a restart loop with the same logs:
Running balena base image entrypoint...
Setting initial display to FORCE_DISPLAY - :0
balenaBlocks xserver version: 0.0.3
Checking GPU memory
/opt/xserver/entry.sh: 18: vcgencmd: not found
/opt/xserver/entry.sh: 18: [: Illegal number:
(EE)
Fatal server error:
(EE) Server is already active for display 0
If this server is no longer running, remove /tmp/.X0-lock
and start again.
(EE)
(EE)
Please consult the The X.Org Foundation support
at http://wiki.x.org
for help.
(EE)
xinit: giving up
xinit: unable to connect to X server: Cannot assign requested address
xinit: server error
I would propose this fix for the entry.sh
script:
https://github.com/balenablocks/xserver/blob/c3acc3e2ed2c3b59abae711a84d6eb1846149ae6/src/entry.sh#L9
LOCK_FILE="/tmp/.X${FORCE_DISPLAY//:}-lock" # remove ':' prefix from FORCE_DISPLAY
if [ -f $LOCK_FILE ]; then
echo "Removing lockfile $LOCK_FILE"
rm -f $LOCK_FILE &> /dev/null
fi
To the raspberry pi 4 we have connected a screen with resolution 1480x320.
The problem is that it display an image with black bar around it.
Docker-compose.yml:
version: '2.1'
volumes:
# we create a shared volume so that the xserver can mount its socket file, and our application container will be able to use it to display
xserver-volume:
services:
xserver:
image: balenablocks/xserver
restart: always
privileged: true
volumes:
# when we start, a UNIX socket is mounted in this directory, for communication to the X server
- 'xserver-volume:/tmp/.X11-unix'
labels:
io.balena.features.dbus: 1
io.balena.features.kernel-modules: 1
environment:
- DISPLAY_ORIENTATION=left
- CURSOR=true
- DISPLAY_RESOLUTION=1480x320
- DISPLAY_RATE=30
balena-electron:
build: .
restart: always
privileged: true
depends_on:
- xserver
# network_mode: host
# ports:
# - 8080:8080
volumes:
# We will have access to the UNIX socket shared by xserver after it has started up.
- 'xserver-volume:/tmp/.X11-unix'
environment:
# We need to specify which display we want to use for the X server. :0 is the first display that we have plugged in. This because there is no default display specified.
- DISPLAY=:0
group_add:
- video
labels:
io.balena.features.dbus: 1
io.balena.features.kernel-modules: 1
[fisehara] When the service restarts, the display remains frozen at whatever frame the video was at, and the following error from the X11 service is logged:
(EE) xf86OpenConsole: Cannot open virtual console 3 (No such file or directory)
Adding /dev/tty3 to the devices section of the x11 service in my docker-compose.yml
Running an Electron App, I try to display a 4K video in kiosk mode.
Everything works for Full-HD videos, but unfortunately not for 4K video ! (i..e there is violett flickering all over when running the 4K video)
Here is what I tried within my Electron App:
start.sh File looks like this (with the Chromium flags set):
#!/bin/bash
value="./node_modules/.bin/electron dist/src/main.js --ignore-gpu-blacklist --enable-native-gpu-memory-buffers --enable-gpu-rasterization --no-sandbox"
echo "STARTING ELECTRON"
exec $value
I also tried the --disable-gpu
flag but without any change.
My Dockerfile.template looks as follows:
(please note the libraries 1mesa-utilsand
mesa-utils-extra` - without them no video is playing at all.... So I assume the two libraries are needed but could also be limited at 4K ????? Any hint appreciated !)
(and please also note that I set the ENV-variable DISPLAY
to :0
at the very bottom)
ARG NODEJS_VERSION="16"
# If we specify BALENA_MACHINE_NAME, when we do a 'balena push', it will automatically substitute the machine type into our variable, so that you can build it for more than one architecture.
FROM balenalib/%%BALENA_MACHINE_NAME%%-node:${NODEJS_VERSION}-run
RUN install_packages \
curl \
libasound2 \
libdrm2 \
libgbm1 \
libgdk-pixbuf2.0-0 \
libglib2.0-0 \
libgtk-3-0 \
libnss3 \
libx11-xcb1 \
libxss1 \
libxtst6 \
libgles2-mesa \
libxshmfence1 \
mesa-utils \
mesa-utils-extra
WORKDIR /opt
RUN curl -skL https://raw.githubusercontent.com/balenablocks/audio/master/scripts/alsa-bridge/debian-setup.sh | sh
# Copy package files
COPY package.json yarn.lock /opt/
# Install node dependencies
RUN JOBS=MAX yarn install --unsafe-perm --production && yarn cache clean --force && rm -rf /root/.cache/*
# Now that we are done NPM installing, copy everything else
COPY . /opt/
COPY ./src /opt/
RUN yarn build
COPY ./dist /opt/
# We are running our entrypoint commands through the start.sh script, because we need to do a couple more things outside of just run electron
CMD ["bash", "/opt/start.sh"]
ENV NODE_ENV=production \
# this is specific for balena, to let the startup script know we want to use all udev devices (mouse, keyboard, etc)
UDEV=1 \
# this is very important, we need to tell our environment that we are going to talk to display 0, which is hosted by the xserver block
DISPLAY=:0
Inside my Electron App I use an index.html
file that shows the video as follows:
<body style="overflow-y: hidden; overflow-x: hidden">
<video autoplay loop id="video">
<source id="video-src" />
</video>
<script src="./dist/src/renderer.js"></script>
</body>
My docker-compose.yml file looks as follows:
version: "2.1"
volumes:
# we create a shared volume so that the xserver can mount its socket file, and our application container will be able to use it to display
xserver-volume:
services:
audio:
image: bh.cr/my_images/trihow-audio
privileged: true
ports:
- 4317:4317 # Only required if using PA over TCP socket
labels:
io.balena.features.dbus: "1"
io.balena.features.kernel-modules: "1"
environment:
- DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket
- AUDIO_OUTPUT=alsa_output.hda-intel.hdmi-stereo
wifi-connect:
image: balenablocks/wifi-connect:amd64
restart: always
network_mode: host
privileged: true
labels:
io.balena.features.dbus: "1"
io.balena.features.firmware: "1"
# environment:
# - DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket
# somehow you can't connect with a custom name
# - PORTAL_SSID=Trihow Player
xserver:
image: balenablocks/xserver
restart: always
privileged: true
volumes:
# when we start, a UNIX socket is mounted in this directory, for communication to the X server
- xserver-volume:/tmp/.X11-unix
sensor-box:
build: trimini_sensorbox
restart: always
privileged: true
custom-player:
depends_on:
# - audio
- xserver
build: .
labels:
io.balena.features.dbus: "1"
restart: always
privileged: true
volumes:
# We will have access to the UNIX socket shared by xserver after it has started up.
- xserver-volume:/tmp/.X11-unix
environment:
# We need to specify which display we want to use for the X server. :0 is the first display that we have plugged in. This because there is no default display specified.
- DISPLAY=:0
- CURSOR=false
- PULSE_SERVER=tcp:audio:4317
- PULSE_SINK=alsa_output.hda-intel.hdmi-stereo
Sometimes if you are unit testing, or don't have a monitor physically plugged into a machine you will need to use a virtual framebuffer to simulate a real display environment. We should discuss the option of having a VIRTUAL=true
flag that would start the container up with xvfb
instead of running xorg.
I tried to change the xserver service in my Balena project from balenablocks
to balenalabs
.
Is it correct that balenalabs
is newer than balenablocks
? Or which one do you recommend ?
The following error occurs when trying to go from balenablocks
to balenalabs
version of xserver:
Before, I had the following inside the docker-compose.yml
File:
xserver:
image: balenablocks/xserver
restart: always
privileged: true
labels:
io.balena.features.dbus: "1"
volumes:
# when we start, a UNIX socket is mounted in this directory, for communication to the X server
- xserver-volume:/tmp/.X11-unix
For the above, everything works and I can push to the Balena fleet without problems.
However, if I exchange the balenablocks/xserver
with bh.cr/balenalabs/xserver-amd64
, such as:
xserver:
image: bh.cr/balenalabs/xserver-amd64
restart: always
privileged: true
labels:
io.balena.features.dbus: "1"
volumes:
# when we start, a UNIX socket is mounted in this directory, for communication to the X server
- xserver-volume:/tmp/.X11-unix
Then I get the following error message when trying to push to the balena fleet :
[Success] Successfully uploaded images
[Error] Some services failed to build:
[Error] Service: xserver
[Error] Error: (HTTP code 404) unexpected - pull access denied for bh.cr/balenalabs/xserver-amd64, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
[Info] Built on x64_01
[Error] Not deploying release.
Remote build failed
I also tried image: bh.cr/balenalabs/xserver
(i.e. without the -amd64
). But did not help, same error !!!
Then I tried to upload my own custom Balena Block from a cloned xserver instance. It did it. It worked and under Balena Blocks I find my own custom Block:
Inside the docker-compose.yml
File, I exchanged to now take my custom Block, such as:
image: bh.cr/<slug_name>/xserver
or also:
image: bh.cr/<slug_name>/xserver-adm64
It did not work !!!!!!!
Again, when trying to push my project to the fleet, I end up once more with the exact same error message:
[Success] Successfully uploaded images
[Error] Some services failed to build:
[Error] Service: xserver
[Error] Error: (HTTP code 404) unexpected - pull access denied for bh.cr/balenalabs/xserver-amd64, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
[Info] Built on x64_01
[Error] Not deploying release.
Remote build failed
What do I need to do ?
Which of the two xserver possibilities do you recommend ? (i.e. balenablocks/xserver or balenalabs/xserver ??)
I have researched and the rotate left and right transform matrix coordinates are backwards
see: https://gist.github.com/rubo77/daa262e0229f6e398766 in which he shows a good example
I was trying to use the block with a busybox base image. It seems the group video
is not present or the GID doesnt match.
Not sure how to enforce this
When using the CURSOR
environment variable is set to false
or true
the cursor is still showing on the screen.
It seems that the xserver's xinitrc
is not loaded correctly.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.