30

I am automating a RPi for four displays at my company. I have them rebooting every day so the browser will refresh. I can't get the Restore pages? Chromium didn't shut down correctly bubble to not come up. I've tried several solutions that ive found online, but nothing works.

Ive added many switches such as --noerrdialogs --disable-session-crashed-bubble --disable-infobars --disable-restore-session-state --incognito

Ive also tried a couple of sed commands i found online.

Any help would be greatly appreciated.

11
  • 1
    Have you looked into properly shutting down chrome? Commented Jun 20, 2017 at 13:55
  • the reason I suggest this is it is treating the disease, not the side effects. Commented Jun 20, 2017 at 14:33
  • 2
    you can use javascript to refresh after a certain amount of time stackoverflow.com/questions/2787679/… you likely don't need to refresh every 5 seconds but the theory is the same. Commented Jun 20, 2017 at 15:48
  • 1
    In that case, I suggest you edit your question so it describes the problem not the symptom and asks for methods of solving the problem. Alternatively, you could delete this question and ask a new one. One important point is do you control the web pages? Commented Jun 20, 2017 at 16:21
  • 1
    Sounds like you're looking at a classic XY problem. You've effectively asked us, HELP! I don't know how to use the brake pedal so I stop my car by crashing the car into things. How do I disable the airbag? You need to focus on writing a webpage that does what you need it to do.
    – Jacobm001
    Commented Jun 20, 2017 at 18:08

9 Answers 9

36

I've got it! Use --app=your.url

For example:

chromium-browser --kiosk --app=http://your.url.here
5
  • 3
    the only thing that worked for me on my Pi Zero! Thank you
    – DarkCygnus
    Commented Oct 10, 2018 at 16:15
  • 1
    Where were you a year ago :)
    – uchuugaka
    Commented Dec 30, 2018 at 15:37
  • 2
    Seriously, this saved my irritiations with crashy chromium. thanks
    – uchuugaka
    Commented Dec 30, 2018 at 15:37
  • In case you are using offline mode with service worker, --app will break it.
    – David
    Commented Sep 30, 2020 at 11:19
  • This is the only thing that solved this issue with an older Pi3. Nothing else worked, including the answers that use sed below.
    – automaton
    Commented Nov 17, 2021 at 17:08
10

For those arriving here from Google:

The best way to now perform this task, without having to use incognito, is to adjust two settings in the Chromium preferences. They are:

  • exited_cleanly
  • exit_type

From what I have gathered from personal tests, just changing the "exited_cleanly" setting may not always work at preventing the Chromium prompt on startup. Other flags such as -disable-infobars will also not work.

To adjust these settings, please add the following in your startup file, before launching Chromium (depending on how you have set up Chromium to automatically run in kiosk mode, this file can either be located at /etc/xdg/lxsession/LXDE-pi/autostart, /etc/xdg/openbox/autostart, ~/.Xsession, or another file, depending on what you have already installed).

sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/Default/Preferences
sed -i 's/"exit_type": "Crashed"/"exit_type": "Normal"/' ~/.config/chromium/Default/Preferences

For example, with my setup (using Xsession), the procedure would go as follows:

  1. Enter sudo nano ~/.Xsession into the console
  2. Insert the above 2 lines into the file, before Chromium is run (You should see a line starting with chromium-browser, so insert them above this)
  3. Press Ctrl + X to exit the file
  4. Type Y
  5. Press Enter
  6. Reboot the machine

Again, the file used to start up Chromium may be located in a different location, depending on how you have setup your Pi, but after changing these two settings, Chromium should start up without displaying the crashing prompt.

2
  • I'd like to use jq to achieve the same goal: jq '.profile.exit_type= "Normal" | .profile.exited_cleanly = true' ~pi/.config/chromium/Default/Preferences > ~pi/.config/chromium/Default/Preferences
    – Huan
    Commented Sep 2, 2020 at 17:40
  • Note that the sed script still works after one removes the spurious space in "exit_type": "Crashed". It should read "exit_type":"Crashed". I would edit the answer myself but StackExchange says I have to edit more than six characters, which is a silly restriction.
    – hackerb9
    Commented Oct 24, 2021 at 5:28
6

1) I dunno why --disable-infobars didn't work for you. This works well for me:

chromium-browser --kiosk --disable-infobars \
http://URL1 \
http://URL2 \
http://URL3

2) A better way to refresh the browser (contents) would be to sent it Control-R? e.g. in your browser startup script, do:

(while sleep 200; do xdotool key ctrl+R; done) &

(I also send ctrl+Tab to cycle through my multiple browser tabs

1
  • --disable-infobars doesnt work for you too, unless you still using a a old version of chrome. Commented Oct 29, 2020 at 20:18
6

I know this doesn't really solve the issue - but as a work-around - it did the trick for me.

I made sure Chrome was shut down cleanly... Opened terminal

cd .config/chromium/Default
chattr +i Preferences

This makes the file immutable... strictly read-only, Chrome can crash as much as it likes - it wont show the popup as the Preferences file can no longer be changed.

This setup works for me as the Pi config will not change - it's just displaying a web based app in kiosk mode.

1
  • Works in Linux Distros too... Note that there could be issues in Windows / WebDriver / Selenium as reported elsewhere
    – MarcoZen
    Commented Aug 21, 2018 at 13:42
3

To disable the Restore Pages bubble I open chromium twice in the autostart file like this:

chromium-browser --no-startup-window --kiosk
chromium-browser --noerrordialogs --kiosk http://your.url.here

The first one gets the popup bubble but you don't see it, then the second one opens as if browser was closed successfully. Probably not the cleanest way to do this, but it worked for me.

2
  • This method, although blunt, is the only answer on this page that works for me. I'm loading Chromium from Selenium, and I need to use a specific user profile with it. Quitting and reloading the browser via Selenium did the trick! Commented Aug 4, 2020 at 20:57
  • 1
    This is also the only method that worked for me. In my situation, I do not wish to use Kiosk mode, but this still seems to do the trick. Thanks for the idea! Commented Aug 25, 2021 at 0:11
2

I came up with a workaround that actually took care of several items at once.

vi restartscript.sh

#!/bin/sh
/usr/bin/killall chromium-browser
/usr/bin/apt-get update -y
/usr/bin/ apt-get upgrade -y
/sbin/reboot

Make the script executable: chmod +x restartscript.sh

Edit cron: chrontab -e

0 5 * * * /home/pi/restartscript.sh

The webpage im displaying gets refreshed, and the pi stays up to date.

2

My solution is very easy. I only copy a Preferences file from a former clear shutdown of Chromium over the current file ~/.config/chromium/Default/Preferences.

2

The only way that worked for me was to modify the config before starting Chromium:

sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/Default/Preferences
1
  • 1
    Chrome has changed their flags a lot since most of the posts on the internet. Having tried it all I took this approach. You also need to sed: 's/"exit_type":"Crashed"/"exit_type":"Normal"/' Commented Oct 29, 2020 at 20:39
2

This page gave me the answer. Adding the option

chrome_options.add_argument("--profile-directory=Default")

resolved it for me (in a non-kiosk application).

Turns out this was only part of the issue. The whole situation seems very variable. I additionally added:

prefs = {'exit_type': 'Normal'}
chrome_options.add_experimental_option("prefs", {'profile': prefs})

Trying to reproduce the error to prove this was the fix, I can't now get it to come back with the pop-up (even without this code). YMMV, btw this is running version 72 of Chrome. I saw other posts that advocated changing the Preferences file with something like sed before starting the browser.

Not the answer you're looking for? Browse other questions tagged or ask your own question.