Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lost my group after unexpect shutdown #210

Closed
Monirzadeh opened this issue Jul 16, 2018 · 6 comments
Closed

lost my group after unexpect shutdown #210

Monirzadeh opened this issue Jul 16, 2018 · 6 comments

Comments

@Monirzadeh
Copy link

Describe the bug
hi
I lost groups after my pc turn off suddenly (power outage)
STG say you have tabs that are not synced. I restore them but my groups and settings restart.

Steps to reproduce the behavior:

  1. do lots of customization
  2. take out the power cord
  • OS: [e.g. linux-kubuntu ]
  • Version [e.g. 3.0.9]
@yennor
Copy link

yennor commented Jul 17, 2018

I seem to have the same problem. I'm not 100% sure if it was because a crash, since I just noticed today that all my groups are gone (besides the one which was activated), and the last system freeze I had is 2 days ago. Anyway, it also tells me "Found hidden unsynchronized tabs. Click on tab to show it into current group/window or:"
Anyway All tab groups gone. I've got like a 100 unsorted tabs now! argh!
os: linux debian
firefox: 61
stg: 3.0.9

@Drive4ik
Copy link
Owner

Sorry guys but I can not protect the data from the fall of the browser or computer. For normal operation of the browser, it must be rebooted at least once a day, and give it the option to completely turn off and then time to fully load the browser and tabs that are loaded. From everything I can not protect. I can only advise you to make backup copies.

@kotarou3
Copy link

What makes STG lose all its config on an unclean shutdown, but other addons like Greasemonkey and uBlock Origin retain them just fine? Is it the storage format? What storage does STG use?

And surely STG should be able to data loss, and automatically restore from latest backup if it exists?

@Drive4ik
Copy link
Owner

@kotarou3

What makes STG lose all its config on an unclean shutdown, but other addons like Greasemonkey and uBlock Origin retain them just fine?

Because STG uses much more data than other plugins. Depends on the number of tabs and groups.

Is it the storage format? What storage does STG use?

I use the same as other addons:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/local
There is no other way to save data.

And surely STG should be able to data loss, and automatically restore from latest backup if it exists?

firefox webextensions do not allow automatic recovery of such amount of data (tabs and groups)

You can find backups in the browser download folder and restore them manually. Not everything is possible to make "automatic"

@kotarou3
Copy link

@kotarou3

What makes STG lose all its config on an unclean shutdown, but other addons like Greasemonkey and uBlock Origin retain them just fine?

Because STG uses much more data than other plugins. Depends on the number of tabs and groups.

Brief (a RSS reader) seems to retain ~82 MiB storage through crashes just fine, compared to STG of only ~3 MiB (if storage/default are where the data is stored):

0	moz-extension+++9ce5a2d5-5981-4134-9fb2-e119135d4916/idb/2885756783ssipmupolreg--tba.files/journals
0	moz-extension+++9ce5a2d5-5981-4134-9fb2-e119135d4916/idb/2885756783ssipmupolreg--tba.files
232K	moz-extension+++9ce5a2d5-5981-4134-9fb2-e119135d4916/idb
0	moz-extension+++9ce5a2d5-5981-4134-9fb2-e119135d4916/cache/morgue
60K	moz-extension+++9ce5a2d5-5981-4134-9fb2-e119135d4916/cache
300K	moz-extension+++9ce5a2d5-5981-4134-9fb2-e119135d4916
0	moz-extension+++9ce5a2d5-5981-4134-9fb2-e119135d4916^userContextId=4294967295/idb/3647222921wleabcEoxlt-eengsairo.files/journals
2.3M	moz-extension+++9ce5a2d5-5981-4134-9fb2-e119135d4916^userContextId=4294967295/idb/3647222921wleabcEoxlt-eengsairo.files
2.5M	moz-extension+++9ce5a2d5-5981-4134-9fb2-e119135d4916^userContextId=4294967295/idb
2.5M	moz-extension+++9ce5a2d5-5981-4134-9fb2-e119135d4916^userContextId=4294967295
0	moz-extension+++8752bcfd-95c6-4b00-b401-f7d7da6fa14f/idb/1070927728bfrei.files
82M	moz-extension+++8752bcfd-95c6-4b00-b401-f7d7da6fa14f/idb
0	moz-extension+++8752bcfd-95c6-4b00-b401-f7d7da6fa14f/cache/morgue
60K	moz-extension+++8752bcfd-95c6-4b00-b401-f7d7da6fa14f/cache
82M	moz-extension+++8752bcfd-95c6-4b00-b401-f7d7da6fa14f
0	moz-extension+++8752bcfd-95c6-4b00-b401-f7d7da6fa14f^userContextId=4294967295/idb/3647222921wleabcEoxlt-eengsairo.files
60K	moz-extension+++8752bcfd-95c6-4b00-b401-f7d7da6fa14f^userContextId=4294967295/idb
68K	moz-extension+++8752bcfd-95c6-4b00-b401-f7d7da6fa14f^userContextId=4294967295

(9ce5a2d5-5981-4134-9fb2-e119135d4916 is STG, 8752bcfd-95c6-4b00-b401-f7d7da6fa14f is Brief)

It seems like the bulk of STG's data is inside a directory with ^userContextId=4294967295 at the end, while Brief's is without the suffix. I'm not sure what the differences are between the two.

But maybe it might be worth investigating why exactly STG ends up wiping the data while Brief can keep it on crashes.

@Drive4ik
Copy link
Owner

It's not just that. Data is saved every 500 ms after the change, and no more

let _saveGroupsToStorageTimer = 0;
async function saveGroupsToStorage(withMessage = false) {
if (withMessage) {
sendMessage({
action: 'groups-updated',
});
}
if (_saveGroupsToStorageTimer) {
clearTimeout(_saveGroupsToStorageTimer);
}
_saveGroupsToStorageTimer = setTimeout(function() {
storage.set({
groups: _groups,
});
}, 500);
}

In Firefox 66, the data has been moved to IndexedDB, and there are problems with this too.
https://www.ghacks.net/2019/02/16/firefox-extensions-to-use-different-storage-type-in-firefox-66/
And not only this plugin
https://github.com/sienori/Tab-Session-Manager/wiki/IndexedDB-Error
gorhill/uBlock#2925

When I tested the browser crash, when I started it, I suggested to restore the session, and I made code that in this case waits for the session to be restored before loading the plugin:

function isRestoreSessionNow(windows) {
return 1 === windows.length && 1 === windows[0].tabs.length && 'about:sessionrestore' === windows[0].tabs[0].url;
}

if (isRestoreSessionNow(windows)) {
// waiting for session restore
await new Promise(function(resolve) {
let tryCount = 0;
async function checkRestoreSession() {
let wins = await getAllWindows();
if (isRestoreSessionNow(wins)) {
tryCount++;
if (3 === tryCount) {
browser.browserAction.setTitle({
title: browser.i18n.getMessage('waitingForSessionRestoreNotification'),
});
utils.notify(browser.i18n.getMessage('waitingForSessionRestoreNotification'), undefined, 'wait-session-restore-message');
}
setTimeout(checkRestoreSession, 1000);
} else {
resolve();
}
}
checkRestoreSession();
});
windows = await getAllWindows();
browser.notifications.clear('wait-session-restore-message');
}

And no data while the browser is not lost. Addon can not be held responsible for system failure.
For this, I made an automatic backup of all data by default, to the downloads folder and the ability to save to bookmarks, and quick recovery from backup.
Most likely, Firefox developers already know about these issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants