34

When Chrome has crashed, it displays a warning (under the address bar) upon restart, offering to restore tabs. I'm launching chrome in kiosk mode and I don't want theses warnings to be displayed.

Is there a way to do this ?

1

10 Answers 10

20

You should run Chrome in Incognito Mode with this command:

chrome --incognito --kiosk http://127.0.0.1

Here they talk about running this command before starting Chrome to stop the Restore Bar from appearing:

sed -i 's/"exited_cleanly": false/"exited_cleanly": true/' \
    ~/.config/google-chrome/Default/Preferences
5
  • incognito does the trick for me.
    – Olivier
    Jan 27, 2011 at 15:40
  • 9
    Yes, incognito works, but it disables cookies and cache, and (in my case) they are required. Oct 1, 2017 at 23:44
  • I added the sed line in my cron file after @reboot Jan 8, 2018 at 16:07
  • For me in Chrome 74 it seems to have moved to a different file and no longer has white space, but this worked: sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' "$HOME/.config/google-chrome/Local State"
    – Greg Bray
    May 8, 2019 at 22:27
  • For me in Chrome 108 I get the "Restore pages? Chrome did not shut down correctly" dialog; I look in $HOME/.config/google-chrome/Local State and exited_cleanly is true. Dec 23, 2022 at 10:37
24

Based on @MiQUEL's answer to this duplicate question:

There are a few approaches.

Incognito mode (--incognito) helps, but it has several disadvantages, such as disabling the cache.

Passing --disable-infobars --disable-session-crashed-bubble works in some versions of Chrome, but, as of Chrome 58, it no longer works. (Removing the --disable-session-crashed-bubble was done as part of this issue; comments there suggest that the flag was intended to test the bubble feature and was not intended as an end-user feature to hide the Chrome warning).

The most reliable approach I've found is to manually edit Chrome's on-disk preferences. Here's how you do this on Linux. (Note that these instructions are for chromium-browser; Google Chrome itself uses ~/.config/google-chrome instead of ~/.config/chromium.)

sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/'Local State'
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/; s/"exit_type":"[^"]\+"/"exit_type":"Normal"/' ~/.config/chromium/Default/Preferences

Putting it all together with a couple of additional flags that have been helpful for kiosk mode in one Chrome version or another:

#!/bin/sh
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' ~/.config/chromium/'Local State'
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/; s/"exit_type":"[^"]\+"/"exit_type":"Normal"/' ~/.config/chromium/Default/Preferences
chromium-browser --kiosk --no-default-browser-check --no-first-run --disable-infobars --disable-session-crashed-bubble "http://some_url/"
1
  • For some reasons tilde wasn't resolved for me, I had to use $HOME in I use lxsession autostart. Nov 13, 2017 at 14:05
12

--disable-infobars --disable-session-crashed-bubble

while true; do
   chromium-browser --kiosk http://fotolia.com/ --no-first-run --touch-events=enabled --fast --fast-start --disable-popup-blocking --disable-infobars --disable-session-crashed-bubble --disable-tab-switcher --disable-translate --enable-low-res-tiling
   sleep 10s;
done
3
  • 1
    Confirmed, this works for me on Chromium 47 on Linux.
    – Sundae
    Dec 9, 2015 at 15:42
  • 1
    Did the trick for me. My Chromium ignored the "exited_cleanly" Preferences.
    – cljk
    Feb 19, 2016 at 6:59
  • 2
    doesn't work anymore (Chromium 65 on RaspberryPi)
    – david114
    Dec 13, 2018 at 9:54
8

This finally worked for me, and it's pretty simple:

  1. Shut down Chromium gracefully
  2. Change the "Change content" permissions of ~/.config/chromium/Default/Preferences to "Nobody"

That will lock the state of two variables, regardless of how Chromium was shut down:

  • "exit_type": "Normal"
  • "exited_cleanly": true

Of course, only do that after you're done setting preferences

4
  • 1
    Please do not post the same answer to multiple questions. If the same information really answers both questions, then one question (usually the newer one) should be closed as a duplicate of the other. You can indicate this by voting to close it as a duplicate or, if you don't have enough reputation for that, raise a flag to indicate that it's a duplicate. Otherwise tailor your answer to this question and don't just paste the same answer in multiple places.
    – DavidPostill
    Oct 2, 2017 at 5:01
  • 3
    Repeated admonishments from moderator aside, unlike every other suggested solution for this problem, this one actually worked for me. So thank you for sharing it. Dec 5, 2017 at 20:55
  • 2
    This seemed like a great solution at first glance. The main problem is that when using this with WebDriver under Selenium, chromedriver complains (at least on a Windows node) that it can't write to the prefs file at startup, so it won't let you launch a session when the prefs file is read-only. Jul 11, 2018 at 20:23
  • 2
    +1 thanks for this. The command I used to lock the file: sudo chattr +i ~/.config/google-chrome/Default/Preferences May 28, 2019 at 19:10
4

I believe --restore-last-session will also do the job.

Source: http://peter.sh/experiments/chromium-command-line-switches/

1
  • 1
    actually in that page it says Note that this does not force automatic session restore following a crash.
    – caesarsol
    Sep 22, 2020 at 14:31
3

I have been trying to solve this problem for days. Incognito mode comes without cache, and changing Preferences file did not work for me.

Finally I have been able to solve by following steps below:

  1. Go to chrome://flags url. Search for “Enable session restore bubble UI” and set it to Disabled.
  2. open chrome with --kiosk --disable-infobars options.
1
  • 1
    Looks like that flag no longer exists Feb 23, 2018 at 18:12
2

--restore-last-session argument when launching Chrome.

1

On Linux I prevent the crash dialog by removing write access to the "Local State" file in the user profile.

Actually I run many instances of chrome with different user profile folders. Sometimes I run a script to kill all chrome processes for cleanup purposes. I used to get the annoying dialogs at restart and fixed it this way:

find /somepath/profiles/ -maxdepth 2 -type f -name "Local State" -exec chmod -w '{}' \;

pkill -9 chrome

find /somepath/profiles/ -maxdepth 2 -type f -name "Local State" -exec chmod +w '{}' \;

If you want to prevent the dialog after an uncontrolled crash, maybe you should remove write access for good. I don't know if it can have negative consequences though, never tried that.

9
  • what is the command to remove write access to the stupid chromium, I tried resetting both variables in that Preferences file I hard boot (repower) my Raspberry pi, I keep getting this nasty popup. I also tried the --disable-session-crashed-bubble in the pi autostart when launching chromium. Thanks. cd ~/.config/chromium/Default then what
    – Meryan
    Apr 9, 2021 at 9:12
  • @Meryan isn't my example working for you? Maybe with chmod a-w instead of just -w?
    – xtian
    Apr 9, 2021 at 9:19
  • So after exiting manually from Chrome via Ctrl-F4 I greped the json and it shows both exit flags as Normal/true I ran chmod -w ~/.config/chromium/Default/Preferences went back to the Pi launched Chromium from the GUI. Than hit the power switch on reboot I still get the popup. I am unix novice I don't understand your script /somepath/profiles/ that is apply to me as well? I have only the default user on the raspberry pi
    – Meryan
    Apr 9, 2021 at 9:27
  • chromium is somehow able to change the access rights on the Preferences file. I see the access writes are back as -rw------ instead of -r--------- after the chmod -w
    – Meryan
    Apr 9, 2021 at 9:32
  • I run chromium from the pi autostart as follows: chromium-browser --start-fullscreen --disable-session-crashed-bubble --kiosk http mydomain.com
    – Meryan
    Apr 9, 2021 at 9:38
0

For others looking for a current answer, I found the following tip on stackexchange that worked for me: chromium-browser --kiosk --app=http://your.url.here

0

Finally something that seems to work and ignore the crash (caused by powering the pi instead of a shutdown/restart).

The --app= seems to do the trick from the pi autostart file.

chromium-browser --start-fullscreen --kiosk  --app=http://mumti.org/?ch=MUMTI&cat=SLOWTV

--app mentioned here Starting Google Chrome in application mode

One of my previous failed attempts was using sed from the autostart to modify Preferences and "Local State". I have no idea why it did not work on /home/pi/

The last successful solution was https://superuser.com/a/1643107/690627 although this brute force worked I hated it because

  1. a simple chromium command line option would have sufficed.
  2. I am still in the midst of fine tuning things so having to unlock these files is unpleasant.
  3. locking files is probably a bad idea as it may crash chromium

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .