I am running a PoC to realize the possibility on use Balena to deploy our experience to our clients around the world.
I am using the electron block to run our electron app on an intel NUC. We are using 4K LG TVs and displax touch films.
However, I am not able to get touch fil working on the setup.
I run a similar PoC in the past using the browser block and I was able to use the same touch film, but regarding the electron block, I found no information on this. Can someone please point me out where should I start looking?
I was taking a look to see if I could find some previous information that could help, but without success. Could you share with us the part of the docker-compose file referencing the electron block? Also, can you share the balenaOS version you are using? Finally, if you can share other OS versions where you got it working, so we can check the differences in modules that´d be great.
It is running on balenaOS 2.83.18+rev1. I did tests in the past using the browser block and the same hardware (NUC+TV+Touch film) and I managed to use the touch film with that block.
Also in parallel testing, I was able to use this touch in other OS such as UC version 20220114.
Please let me know if I misunderstood any question,
Thanks once again,
I currently have a device running the browser block where the touch is being used. it is on balenaOS 2.83.18+rev1. It is the same version as the one used in electron tests;
Dockerfile - I the first part of the dockerfile we build our electron app and include all our internal dependencies. Then, based on the repo sample app we copy the required files from the intermediate container into usr/src/app. It took a while to us to be able to run it.
FROM balenablocks/amd64-balena-electron-env:v1.2.10
RUN mkdir -p /etc/X11/xorg.conf.d
COPY ./packages/electron/touch-rotation.conf /etc/X11/xorg.conf.d/touch-rotation.conf
WORKDIR /usr/src/app
COPY --from=intermediate /cd-core/packages/electron/es/ ./
COPY --from=intermediate /cd-core/packages/electron/package-balena.json ./package.json
COPY --from=intermediate /cd-core/packages/electron/index.js ./
RUN npm i
RUN npm i electron
xserver part of the docker-compose - there is non. Maybe that’s the problem
Block repo - Yes, I am using this repo. Also, I recently open an issue in the repo regarding a problem I experiencied.
You might want to try this example to see if you get the basic setup working.
Also, here you can find an interesting explanation of why it is interesting to separate the different blocks, and it may help to figure out where you are having issues.
One good thing about your answer about the OS version you were running the touch succesfully with the browser block, is that we can discard a problem with the module that is serving the touch functionality. It looks like you are having an issue with the configuration.
Let me know how it goes.
Hello @rmorillo24,
After a couple of testing, I was able to run the xserver and electron blocs together and have the touch-enabled on the electron block.
However, I lost the capability to use envVars to apply electron block configurations (like screen rotation for instance). I will share here my current configs:
Docker-compose:
version: '2.1'
volumes:
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'
cr-electron:
build:
context: ./
dockerfile: ./packages/electron/Dockerfile
restart: always
privileged: true
network_mode: host
ports:
- 8080:8080
volumes:
- 'xserver-volume:/tmp/.X11-unix'
depends_on:
- xserver
environment:
- DISPLAY=:0
- BALENAELECTRONJS_SCREENSAVER_DELAY_OVERRIDE='never'
- XRANDR_ARGS=-o right
Those last envVars are being ingored.
Dockerfile:
(...)
FROM balenablocks/amd64-balena-electron-env:v1.2.10
WORKDIR /usr/src/app
COPY --from=intermediate /cd-core/packages/electron/es/ ./
COPY --from=intermediate /cd-core/packages/electron/package-balena.json ./package.json
COPY --from=intermediate /cd-core/packages/electron/balena-start.sh ./balena-start.sh
COPY --from=intermediate /cd-core/packages/electron/index.js ./
RUN npm i
RUN npm i electron
CMD ["bash", "balena-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
balena-start.sh:
#!/usr/bin/env bash
# We are going to wait for the UNIX socket to be mounted before trying to start the application. This will prevent us from going into a crash loop before xserver is ready. See more info here: https://github.com/balenablocks/xserver#waiting-for-xserver-to-start
while [ ! -e /tmp/.X11-unix/X${DISPLAY#*:} ]; do sleep 0.5; done
# Run balena base image entrypoint script. We also specified UDEV=1 in the Dockerfile. This will allow udev devices (mouse, etc) to be mounted
/usr/bin/entry.sh echo "Running balena base image entrypoint..."
# This stops the CPU performance scaling down
echo "Setting CPU Scaling Governor to 'performance'"
echo 'performance' > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
# We are using root to run --no-sandbox for chrome, partially because of this issue: https://github.com/electron/electron/issues/17972
node_modules/.bin/electron --no-sandbox index.js
Any idea on what I am missing now?
Thanks once again,
If the variables are properly set in the container, but you can’t access them from that script, it means that the script is trying to access the variables before they are set.
Maybe you can try to modify the script so that you first set the variables, and then execute the script?
The xserver repo has an issue with the cursor. It is not possible to hide it toggling the env var.
I think it is because the env var value is hardcoded on the dockerfile.
Also looking into the repo issues it looks like it has been an issue since September.
Can we address this?
I ran into severe tearing problems using the electron and server with my app.
I moved to sway & wayland-based solution.
Also, I started building my own electron image.