Treestyletab: Custom themes style rules don't survive a restart of the browser

Created on 4 Aug 2020  路  24Comments  路  Source: piroor/treestyletab

Short description

Custom themes style rules don't survive a restart of the browser. I've tried to restore the metal theme using the steps mentioned in https://github.com/piroor/treestyletab/wiki/Code-snippets-for-custom-style-rules#restore-old-built-in-themes , they seem to work fine as long as the browser is not restarted. After a restart the rules are reset

Steps to reproduce

  1. Start Firefox with clean profile.
  2. Install TST.
  3. Install Metal theme rules
  4. Restart browser
  5. Observe that the theme is no longer present

Expected result

Browser restart should preserve custom style rules

Actual result

Browser restart forgets custom style rules

Environment

  • Platform (OS): mac OS
  • Version of Firefox: 79.0
  • Version (or revision) of Tree Style Tab: 3.5.17
fixed

Most helpful comment

@irvinm Yeah, I've thought about same idea and I've implemented that with the commit 203d288. Because the document says that the size of the quota for each field is 8KB, I've chunked style rules in 8KB for safety. Currently there are 6 slots for user styles, 8KB * 6 = 48KB is the max size of style rules. It is about a half of the total quota given for TST.

All 24 comments

I'm having the exact same issue on MacOS 10.13.6 with FF 79.0 and TST 3.5.19.

@piroor I am wondering if this might be related to the max amount of sync data as we discussed in https://github.com/piroor/treestyletab/issues/2623. Because the theme has the image data definitions encoded as base64, those take up a lot of space. (Looks like if you cut\paste the theme, it is about 12.2k of the 16k of possible data)

@anilkumarmyla or @brimarq ... if you delete the CSS block of "image data definitions", does the theme survive (albeit it won't be the same without the definitions) after restarting the browser? Make sure to do a sync before restarting the browser. [This is just a debug step to isolate the issue]

Oops, @irvinm you are right, it looks to exceed the quota...

@irvinm Yes, the theme survives if I delete the image definitions! However I'm not sure where the Sync button is. With 3.5.19, it seems the image definitions vanish just by going to the plugin preferences page, after a previous save

@piroor ... just a thought: Given that Firefox supports up to 512 items to sync with each up to 16k in size (after base64 conversion) up to a total of 100k of storage, could there be a way to keep your implementation of "userStyleRules" the same but when it came to setting up the synchronization keys in common.js split up the content of "userStyleRules" into several smaller buckets < 16k to overcome the single key sync restrictions? [Maybe breaking "userStyleRules" into a max of 5 items which would give you like 5x15k = 75k of total CSS that could be used ... even just 2 or 3 might be sufficient]

This would certainly help those trying to pass in base64 URI data as backgrounds, masks, or content. Again, just a thought ... obviously your call.

@irvinm Yeah, I've thought about same idea and I've implemented that with the commit 203d288. Because the document says that the size of the quota for each field is 8KB, I've chunked style rules in 8KB for safety. Currently there are 6 slots for user styles, 8KB * 6 = 48KB is the max size of style rules. It is about a half of the total quota given for TST.

@anilkumarmyla this should be fixed. Can you verify and close this item?

@piroor

My custom styles, in a synced profile, have been cleared out by a recent update. Is that this issue?

@bughit make sure that both machines have the newer version of TST. I saw that originally when one upgraded and the other did not. I upgraded the older one and it sync-ed the TST CSS.

@irvinm Is this a tip for getting the styles back? It's too late, they're gone from every synced profile.

@bughit Hmm... The change 203d288 introduces new 6 entries userStyleRules0-userStyleRules5. When TST is updated, the old entry userStyleRules is migrated to userStyleRules0 and userStyleRules is cleared. If your another device had an old version TST and configs were synchronized before TST was updated, userStyleRules can be cleared. If this was happened on your environment, sadly the lost data cannot be taken back...

@bughit one thought I had (shot in the dark) ... do you happen to backup your profile directory at all? If you do, you could restore the profile and before the sync takes place, copy out your TST CSS. Just an idea. [Or do you happen to have any other devices that haven't upgraded and sync-ed ... they would still have the CSS]

@irvinm I'm still unable to save the metal theme from browser restart (I'm on 3.5.21) . I'm not sure how to sync the updated css rules to my browser, any idea how to do this? For now, I simply enter the rules, wait for some time and restart the browser/ With 3.5.21 I'm observing css rules that I did not enter getting suffixed at the end and other weird phenomenon

@anilkumarmyla, one thing I could suggest:

  • Make sure all of your devices are on latest TST version
  • Copy your TST CSS (and place in a text editor)
  • Clear out your TST CSS in your browser
  • Manually initiate a sync in Firefox
  • Repeat for your connected devices (all should be blank and synced now)
  • Paste back your TST CSS and manually do a sync
  • Go to your other device and manually do a sync (blank CSS should be overwritten by the sync)
  • Restart browser to make sure everything persists.

@anilkumarmyla I've found a bug around saving data and I've introduced a change f2d0070. Before the change, on my system very long user style rules were unexpectedly lost its first chunk when the options page was loaded. I hope it should fix your case... Intermittently the first part of user styles is still lost after the change. I'm trying to debugging now...

@anilkumarmyla I've reproduced the data loss problem and understood that the current version wrongly chunks user style rules to too large size. With the commit 00659f6 now user style rules will be chunked more safely.

By the way, there may be a workaround: you possibly save the "Metal" user style rules successfully if you remove the license header comment (the top of the style rules).

Finally I've totally re-implemented operations saving large style rules as chunked data. The max data size became smaller than 48KB (because the data will be base64 encoded twice), but stable.

I have the problem that still with the latest version, the CSS rules are reset to my old version.
I've copied the Metal theme at the top and below my changes. That lasts for some hours, and when I open a new tab or window, the CSS is reset to the state before I added the theme on top.
I hope your last fix will fix this.
Thanks for you work. Aweseome what you do for Firefox.

It happened again.

@Tragen Which is the version "latest"? If it means 3.5.21, could you try the latest development build?: https://github.com/piroor/treestyletab#development-builds

Yes, 3.5.21.

I was wrong. I've tested with 3.5.21, the custom styles are reset as soon as I open a new window.

I've installed the development version and the error is fixed for me.

Upgrading to 3.5.22 fixes this problem. Thanks @piroor for the quick fix and for the awesome plugin and @irvinm for the constant follow up 馃槃

Was this page helpful?
0 / 5 - 0 ratings