OneTab keep crashing

It was just a normal day, a day similar to others.  My OneTab was suddenly not working. Some people here might not know it, OneTab is a chrome extension that make keeping and restoring tabs easy.

Screenshot from 2016-04-06 18:04:16.png

Honestly , I didn’t get surprised. Why?

I have a habit of keeping lots of tabs open in multiple windows. In a regular day, I can open up to 30+ tabs easily. That’s why I need some tools like OneTab to manage all of them. Also, I keep all the lists even they are restored. This led to that over the past 2 years, I have 4k+ tab records inside the OneTab.

The reason is simple, when I open up the OneTab page, I have a sense that it becomes slower and slower, it’s because there are too many items in the page which may cause a memory leak. What’s worse is that I can’t even remove and export the data!

So, what can I do?

Popular Linux Distro mostly is storing the data of the chrome extensions under the following path:

 /home/{YOURNAME}/.config/google-chrome/Default/Local Storage

For each extensions, there would be a .localstorage file and a .localstorage-journal file. One tab is stored as:

 chrome-extension_chphlpgkkbolifaimnlloiipkdnihall_0.localstorage

 chrome-extension_chphlpgkkbolifaimnlloiipkdnihall_0.localstorage-journal

In fact, those .localstorage files are just SQLite files. Fortunately I can solve it by doing some DB operations.

To make life simpler, I do it in GUI. Thanks to the author of sqlitebrowser.

Screenshot from 2016-04-12 00:36:38.png

Screenshot from 2016-04-12 00:37:462.png

Basically, it’s just a simple database containing 1 key-value table only. There are 7 records in this table but only 2 records, idCounter and state, are matters.

  • idCounter: the last primary key of tabs
  • state: the tabs records that stored in JSON string

Copy and paste the value of “state” to any editor, you should see something like this:

{
  "tabGroups": [
    {
      "id": 3198,
      "tabsMeta": [
        {
          "id": 3182,
          "url": "http://localhost:3000/users/75/edit",
          "title": "Servlet Error"
        },
        {
          "id": 3183,
          "url": "https://docs.racket-lang.org/reference/lambda.html?q=lambda#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._lambda%29%29",
          "title": "3.8 Procedure Expressions: lambda and case-lambda"
        },
        {
          "id": 3185,
          "url": "https://docs.racket-lang.org/reference/exns.html?q=object-name#%28def._%28%28quote._~23~25kernel%29._raise-user-error%29%29",
          "title": "10.2 Exceptions"
        },
        {
          "id": 3188,
          "url": "https://docs.racket-lang.org/reference/ivaraccess.html",
          "title": "6.4 Field and Method Access"
        },
        {
          "id": 3197,
          "url": "http://stackoverflow.com/questions/23296384/application-not-a-procedure-racket",
          "title": "condition - application: not a procedure racket - Stack Overflow"
        }
      ],
      "createDate": 1453743658563
    },
    {
      "id": 3212,
      "tabsMeta": [
        {
          "id": 3199,
          "url": "https://docs.racket-lang.org/reference/exns.html?q=object-name#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail%29%29",
          "title": "10.2 Exceptions"
        },
        {
          "id": 3200,
          "url": "https://docs.racket-lang.org/reference/define-struct.html?q=object-name#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-struct%29%29",
          "title": "5.1 Defining Structure Types: struct"
        },
        ...
      ],
      "createDate": 1454092984398
    },
     ...
  ]
}

It’s Just a pure Json data. I make a copy of this for backup purposes. Now I can remove some items here. I did few tests to find the recommended size, I prefer to limit to 1000. Besides that make sure the id of the last item is the same as the value of idCounter in itemTable.

Data is ready, But …

You can’t make this patch work if chrome is running. Basically, all the chrome’s instances must be terminated before you are touching the extension data. To do so, you might use some commands like: kill, top or htop, etc.

Finally just replace the state field of itemTable with the modified version of the json data. And of course, OneTab is back!

Advertisements