Alex313031 / thorium

Chromium fork named after radioactive element No. 90. Windows and MacOS/Raspi/Android/Special builds are in different repositories, links are towards the top of the README.md.
https://thorium.rocks/
BSD 3-Clause "New" or "Revised" License
5.08k stars 154 forks source link

Save SSD by disabling session restore ou increase session store intervals #61

Open trimechee opened 2 years ago

trimechee commented 2 years ago

Hello, i discouver this article of 2016, this problems seems to affect also chromium browsers, it wil be great to save our hard disk and battery to add an option to disable session restore or increase session store intervals, we can do that with firefox but we can't do this with chrome browser, i have made search, i found solution but is complicated , may be it can help, please add option to disable completely session restore, many don't need this feature, we just use browser to watch some videos.....

Thank you in advance !

"Firefox (& Chrome) are eating our SSD's?!" "Chrome writing to disk every 15 secs" "Heavy SSD Writes Firefox is eating your SSD"

"Firefox and Chrome can shorten SSD lifetime September 26, 2016

Firefox and Chrome have been found to continuously write so much data that it might affect the durability of SSDs. Both browsers write an incredible amount of data to disk, even when idle.

firefox-with-32gb-written-in-a-single-day

This was discovered by researcher Sergei Bobik who used the software SSDLife to monitor how much data was read and written on his system. He found both browsers write a lot of data as they continuously make a backup of themselves"

https://myce.wiki/news/firefox-chrome-can-shorten-ssd-lifetime-80534/

https://forums.linuxmint.com/viewtopic.php?t=235651

https://www.servethehome.com/firefox-is-eating-your-ssd-here-is-how-to-fix-it/

"reduced to using Chrome, below is what is going on inside Firefox, it says Chrome does the same thing. I dont need this garbage of Chrome writing the whole page to my micro SD every 15 seconds. Has anybody found, useing a work around for Chrome, when I looked on the net I could not find anything about Chrome, it was all FF."

"by Nominal Animal Before switching to a laptop with a really, really fast SSD, I used to keep my active browser profiles on a ram disk (tmpfs).

Essentially, when inactive, your Firefox profile can be stored in a tarball (~/.mozilla/firefox/profilename.default.tar). When active, the contents of the tarball are extracted to a temporary directory on a tmpfs mount (ramdisk), with the ~/.mozilla/firefox/profilename.default pointing to that directory. The only real limitation of this approach is that you'll want to set the maximum cache size to something small; I happily used 0, 32 and 64 megabytes for years. (The no-cache one I used on a 2009 Acer Aspire One A110L minilaptop. It still works fine for casual web browsing.)

There are two approaches to maintaining such Firefox profiles.

First approach is to construct it at login, and deconstruct/repack it at logout. This is managed via a session manager script, and varies slightly between session managers. (I tried to get the necessary hooks for doing this in a transparent, safe manner to GDM, but got fed up with the lack of interest, and switched to LightDM.) The downside is that the profile is in memory even when you don't have a browser open, and if you keep yourself logged in all the time, the tarball version of the profile never gets updated.

Second approach is to customize or interpose /usr/bin/firefox (or /usr/bin/firefox-esr). It is a launcher shell script for Firefox. In it, the exec $MOZ_LIBDIR/$MOZ_APP_NAME "$@" causes the script to replace itself with the actual Firefox binary. If you edit the script, or use your own copy of the script, with the exec removed, the shell will remain in memory while the browser is still running. (In this case, I recommend using dash as the shell, if possible, for minimal resource use.) Before running the browser binary proper, the scriptlet checks if the session symlink points to a valid directory. If not, it sets it up. After the browser binary exits, the script tests if there are no more instances left (ps -o pid= -C firefox or ps -o pid= -C firefox-esr), and if not, re-tars the profile, and removes the temporary profile directory. (I preferred to use sync to ensure the data hits the disk, and notify-send to pop up a notification whenever the profile was safely stored on disk. That way, after making a number of new bookmarks or such, all I needed to do was to close and reopen the browser windows, to be sure they were safely stored on disk.)

For further information, search for firefox profile tmpfs and/or firefox profile ram with your preferred web search engine. Top

Gee wiss nominal animal, thats a long answer. I was asking about chrome. Go to 'firefox 55 crashing' to see what the experts say to do if you are using a solid drive.

oldchap wrote:
I was asking about chrome.

The approach I used with Firefox years ago works fine for chrome, too."

https://forum.odroid.com/viewtopic.php?t=29810

trimechee commented 2 years ago

It says

"Chrome seems to generate the same operations as well

Early experiments show a similar behavior for Chrome, which also generates around 1GB per hour, rounding up to around 24GB per day."

"Those [SSD] drives can be rated for about 20GB of writes per day and Firefox [or Chrome] alone might be using more than half of that," Bobik warns users using SSD drives.

"Adjust This Setting Before Firefox Wears Down Your SSD Drive Google Chrome seems to exhibit the same behavior"

https://news.softpedia.com/news/adjust-this-setting-before-firefox-wears-off-your-ssd-drive-508665.shtml

https://forums.servethehome.com/index.php?threads/firefox-is-chewing-through-your-nand.11346/page-2#post-108407

Solution :

take inspiration from brave browser which is open source and apparently doesn't have this kind of disk ssd problem

https://community.brave.com/t/a-geeky-noob-tells-you-why-he-uses-brave-browser/102876

"It might seem stupid. But this browser doesn’t scan my whole hard drive right? Chrome’s “Software Reporter Tool” does that. It scans and tests every .exe file.

And, this browser doesn’t keep writing data onto my hard drive when idle, right? Firefox does that all the time. Keep Firefox open for 24 hrs and it will write more than 10GB of data. And I don’t know how to stop Firefox from doing that. And I love to keep browsers open all the time. So these two problems are really annoying. My last cheap SSD broke sooner because of this?" "

Alex313031 commented 2 years ago

@trimechee Interesting, I will look into it.

trimechee commented 2 years ago

Wow! fantastic ! Thanks a lot 🥇

i'm so shocked and sad and in shock and devastated because i thought firefox is lighter than chrome, i spent several hours today to research and understand and modify firefox's internal session restore values and i hope you can find a solution if this problem really affects chromium based browsers because i did some research and it says there is no solution for chrome!

I looked in the peter.ch site for command lines but I didn't succeed, the only small solution I found is to go to the chromium settings/startup/open new page instead of resume where you have stopped

trimechee commented 2 years ago

here what i found, some people said this not operational and bug, some said it works.....

"Someone has suggested just running Chrome in Incognito mode to get around the problem If you are running in full screen mode and redirecting to a specific page that shouldn't be noticeable. I know that's a bit of a work around.

Open chrome \ Default \ Preference, and change the value to

"exit_type": "none",

"exited_cleanly": true,

Save the file, and put him to attribute "read only". Tested on various versions of the Chrome browser

--disable-session-crashed-bubble

chrome.exe --kiosk --disable-session-crashed-bubble "http://example.com"

https://superuser.com/questions/461035/disable-google-chrome-session-restore-functionality

https://bugs.chromium.org/p/chromium/issues/detail?id=445256#c17

https://superuser.com/questions/33548/starting-google-chrome-in-application-mode

https://superuser.com/questions/1640618/how-to-disable-permanently-the-chromium-popup-after-crash-or-hard-boot/1643107#1643107

https://superuser.com/questions/237608/how-to-hide-chrome-warning-after-crash

trimechee commented 2 years ago

"I see some inconveniences in the solutions provided:

--incognito switch removes cache, what is pretty bad in most circumstances.

(Copy-pasting chrome help )

Google Chrome has hundreds of undocumented command-line flags that are added and removed at the whim of the developers.

--disable-session-crashed-bubble depends of which version of chrome are you using, the most actual version v39 doesn't have this setting allowed.

The solution I did was to alter the user profile and overwrite the crash status to a normal close status, It's a simple hack that works perfect.

This is the script I run in kiosk-mode in a chrome-only session under Ubuntu 12.04 and 14.04

!/bin/sh

sed -i 's/"exited_cleanly": false/"exited_cleanly": true/' ~/.config/google-chrome/Default/Preferences sed -i 's/"exit_type": "Crashed"/"exit_type": "None"/' ~/.config/google-chrome/Default/Preferences google-chrome --kiosk "http://some_url" It simply finds and replace the string

"exited_cleanly":false exit_type": "Crashed" with

"exited_cleanly": true "exit_type": "None" So, no matter how chrome has closed. It will always think it has closed gracefully. (Tested in many chrome versions)

trimechee commented 2 years ago

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

Shut down Chromium gracefully 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"

"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 "

https://superuser.com/questions/237608/how-to-hide-chrome-warning-after-crash

https://superuser.com/questions/1640618/how-to-disable-permanently-the-chromium-popup-after-crash-or-hard-boot/1643107#1643107

trimechee commented 2 years ago

Hello Mr @Alex313031 , yes it does't concern our beloved Thorium Browser but i ask for yout help because you are generous 🥇 I have a doubt about two parameters in Firefox and I'm afraid it will have the opposite effect, I think it's safe to increase these values to deactivate the session store:

browser.sessionstore.interval browser.sessionstore.interval.idle

but I have doubts about these 2 values, should I increase it or minimize or put "0" to disable the session restore please? I searched but couldn't find an answer :(

browser.sessionstore.idleDelay browser.sessionstore.cleanup.forget_closed_after

trimechee commented 1 year ago

Hello Mr Alex @Alex313031 , how are you ? i hope you are fine in sha Allah :) Just to say i tried the new revolutionary A.I chatgpt and also i make my new owen research to find more solutions to disable session store, here what i find but I'm not sure if these solutions are outdated :

--disable-features=SessionRestore -disable-restore-session-state --disable-session-crashed-bubble --disable-features=InfiniteSessionRestore disable enable Tab Discarding Enable Tab Stash In the System section, toggle off the switch for "Continue running background apps when Google Chrome is closed".

Running perl -pi -e 's/exit_type\":\"Crashed/exit_type\":\"none/' ~/.config/google-chrome/Default/Preferences does the trick for me on Ubuntu.

After manually exiting Chromium on the GUI (ie. clean exit)

su (note: super-user remain in current user path, now using relative to local path) chattr +i .config/chromium/Default/Preferences chattr +i .config/chromium/'Local State'

If you never created a password for the root on your pi do the following and you will have the password for the su command above.

sudo passwd root

trimechee commented 2 months ago

Mr @Alex313031 , you said to me that what i write about session store interval is interesting and you will look in this, and i see the friendly Mr @gz83 close this issue,

so the new version of our beloved Thorium browser has increased session store intervals or added advanced flag to increase session store interval to preserve our old hard disk and battery ?

gz83 commented 2 months ago

Chrome/Chromium has made some efforts to save resources (memory, power, etc.) in newer versions, but I think they may still not fully meet your needs.

Your issue was closed in a bulk operation (closing issues that have been inactive for a long time), but there is new activity now, so I reopened it.

trimechee commented 2 months ago

Thank you very much Mr @gz83 for opening the issue and sorry for the misunderstanding :) 💯 🥇

yess chrome and chromium know that they can use a lot of energy which affects our battery and they introduced the features "memory saver" and "battery saver", it is in a way a session store killer because when the web browser remains idle for a certain time, chrome and chromium will deactivate session store or reduce the frequency of the session store and thus we can forget our open web browsers without too much fear of wasting energy dead battery,

but the problem and I have already spoken to Mr Alex @Alex313031 , the battery saver feature which reduces energy consumption and javasript timer and the frequency of the session store is only activated when we have a battery (option absent on laptop without battery or desktop computer) and is only activated when the battery reaches the 20% level, and in addition I saw in the flags of chromium and chrome that memory saver is activated and discard idle web page only after 2 hours of inactivity which is too much, edge browser allows to discard idle web page after 30 seconds of inactivity, or 5 minutes.... edge browser gives us the choice.....

so to reduce the frequency of the session store, I think our beloved Throrium browser should offer us an option to activate battery saver even without battery and even when the battery does not reach 20%, and also memory saver should activate after 1 minute of web page idle for example, because the default value 2 hours is too high and during these 2 hours, the session store is active even if the browser is idle !

Thank you so much :)

bbt-dev commented 1 month ago

I opened a new thread that could be useful for resolving also this issue.

In brief, the solution could be rather simple: allow to easily change the path to cache folder. If Thorium will write the cache to the dedicated disk - this will prevent consuming SSD writing resource. And this allow to easily exclude from backups the browser cache, but keep user profile, plugins etc.