Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pi Zero 2 W - Not launching browser on boot #29

Open
daylemur opened this issue Jul 31, 2024 · 18 comments
Open

Pi Zero 2 W - Not launching browser on boot #29

daylemur opened this issue Jul 31, 2024 · 18 comments
Labels
wontfix This will not be worked on

Comments

@daylemur
Copy link

I have followed all of the setup steps multiple times, and tried with multiple different installations of RaspOS (32bit, 64bit, Legacy, etc) and none seem to want to launch the browser once the system is running. The install script runs without any issues, and I am able to access the dashboard, update the piosk URLs and apply the changes to the Pi.

@debloper
Copy link
Owner

What happens if you reboot after the installation?

Also (if rebooting didn't work) after the reboot, can you please run these following scripts and post the output?

$ # run as the same user that set up PiOSK
$ less $HOME/.config/wayfire.ini
$ ps aux | grep piosk
$ ps aux | grep chrom
$ journalctl -fb

All of this assumes that you are using PiOS with wayland+wayfire (latest bookworm build with graphical user interface) & ran the script as the same user that the desktop is auto logging-in to.

@debloper debloper added the question Further information is requested label Jul 31, 2024
@MBennin
Copy link

MBennin commented Aug 10, 2024

I am also experiencing issues getting the kiosk to display. The desktop loads up correctly and I can access the webpage at the pi's ip address.

I am using a Raspberry Pi Zero 2W, RaspOS 32bit Full, with this screen.

Output from the above commands:

$ less $HOME/.config/wayfire.ini
[autostart]
browser = /home/mbennin/piosk/scripts/browser.sh
switcher = bash /home/mbennin/piosk/scripts/switcher.sh
/home/mbennin/.config/wayfire.ini (END)

$ ps aux | grep piosk
mbennin 1508 0.0 0.4 7532 1792 pts/0 S+ 04:36 0:00 grep --color=auto piosk

$ ps aux | grep chrom
mbennin 1510 0.0 0.4 7532 1792 pts/0 S+ 04:36 0:00 grep --color=auto chrom

journalctl -fb
Aug 10 04:31:01 pi-kiosk systemd[1]: fstrim.service: Deactivated successfully.
Aug 10 04:31:01 pi-kiosk systemd[1]: Finished fstrim.service - Discard unused blocks on filesystems from /etc/fstab.
Aug 10 04:35:01 pi-kiosk PackageKit[1275]: daemon quit
Aug 10 04:35:01 pi-kiosk systemd[1]: packagekit.service: Deactivated successfully.
Aug 10 04:35:01 pi-kiosk systemd[1]: packagekit.service: Consumed 14.742s CPU time.
Aug 10 04:35:08 pi-kiosk sshd[1487]: Accepted password for mbennin from 192.168.0.192 port 55169 ssh2
Aug 10 04:35:08 pi-kiosk sshd[1487]: pam_unix(sshd:session): session opened for user mbennin(uid=1000) by (uid=0)
Aug 10 04:35:08 pi-kiosk systemd-logind[451]: New session 4 of user mbennin.
Aug 10 04:35:08 pi-kiosk systemd[1]: Started session-4.scope - Session 4 of User mbennin.
Aug 10 04:35:09 pi-kiosk sshd[1487]: pam_env(sshd:session): deprecated reading of user environment enable

@debloper
Copy link
Owner

Thanks @MBennin this is super helpful!

$ ps aux | grep piosk
mbennin 1508 0.0 0.4 7532 1792 pts/0 S+ 04:36 0:00 grep --color=auto piosk

$ ps aux | grep chrom
mbennin 1510 0.0 0.4 7532 1792 pts/0 S+ 04:36 0:00 grep --color=auto chrom

This tells us that neither of the the processes (the chrome browser, or the wtype tab switcher) are running (except for the process that you're querying it with, i.e. grep which doesn't count).

As the next step, what happens if you open up a terminal (in desktop mode, not over SSH), and run the following:

# the args don't have to be broken into new lines, it's just for better readability
# here's the actual script: https://github.com/debloper/piosk/blob/main/scripts/browser.sh
chromium-browser \
  https://google.com/ \
  --kiosk \
  --fast \
  --fast-start \
  --no-first-run \
  --noerrdialogs \
  --disable-infobars \
  --ozone-platform=wayland \
  --enable-features=OverlayScrollbar \
  --enable-accelerated-video-decode \
  --enable-gpu-rasterization \
  --enable-oop-rasterization \
  --ignore-gpu-blocklist \
  --disable-smooth-scrolling \
  --disable-low-res-tiling \
  --enable-low-end-device-mode \
  --disable-composited-antialiasing \
  --start-maximized

I don't see why this won't run as it's clearly set up in the wayfire config (unless Wayfire on startup is expected to work differently on Pi Zero 2 W). And I don't see any eyebrow-raisers on the journal either.

This might need a deeper dive (and not just for PiOSK). Anyone stumbling across this issue, please post your anecdotes/experiences/findings, so it helps to piece together the puzzle.

@MBennin
Copy link

MBennin commented Aug 12, 2024

I got the following output from the above command:

[1472:1472:0812/011129.373693:ERROR:wayland_connection.cc(197)] Failed to connect to Wayland display: No such file or directory (2)
[1472:1472:0812/011129.379277:ERROR:ozone_platform_wayland.cc(265)] Failed to initialize Wayland platform
[1472:1472:0812/011129.379345:ERROR:env.cc(258)] The platform failed to initialize. Exiting.

I made sure to enable wayland from raspi-config, so I'm not sure why it can't connect to the display.

@debloper
Copy link
Owner

After looking into it for a bit, found out that Wayland is disabled on older SoCs. Seems like an imposed restriction (not a technical limitation).

Can you please try this workaround:

you can get it working by adding wayland=on to the end of the /boot/firmware/cmdline.txt file — OP on RPi Forum

Thanks for the help to get to the bottom of this. I'd update the docs to reflect it.

@debloper debloper added wontfix This will not be worked on and removed question Further information is requested labels Aug 12, 2024
@rsponar
Copy link

rsponar commented Aug 21, 2024

I have the same issue on my Raspberry Pi zero 2W, adding wayland=on to /boot/firmware/cmdline.txt did not fix this, exact same error messages as @MBennin

@Timmwardion
Copy link

Timmwardion commented Sep 7, 2024

I was having the exact same issues as above (w RPi3). I ran ~/piosk/scripts/browser.sh and got the below:

[1677:1677:0907/232210.085750:ERROR:wayland_connection.cc(197)] Failed to connect to Wayland display: No such file or directory (2)
[1677:1677:0907/232210.090904:ERROR:ozone_platform_wayland.cc(265)] Failed to initialize Wayland platform
[1677:1677:0907/232210.090963:ERROR:env.cc(258)] The platform failed to initialize.  Exiting.

After a bit of investigation I found that Wayland doesn't work on the RPi3 without 'wayland=on' in /boot/firmware/cmdline.txt

So I added that, rebooted, and Bam! Success.

Note: I should highlight that it's REALLY sluggish. Will likely swap the Pi3 out for a Pi4B tomorrow. No such thing as overkill :-)

@male-zvire
Copy link

I have same issue with Rpi zero 2W... "wayland=on" in cmdline.txt helps, partly. Now, i need to confirm this window before browser starts.
PXL_20241101_161448838

@andiohn
Copy link

andiohn commented Nov 29, 2024

It's in the browser scripts I think. I found this. I'm looking: https://issues.chromium.org/issues/373891800

@andiohn
Copy link

andiohn commented Nov 29, 2024

Apparently --no-memcheck should fix it according to the /usr/bin/chromium-browser script

@andiohn
Copy link

andiohn commented Nov 29, 2024

Didn't work. I added that to the browser.sh script and it still prompted me

@andiohn
Copy link

andiohn commented Nov 29, 2024

Doesn't look like it's using the startup flags because the 'restore' shows too, so I think the usr bin will have to be modified or something.

@f1nch87
Copy link

f1nch87 commented Dec 7, 2024

Sound promising for me just baught two raspi zero 2w 😄

@male-zvire
Copy link

Just delete
screenshot 93
this section from chromium launch script
But dont use lot of javascript 😉 Zero 2 isn't strongman...

@arqtv
Copy link

arqtv commented Dec 8, 2024

Remote browser (Chrome on OSX 10.13.6) not opening PIOSK web page on remote PIOSK target. Made all checks noted in this thread and get what I think are correct responses - see below. I have checked to see what ports are open on the remote PIOSK and only see port 22 and not port 80. I can ssh into PIOSK IP but browsing to the same local IP gives me a "This site can't be reached - unexpectedly closed by remote host". Both PIOSK and MAC are on same wifi network.

I have a hdmi monitor, keyboard and mouse connected to the target PIOSK which is a Pi3A+ running fresh and clean 32 bit Bookworm with Wayland/wayfire. Desktop loads but nothing else.

Running /scripts/browser.sh directly on the target spawns an error message
ERROR: wayland_connection.cc(205)] Failed to connect to Wayland display: No such fie or directory.
ERROR: ozone_platform_wayland.cc(264) Failed to initialize Wayland platform

But opening the browser first and then repeating the script command brings up the browser with several tabs that do eventually load. Remote browsing is however still not working. Connection is refused, due to no web server running and port 80 not open.

piosk@piosk:~ /piosk/$ ./scripts/browser.sh
Opening in existing browser session.

Results obtained using ssh to target
piosk@piosk:~ $ cat .config/wayfire.ini
[autostart]
browser = /home/piosk/piosk/scripts/browser.sh
switcher = bash /home/piosk/piosk/scripts/switcher.sh

piosk@piosk:~ $ ps aux | grep chrom
piosk 1595 0.0 0.4 7532 1792 pts/0 S+ 15:24 0:00 grep --color=auto chrom

piosk@piosk:~ $ ps aux | grep piosk
avahi 401 0.0 0.6 6408 2816 ? Ss 14:37 0:00 avahi-daemon: running [piosk.local]
piosk 750 0.0 1.6 16540 7040 ? Ss 14:37 0:00 /lib/systemd/systemd --user
piosk 751 0.0 0.5 36384 2488 ? S 14:37 0:00 (sd-pam)
piosk 766 0.0 1.4 43140 6272 ? S<sl 14:37 0:00 /usr/bin/pipewire
piosk 767 0.0 0.6 22112 2944 ? Ssl 14:37 0:00 /usr/bin/pipewire -c filter-chain.conf
piosk 768 0.0 3.0 121404 13484 ? S<sl 14:37 0:00 /usr/bin/wireplumber
piosk 769 0.0 1.2 35852 5376 ? S<sl 14:37 0:00 /usr/bin/pipewire-pulse
piosk 770 0.0 0.5 8588 2560 tty1 S+ 14:37 0:00 -bash
piosk 772 0.0 0.7 7496 3456 ? Ss 14:37 0:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
piosk 825 0.0 1.3 43304 5760 ? Ssl 14:37 0:00 /usr/libexec/xdg-permission-store
piosk 838 0.0 1.9 56704 8320 ? Ssl 14:37 0:00 /usr/bin/lxsession -s LXDE-pi -e LXDE
piosk 887 0.0 0.2 6196 1276 ? Ss 14:37 0:00 /usr/bin/ssh-agent /usr/bin/startlxde-pi
piosk 932 0.0 1.4 44308 6144 ? Ssl 14:37 0:00 /usr/libexec/gvfsd
piosk 937 0.0 1.1 56580 5120 ? Sl 14:37 0:00 /usr/libexec/gvfsd-fuse /run/user/1000/gvfs -f
piosk 947 0.0 2.9 89580 12672 ? S 14:37 0:01 openbox --config-file /home/piosk/.config/openbox/lxde-pi-rc.xml
piosk 950 0.0 1.9 49676 8320 ? Sl 14:37 0:00 lxpolkit
piosk 952 0.2 10.6 399424 46460 ? Sl 14:37 0:06 lxpanel --profile LXDE-pi
piosk 954 0.0 11.9 352776 52180 ? Sl 14:37 0:02 pcmanfm --desktop --profile LXDE-pi
piosk 971 0.0 0.2 6196 1148 ? Ss 14:37 0:00 /usr/bin/ssh-agent -s
piosk 979 0.0 0.9 14200 4096 ? S 14:37 0:00 systemd-inhibit --what=handle-power-key gtk-nop
piosk 982 0.0 0.5 4960 2304 ? S 14:37 0:00 xcompmgr -aR
piosk 993 0.0 5.1 225600 22268 ? S 14:37 0:00 gtk-nop
piosk 1027 0.0 2.3 93012 10112 ? Ssl 14:37 0:00 /usr/libexec/gvfs-udisks2-volume-monitor
piosk 1031 0.0 1.2 26784 5248 ? Sl 14:37 0:00 /usr/lib/menu-cache/menu-cached /run/user/1000/menu-cached-:0
piosk 1039 0.0 1.2 40616 5632 ? Ssl 14:37 0:00 /usr/libexec/gvfs-goa-volume-monitor
piosk 1043 0.0 1.2 40552 5504 ? Ssl 14:37 0:00 /usr/libexec/gvfs-mtp-volume-monitor
piosk 1047 0.0 1.2 41616 5632 ? Ssl 14:37 0:00 /usr/libexec/gvfs-gphoto2-volume-monitor
piosk 1051 0.0 1.4 54108 6144 ? Ssl 14:37 0:00 /usr/libexec/gvfs-afc-volume-monitor
piosk 1057 0.0 1.5 53788 6912 ? Sl 14:37 0:00 /usr/libexec/gvfsd-trash --spawner :1.13 /org/gtk/gvfs/exec_spaw/0
piosk 1456 2.5 7.8 128448 34164 ? Sl 14:38 1:12 lxterminal
piosk 1502 0.0 0.8 8596 3840 pts/1 Ss 14:43 0:00 bash
piosk 1505 4.0 0.8 8656 3712 pts/1 S+ 14:43 1:42 htop
piosk 1510 0.0 0.9 8596 3968 pts/2 Ss+ 14:46 0:00 bash
root 1563 0.0 1.9 14816 8704 ? Ss 15:22 0:00 sshd: piosk [priv]
piosk 1570 0.0 1.4 15076 6356 ? S 15:22 0:00 sshd: piosk@pts/0
piosk 1571 0.1 0.9 8584 3968 pts/0 Ss 15:22 0:00 -bash
piosk 1597 300 0.9 11864 4224 pts/0 R+ 15:25 0:00 ps aux
piosk 1598 0.0 0.4 7532 1792 pts/0 S+ 15:25 0:00 grep --color=auto piosk

piosk@piosk:~ $ journalctl -fb
Dec 08 15:22:13 piosk sshd[1563]: pam_unix(sshd:session): session opened for user piosk(uid=1000) by (uid=0)
Dec 08 15:22:13 piosk systemd-logind[452]: New session 5 of user piosk.
Dec 08 15:22:13 piosk systemd[1]: Started session-5.scope - Session 5 of User piosk.
Dec 08 15:22:13 piosk sshd[1563]: pam_env(sshd:session): deprecated reading of user environment enabled
Dec 08 15:23:45 piosk sudo[1587]: piosk : TTY=pts/0 ; PWD=/home/piosk ; USER=root ; COMMAND=/usr/bin/nano .config/wayfire.ini
Dec 08 15:23:45 piosk sudo[1587]: pam_unix(sudo:session): session opened for user root(uid=0) by piosk(uid=1000)
Dec 08 15:24:06 piosk sudo[1587]: pam_unix(sudo:session): session closed for user root
Dec 08 15:24:18 piosk sudo[1591]: piosk : TTY=pts/0 ; PWD=/home/piosk ; USER=root ; COMMAND=/usr/bin/nano .config/wayfire.ini
Dec 08 15:24:18 piosk sudo[1591]: pam_unix(sudo:session): session opened for user root(uid=0) by piosk(uid=1000)
Dec 08 15:24:22 piosk sudo[1591]: pam_unix(sudo:session): session closed for user root

Please advise what I should check further or how I should initialise the PIOSK web server?

@debloper
Copy link
Owner

debloper commented Dec 9, 2024

@arqtv I think you have 2 issues:

  1. You're likely on labwc compositor; follow this issue for workarounds.
  2. Open the port 80 to access the dashboard; check ufw or iptables docs for details.

@brimdor
Copy link

brimdor commented Dec 15, 2024

If Pi Zero W 2 is not an option due to incompatibility, I recommend removing from your description stating that RPi Zero W 2, Pi 4 and 5 are all compatible.

@SpiraMirabilis
Copy link

SpiraMirabilis commented Dec 17, 2024

The piosk needs to use systemd to manage its three scripts that are running.
I'm not really interested in actually submitting a PR but this is how you would do it:

Here is an example of a systemd service that should be used instead of the way piosk currently sets itself up to be autorun:

install in /etc/systemd/system/ and then run sudo systemctl daemon-reload, sudo systemctl enable piosk-browser and sudo systemctl start piosk-browser (repeat for other two)

piosk-browser.service

[Unit]
Description=Run piosk 'browser.sh' to launch chromium
After=default.target

[Service]
Type=simple
ExecStartPre=/usr/bin/sleep 5
ExecStart=/bin/bash /home/pi/piosk/scripts/browser.sh
WorkingDirectory=/home/pi
User=pi
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/pi/.Xauthority
Environment=XDG_RUNTIME_DIR=/run/user/1000
Restart=on-failure

[Install]
WantedBy=graphical.target


Note that it has a small sleep delay before the service fires, and it depends on graphical.target so it will launch (with a delay) after the GUI comes up, and it hijacks the pi user's environmental variables for the X display adapter. Note that this will only work if the user is named "pi".

If you configured the raspberry pi user with a different username then you'd have to adjust this. The savvy developer could include these three files as a template in the install script and then use sed to add in the actual user name so that it would always work.

You'd need a seperate version of this for the switcher.sh and also one to run the index.js if you wanted it to switch tabs and have the webserver running, here are the ones I used:

piosk-switcher.service

[Unit]
Description=Run piosk 'switcher.sh' to switch tabs
#After=piosk-browser.service
#Requires=piosk-browser.service

[Service]
Type=simple
ExecStartPre=/usr/bin/sleep 30
ExecStart=/bin/bash /home/pi/piosk/scripts/switcher.sh
WorkingDirectory=/home/pi
User=pi
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/pi/.Xauthority
Environment=XDG_RUNTIME_DIR=/run/user/1000
Restart=on-failure
RestartSec=5

[Install]
WantedBy=graphical.target


piosk-webserver.service

[Unit]
Description=Run piosk webserver

[Service]
Type=simple
ExecStartPre=/usr/bin/sleep 5
ExecStart=/usr/bin/node /home/pi/piosk/index.js
WorkingDirectory=/home/pi/piosk
User=root
Restart=on-failure

[Install]
WantedBy=graphical.target


Ideally you should have three of these, including one to run your index.js. Putting things in rc.local is ugly, there is no functionality to restart it if it fails and a bunch of other things.

This will solve the "after X hours the piosk stops switching tabs" issue which is undoubtedly the switcher.sh script failing for some random reason or another, but systemd will automatically restart it as long as "browser.sh" is running.

Edit: I removed the After/Requires section in piosk-switcher.service as this seems to get hung up on boot often and just replaced it with a 30 second delay and hoping for the best, which seems to work well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests