Page Lifecycle API
developers.google.com
developers.google.com
> Otherwise please use the original title, unless it is misleading or linkbait. Don't editorialize.
I think a better title would be: "Page Lifecycle API - A solution to the 'Too Many Tabs' memory problem".
"Page Lifecycle API" from "developers.google.com" gives a hint that the article is written by Google and given "developers" is about an open source (or open API at least) Google product, and presto in the first paragraph: "[...] shipping in Chrome 68 [...]". The title is perfectly fine as it is.
As I was doing my research for the article, I found a lot of things that really surprised me. And I feel pretty confident in saying that most web developers aren't aware of these things either.
Here are my top four:
- We shouldn't use the unload event. Ever.
- The unload event often doesn't fire when closing tabs/app on mobile
- The pagehide/pageshow events even exist (virtually no one I've talked to knows what they do; most people think they're about page visibility).
- In browsers that implement a page navigation cache, you can click a link to navigate away and then navigate back with the back button, and all your JS code is exactly as it was before you navigated.
To this last point. Try doing this in the console:
1. Write a promise that resolves in a setTimeout after 5 seconds.
2. After 1 second, click a link to navigate to a new page.
3. Stay on that page for an hour.
4. Click that back button.
5. Your promise will resolve in 4 seconds!
- "Read and change all your data on the websites you visit"
- "Read and change your browsing history"
That's a lot of power to grant to a third party, especially on a work machine where some of that data you're looking at may belong to your users.
How many applications are running on your work machine outside the browser, with no warnings or significant[0] limitations?
Advantages over The Great Suspender: - More memory savings - Compatible with chrome tab syncing - Super lightweight extension that uses no content scripts or persistent background scripts
Disadvantages over The Great Suspender: - No visibility on which tabs have been suspended - Unable to prevent a tab from reloading when it gains focus
--
I'd say those disadvantages (particularly the second one) outweigh any increase in memory savings.
How are these two things related? One is for running code in a VM, and the other is a UX pattern for presenting multiple screens/interfaces for multitasking.
[0] https://www.openhub.net/p/Linux/analyses/latest/languages_su...
[1] https://www.openhub.net/p/WebKit/analyses/latest/languages_s...
Meanwhile I've had 800+ tabs open in Firefox with no noticeable issues.
Once you switch to vertical it becomes easy to leave old tabs hanging around. They impose no extra cognitive load until you have enough to require scrolling.
I navigate them using the tab hotkeys, container tab menu, and fast scrolling while watching for favicon clusters.
Every few weeks I do a quick pass through all my open windows and tabs and I close any documents that have grown stale or that I've already finished studying up on or read through.
In other words - this behavior is proof that there's room for improvement of browser history UI.
Definitely. Firefox's built-in history browsing UI is frankly horrible. Norwell History Tools was better but is no longer supported.
I recommend aggressively archiving into Zotero or another tool, perhaps into an "unread" folder, so that at least it's possible to read any one of them.
... I'm not joking.
But overall I'd say In my case my high tab count is mostly due to laziness. I have tons of tabs open that I may never look at again, but just haven't cleaned up. You might say "well, that's dumb, you're wasting memory and should clean up those unneeded tabs", but I'd retort, "why should I do manual work when the computer can clearly just deal with it for me so I don't have to care?"
I tend to do think and do things very on a very asynchronous / concurrency level. I'll load dozens of webpages CTRL+Left click new tabs open, cross reference other documents open.
When I do this, there's two reasons usually
- 1. I'm surfing the web for interesting content as quickly as possible
- 2. I'm researching a specific topic and answer
------------------------------------------------------------------
So in case 1, I'm on hackernews. Its far faster for CTRL+Left click and upvote dozens of articles that I find relevant. First, I open the comments page to see what the general concensus on the article is, then I load the article after.
Because my browser needs a few seconds to load all this in one go, it makes sense for me to open new tabs at a time. I save what is essentially seconds of time, but it adds up in the long run making me way more productive.
When I get tab overflow, I just move the most important tab (the hackernews page) to its own window, leaving behind everything else, but not closing it off. I have the "Great suspender" chrome extension set to 30 minutes or so, in that 30 minutes, I will pop open roughly 20-100 tabs and skimp through dozens of articles and hundreds of comments.
I do the same process as well, for (2) researching a specific topic in a field. Say my computer breaksdown. I need to deduce what issues I can look up, and go through dozens of sites such as tomshardware, reddit, microsoft tech support, superuser stackexchange, youtube, among many others. I need to cross reference sometimes dozens of sites to identify and narrow the issue.
Not everyone does things this way, it requires a specific mindset to be okay with having a chrome tab wasteland, but it gets the job done way faster than any other solution or method I've tested.
I realize that (1) reading and keeping up to date on news is valuable, but it also is a huge time drain as well. So I try and get it as quickly over with as possible.
During this entire process I will also bookmark certain things as well, based on how useful the information is. In each of these 20-100 sites, I assign a mental metric in my head, depending on the metric, I will do certain things
------------------------------------------------------------------
- 1. If the site is relevant to me down the road and on a site, or has something interesting to talk about, I will CTRL+D pinboard shift add 3 or so tags and press enter. This takes me about 5-10 seconds to do on a page
- 2. If the site came from hackernews and is going to be useful in my life in the next 1-2 years, I will "favorite it"
- 3. If the site is interesting on hackernews and I read the comments / article, I will "upvote it"
- 4. If the article on the site is something I will use in the following week, it will be added as a chrome toolbar bookmark which I sorted on a A-Z basis
------------------------------------------------------------------
At the end of the day I will have funneled down all the interesting tidbits into (1) what is useful and (2) what is interesting, and (3) what is not.
These will all be aggregated in a singular list on hackernews or pinboard or into its own dedicated spot on chromes toolbar.
This means I can access all the information I've ever read in roughly a few keyboard clicks and strokes and can reference and cite dozens of pieces of factual pieces of information to backup any arguments I have, whether in writing or in person.
In this sense I am essentially making my own version of zotero or some citation machine with whatever tools are available in the best possible workflow I can possibly imagine to get shit done really quickly
[In the future, we will add a commit() method to perform write-only transactions that don't require callbacks. (assuming the IndexedDB database is already open).]
This seems like a strange design. So there is a callback specifically for persisting data before freeze, but when it runs, the main persistance API isn't actually available.
Wouldn't it have been possible to mark IndexedDB callbacks as "non-freezable tasks" - or allow a promise to be returned from the freeze callback? (Subject to a timeout)
> For code that needs to work today, however, developers have two options:
- Use Session Storage [...]
- Use IndexedDB from your service worker [...]
I guess session storage is technically a workaround - but it seems odd, as almost everywhere else you get the recommendation to use IndexedDB instead.
I guess a strategy could be to simply dump all your unsaved data into session storage on freeze, and then "properly" load it into IndexedDB on the next load or unfreeze. Still, this seems complicated and subject to problems if your data exceeds the maximum storage size.
The rest should probably be an actual application.
Is there any way to force Chrome to totally inactivate all tabs in the background, with a whitelist option so Youtube and friends can run?
That is to say, I’ve only seen chrome get worse in this regard.
It hasn't settled yet? I'm not missing anything in my Firefox (but I don't know about session manager addons since I don't use any).
Firefox 52.x ESR, which does work with XUL extensions, would remain a supported choice until September 2018 (a couple of more months from now). After that, there wouldn't be a Mozilla supported browser that's not exclusively WebExtensions based, AFAIK.
the webassembly / webgpu / webvr people are trying to bring multi gigabyte games to the web and the page lifecycle people are trying to make it so every time you put that.tab in the back you have to wait several minutes for the data to reload.
or, you know, start optimizing. Opera 12 used to render websites using 5-10MB, same websites took 50-100MB in Chrome.
How do you transparently suspend a site that has a setInterval(foo, 1000) running?
Microsoft made a public statement of support for the API, and Firefox engineers were actively involved in many of the design and implementation discussions.
You can read more details in the Intent to Ship thread here: https://groups.google.com/a/chromium.org/d/msg/Blink-dev/Na7...