33

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 ?

InterLinked
  • 2,406
  • 6
  • 29
  • 64
Olivier
  • 1,479
  • 4
  • 16
  • 22
  • This is a probable duplicate of http://superuser.com/questions/461035/disable-google-chrome-session-restore-functionality. Even though this question is older, it has 10x fewer views and 3x fewer votes. – nc4pk Jul 23 '15 at 00:31

10 Answers10

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/"
Josh Kelley
  • 1,527
  • 2
  • 15
  • 29
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
jowido
  • 616
  • 4
  • 4
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
frekele
  • 221
  • 2
  • 4
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

Davide Andrea
  • 231
  • 4
  • 6
  • 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](https://superuser.com/help/privileges/close-questions) or, if you don't have enough reputation for that, [raise a flag](https://superuser.com/help/privileges/flag-posts) 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 02 '17 at 05: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. – Justin Force Dec 05 '17 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. – Scott Dudley Jul 11 '18 at 20:23
  • 2
    +1 thanks for this. The command I used to lock the file: `sudo chattr +i ~/.config/google-chrome/Default/Preferences` – Harrison Powers May 28 '19 at 19:10
4

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

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

Gili
  • 1,841
  • 4
  • 26
  • 37
  • 1
    actually in that page it says `Note that this does not force automatic session restore following a crash`. – caesarsol Sep 22 '20 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.
yjcxy12
  • 131
  • 1
2

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

Matt
  • 278
  • 1
  • 2
  • 12
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.

xtian
  • 236
  • 3
  • 5
  • 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 09 '21 at 09:12
  • @Meryan isn't my example working for you? Maybe with chmod a-w instead of just -w? – xtian Apr 09 '21 at 09: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 09 '21 at 09: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 09 '21 at 09:32
  • I run chromium from the pi autostart as follows: chromium-browser --start-fullscreen --disable-session-crashed-bubble --kiosk http mydomain.com – Meryan Apr 09 '21 at 09:38
  • The file that I set to readonly is called "Local State" (yes, with a space) and resides in the user profile folder. If you don't know where your user profile folder is, then start chrome with a specific user profile folder: --user-data-dir=/some/folder/here – xtian Apr 09 '21 at 15:22
  • Tried chmod -w ~/.config/chromium/'Local State' after cleaning, chromium has super power it changes it to -rw---------------------------- I have now posted my wasted time here https://superuser.com/questions/1640618/how-to-disable-permanently-the-chromium-popup-after-crash-or-hard-boot – Meryan Apr 09 '21 at 19:25
  • Maybe you can start chromium with a different user that has less privileges? – xtian Apr 10 '21 at 20:35
  • https://superuser.com/a/1643107/690627 This brute force worked but I hate it when a simple command line option would have sufficed. I am still in the midst of fine tuning things so having to unlock these files is unpleasant. I have no idea why sed from the autostart modifying Preferences and "Local State" does not work on /home/pi/... what am I missing? – Meryan May 12 '21 at 03:04
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

R Rust
  • 1
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
Meryan
  • 222
  • 2
  • 12