GUI / Xinit problems

Hello Resin Team and Docker Friends,

I am currently working on a project which involves a Python GUI which needs to be feed from a Docker Container to an HDMI screen, getting input from Mouse and Keyboard - using the current ResinOS as a local install (so the current resinOS 2.0.0+rev3.dev for RPi3). There are some projects which do the same and I found here, namely:



As I do try to make an small, reusable (for different projects :)) and somehow reliable working solution, I went with https://github.com/pcarranzav/resin-electron-app as a starting point and created following scripts based on the code shown there:

The Dockerfile contains additional stuff like using the current jessie Image from resin, the only thing I changed was adding the cross-build stuff which the resin Team described, so that I can let this image build on hub.docker.com :).

In my example, I launched gedit in the end through launch_app.sh - but - most of the time, this does not work correctly: It does only grab keyboard/mouse input from time to time. Any ideas on how to improve the code and make it work more reliable? (If I try to run it with docker run nmaas87/docker-raspbian_xinit:latest it does not work at all - only pushing it via rdt somehow works…)

Thanks a lot!

Hi, checking it out if we can see anything obviously wrong.
In general you will have to look at the logs, if possible, see what’s in dmesg, etc.

Sorry, this is not very clear. Where do you run it like that? On your local, not Raspberry Pi machine? Or otherwise?

I try to run it on my RPi 3 with latest resinOS :). Using the locally attached keyboard and mouse on that device. Thanks a lot :slight_smile:

OK I got some new info.

I can now run the container directly from the RPi 3 via following command:

docker run --privileged nmaas87/docker-raspbian_xinit:latest

It did not work because I forgot about privileged mode :frowning:. However, still no Mouse and Keyboard - even if I mount the whole /dev/ directory to the folder (only for debug purposes ;)).

I can also use rdt to push the container, but I need to remove the cross-build-start and end before pushing from the Dockerfile - which is clear, otherwise the container would try to build itself on the ARM Hardware waiting for some x64 system… ( https://github.com/nmaas87/docker-raspbian_xinit/blob/master/xinit_latest/Dockerfile ). I did also remove -use_cursor no from https://github.com/nmaas87/docker-raspbian_xinit/blob/master/xinit_latest/src/launch_app.sh to be sure that the windowmanager would be able to use the cursor - but in fact, no matter if I enable or disable it or remove it, the cursor is visible. If I remove it from the config, I get a small black box in the left (0,0) coordinate. But nothing else changes.

maas@Munin:~/Schreibtisch/docker-raspbian_xinit/xinit_latest$ sudo rdt push 192.168.4.74 -s . -n gui
* Building..
- Stopping and Removing any previous 'gui' container
- Building new 'gui' image
Step 1 : FROM nmaas87/docker-raspbian_qemu:latest
 ---> 4073f3881ae6
Step 2 : MAINTAINER Nico Maas <mail@nico-maas.de>
 ---> Using cache
 ---> da972a7dd2ba
Step 3 : ENV DEBIAN_FRONTEND noninteractive
 ---> Using cache
 ---> 87c41703e1f4
Step 4 : RUN apt-get update     && apt-get install -yq --no-install-recommends         alsa-utils         xinput-calibrator         autoconf         build-essential         git         openssh-server         xserver-xorg-core         xorg         libgtk2.0-0         libnotify4         libgconf2-4         libnss3         libasound2         matchbox         sudo         locales         whois         gedit     && apt-get autoremove -qqy     && apt-get autoclean -y     && apt-get clean && rm -rf /var/lib/apt/lists/* && mkdir /var/lib/apt/lists/partial     && mkdir /var/run/sshd     && echo 'root:resin' | chpasswd     && sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config     && sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
 ---> Using cache
 ---> 78148d6cf14d
Step 5 : RUN touch /usr/share/locale/locale.alias   && sed -i "s/^#\ \+\(de_DE.UTF-8\)/\1/" /etc/locale.gen   && locale-gen de_DE de_DE.UTF-8
 ---> Using cache
 ---> ef485e0541b1
Step 6 : ENV LANG de_DE.UTF-8 LC_ALL de_DE.UTF-8 LANGUAGE de_DE:de
 ---> Using cache
 ---> 3ff6e5ab0b8d
Step 7 : RUN useradd   --groups=sudo   --create-home   --home-dir=/home/pi   --shell=/bin/bash   --password=$(mkpasswd pi)   pi   && sed -i '/%sudo[[:space:]]/ s/ALL[[:space:]]*$/NOPASSWD:ALL/' /etc/sudoers
 ---> Running in cebaee0dd6b4
 ---> 20b64f700075
Removing intermediate container cebaee0dd6b4
Step 8 : RUN mkdir -p /usr/src/app && ln -s /usr/src/app /app
 ---> Running in a8ef9665e9e8
 ---> 478211144810
Removing intermediate container a8ef9665e9e8
Step 9 : WORKDIR /usr/src/app
 ---> Running in 07dd70dc0212
 ---> 598c4d8c6217
Removing intermediate container 07dd70dc0212
Step 10 : COPY src /usr/src/app
 ---> ddacff36f29c
Removing intermediate container ff03e44a7f19
Step 11 : COPY src/start.sh /start.sh
 ---> f7f437de82a8
Removing intermediate container 674258f8bdf1
Step 12 : CMD bash /start.sh
 ---> Running in 1a475702fdf8
 ---> ccdb0245a189
Removing intermediate container 1a475702fdf8
Successfully built ccdb0245a189
- Creating 'gui' container
- Starting 'gui' container

rdt push completed successfully!
* Streaming application logs..
Invalid card number.
2Usage: amixer <options> [command]

Available options:
  -h,--help       this help
  -c,--card N     select the card
  -D,--device N   select the device, default 'default'
  -d,--debug      debug mode
  -n,--nocheck    do not perform range checking
  -v,--version    print version of this program
  -q,--quiet      be quiet
  -i,--inactive   show also inactive controls
  -a,--abstract L select abstraction level (none or basic)
  -s,--stdin      Read and execute commands from stdin sequentially
  -R,--raw-volume Use the raw value (default)
  -M,--mapped-volume Use the mapped volume

Available commands:
  scontrols       show all mixer simple controls
  scontents	  show contents of all mixer simple controls (default command)
  sset sID P      set contents for one mixer simple control
  sget sID        get contents for one mixer simple control
  controls        show all controls for given card
  contents        show contents of all controls for given card
  cset cID P      set control contents for one control
  cget cID        get control contents for one control
2Usage: amixer <options> [command]

Available options:
  -h,--help       this help
  -c,--card N     select the card
  -D,--device N   select the device, default 'default'
  -d,--debug      debug mode
  -n,--nocheck    do not perform range checking
  -v,--version    print version of this program
  -q,--quiet      be quiet
  -i,--inactive   show also inactive controls
  -a,--abstract L select abstraction level (none or basic)
  -s,--stdin      Read and execute commands from stdin sequentially
  -R,--raw-volume Use the raw value (default)
  -M,--mapped-volume Use the mapped volume

Available commands:
  scontrols       show all mixer simple controls
  scontents	  show contents of all mixer simple controls (default command)
  sset sID P      set contents for one mixer simple control
  sget sID        get contents for one mixer simple control
  controls        show all controls for given card
  contents        show contents of all controls for given card
  cset cID P      set control contents for one control
  cget cID        get control contents for one control
Invalid card number.


X.Org X Server 1.18.4
Release Date: 2016-07-19
"X Protocol Version 11, Revision 0
9Build Operating System: Linux 4.4.26-v7+ armv7l Raspbian
XCurrent Operating System: Linux resin 4.4.48 #2 SMP Thu Apr 13 05:03:46 UTC 2017 armv7l
Kernel command line: �8250.nr_uarts=1 dma.dmachans=0x7f35 bcm2708_fb.fbwidth=1280 bcm2708_fb.fbheight=1024 bcm2709.boardrev=0xa02082 bcm2709.serial=0xf2ef8db0 smsc95xx.macaddr=B8:27:EB:EF:8D:B0 bcm2708_fb.fbdepth=16 bcm2708_fb.fbswap=1 bcm2709.uart_clock=4800000P0 vc_mem.mem_base=0x3ea00000 vc_mem.mem_size=0x3f000000  dwc_otg.lpm_enable=0 coMnsole=tty1 console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
)Build Date: 11 November 2016  11:59:59AM
>xorg-server 2:1.18.4-2+rpi1 (https://www.debian.org/support) 
"Current version of pixman: 0.33.3
d	Before reporting problems, check http://wiki.x.org
	to make sure that you have the latest version.
Markers: (--) probed, .(**) from config file, (==) default setting,
	%(++) from command line, (!!) notice, E(II) informational,
	(WW) warning, (EE) error, (NI) not implemented, S(??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Mon May  1 15:58:02 2017
@(==) Using system config directory "/usr/share/X11/xorg.conf.d"
*modprobe: FATAL: Module g2d_23 not found.
}
** (gedit:35): WARNING **: Could not load Gedit repository: Typelib file for namespace 'GtkSource', version '3.0' not found
�
(gedit:35): dconf-WARNING **: failed to commit changes to dconf: Failed to execute child process "dbus-launch" (No such file or directory)
�
(gedit:35): dconf-WARNING **: failed to commit changes to dconf: Failed to execute child process "dbus-launch" (No such file or directory)

However, no mouse/keyboard support either and - as with the direct approach. And it feels like gedit seems to die after 10 cursor blinks or so (the textcursor stops blinking after about 10 blinks or so…)

First things first: managed to make your setup work, seems like you are missing some dependencies.

First I’ve installed xinput to see what devices were available in the system, and no real device was (running xinput -list after the X server started):

⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]

Then after installing evtest to see input events, it probably pulled in enough dependencies, and now my mouse and keyboard shows up:

⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ MOSART Semi. 2.4G Wireless Mouse        	id=8	[slave  pointer  (2)]
⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
    ↳ USB Keyboard                            	id=7	[slave  keyboard (3)]
    ↳ USB Keyboard                            	id=6	[slave  keyboard (3)]

And gedit worked:

In these kinds of situations, it helps to have as many tools to debug as possible.

Hope this will help to get ahead with your project!

1 Like

Thank you @imrehg, that is awesome news.
However, I could sadly not reproduce your success.
I did install xinput and evtest into the image and started xinput -list, which only showed “no available xserver”, while evtest showed my keyboard. gedit did not work. Could you please edit my Dockerfile, so that I could rebuild my image from scratch and had a “known good” starting point? Somehow i’m missing something here…

Thanks a lot!

You have to run that command from within the area of xinit (that is in launch_app.sh in your setup), as all other X commands to talk to the server.

Thank you @imrehg, I could get it working now. Key was to really start the INITSYSTEM and start the start.sh not via CMD, but via an systemd service. From that moment on, the GUI could launch gedit and the needed services - which were - so it seems like you found out - missing some dependencies. Thank you very much for your help :)!

:tada: Glad to hear it works, and keep us posted about your project! :smiley:

Thank you, I am making good progress and maybe get around to make a little tutorial on how to build such appliances with resin/resinOS in form a blogpost today :slight_smile: - maybe I can apply with that for blog4swag and help other people with similiar problems out :)! and now gets to work on that :wink:

That sounds great, looking forward to it! And yeah, #blog4swag it :wink:

1 Like

Thank you very much, I just got it working and blogged it! :smile:

1 Like