API to hibernate tabs?

273 views
Skip to first unread message

Nathan Pierce

unread,
Feb 4, 2023, 10:55:36 AM2/4/23
to Chromium Extensions
I'm curious if anyone knows of a way for chrome extensions with tab access to hibernate them? I can store state in my extension, remove tabs, and then restore them when the user wants, but I was hoping chrome could do this natively.

wOxxOm

unread,
Feb 4, 2023, 12:00:56 PM2/4/23
to Chromium Extensions, nors...@gmail.com

Nathan Pierce

unread,
Feb 4, 2023, 1:50:10 PM2/4/23
to Chromium Extensions, wOxxOm, Nathan Pierce
Perfect! thanks!

Nathan Pierce

unread,
Feb 4, 2023, 3:01:13 PM2/4/23
to Chromium Extensions, nors...@gmail.com, wOxxOm
Do you happen to know how to resume the tab? I tried to update with active: true, but that doesn't seem to work.

wOxxOm

unread,
Feb 4, 2023, 3:25:23 PM2/4/23
to Chromium Extensions, weareo...@gmail.com, nors...@gmail.com, wOxxOm
Judging by the description it's not really hibernation, it's essentially like task killing so nothing remains except an entry in the tab strip. It mentions reloading which probably means you can also do it via chrome.tabs.reload()

ONLYHUMN

unread,
Feb 4, 2023, 3:28:36 PM2/4/23
to Chromium Extensions, wOxxOm, ONLYHUMN, nors...@gmail.com
Yep, reload works... Yet, other methods under chrome.tabs seem to claim they can't find the tabID after it's discarded... lol

Belly King

unread,
Sep 6, 2023, 9:05:11 AM9/6/23
to Chromium Extensions, ONLYHUMN, wOxxOm, nors...@gmail.com
Hi, does chrome.tabs.reload  actually work? Say I have a tab with id 123, when this tab is discarded, calling chrome.tabs.reload(123) does not work for me...I get tab id does not exist error.

I am building an extension to manage tabs. If the tab discarded, I cannot find a way to update the discarded one with new tab id...

I listen to the  chrome.tabs.onUpdated  event. When tab(id=123) is discarded it is like this:

chrome.tabs.onUpdated: tabId: 456, tabChangeInfo:{ discarded: true, status: "unloaded" }

This is no way for me to know that tab 456 is actually linked to tab 123.

kg_17

unread,
Sep 6, 2023, 10:04:00 AM9/6/23
to Chromium Extensions, Belly King
https://bugs.chromium.org/p/chromium/issues/detail?id=910968

The id of a tab changes when a tab is discarded.  You can listen to chrome.tabs.onReplaced to get the new id.

Also, in case you are not aware, chrome.tabs.reload loads an up-to-date version of a page.  Form data, page position, etc are lost when a discarded tab is reloaded.  However, if a discarded tab is activated, the tab is restored properly.
Reply all
Reply to author
Forward
0 new messages