rNeomy / auto-tab-discard

Use native tab discarding method to automatically reduce memory usage of inactive tabs

Home Page:https://webextension.org/listing/tab-discard.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Discarding fails when certain sites are open?

jalaziz opened this issue · comments

I recently noticed that the extension was failing to discard any tabs across any window in Chrome.

I started to investigate by activating logging and found logs similar to:

Tue Jan 17 2023 23:01:53 GMT-0800 (Pacific Standard Time) 'alarm fire' 'number.check' 'number.check'
​Tue Jan 17 2023 23:01:53 GMT-0800 (Pacific Standard Time) 'number.check is called'
​Tue Jan 17 2023 23:01:53 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​Tue Jan 17 2023 23:01:53 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Tue Jan 17 2023 23:01:53 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Tue Jan 17 2023 23:01:53 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Tue Jan 17 2023 23:01:53 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Tue Jan 17 2023 23:01:53 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Tue Jan 17 2023 23:01:53 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Tue Jan 17 2023 23:01:53 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Tue Jan 17 2023 23:01:53 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Tue Jan 17 2023 23:01:53 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Tue Jan 17 2023 23:01:53 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Tue Jan 17 2023 23:01:53 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Tue Jan 17 2023 23:01:53 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Tue Jan 17 2023 23:01:53 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Tue Jan 17 2023 23:01:53 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Tue Jan 17 2023 23:01:53 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Tue Jan 17 2023 23:01:53 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Tue Jan 17 2023 23:01:53 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'

Given the number of entries, it seems that the check was getting stuck or failing on certain tabs, but no error was being thrown. I started closing tabs one by one and narrowed down the issue to one tab (https://stackoverflow.com/questions/52995303/redis-streams-vs-kafka-streams-nats). When I closed that tab, I got logs similar to:

Tue Jan 17 2023 23:57:54 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Tue Jan 17 2023 23:57:54 GMT-0800 (Pacific Standard Time) 'number check' 'tabs that are ignored' 0
​ Tue Jan 17 2023 23:57:54 GMT-0800 (Pacific Standard Time) 'number check' 'possible tabs that could get discarded' 25
​ Tue Jan 17 2023 23:57:54 GMT-0800 (Pacific Standard Time) 'number check' 'discarding' 20

However, when I open just that site in a tab on its own, the extension seems to complete the tab check fine. It seems to fail only when there are more tabs than the threshold for discarding.

Also, during testing, I was closing and opening tabs in bulk and noticed some errors in the console similar to:

Unchecked runtime.lastError: No tab with id: 1939841211.

I'm not sure if that error is related, but it didn't seem like it was as the issue occurs even when I don't see that error.

I've been trying to narrow down a reproduction and it's been difficult, but it doesn't appear to be strictly an issue with that tab. Even with no StackOverflow tabs, the issue occurs. Although, it does seem to occur most frequently with StackOverflow or StackExchange tabs.

However, it seems to be related to at least one problematic tab, because whenever I close the tab, I suddenly see a flood of logs and discarding starts working again:

Wed Jan 18 2023 00:16:54 GMT-0800 (Pacific Standard Time) 'number.check is called'
​ Wed Jan 18 2023 00:16:54 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Wed Jan 18 2023 00:16:54 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'discarding aborted' 'tab is not old'
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'discarding aborted' 'tab is not old'
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'tabs that are ignored' 3
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'possible tabs that could get discarded' 3
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'discarding' 1
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'tabs that are ignored' 0
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'possible tabs that could get discarded' 6
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'discarding' 1
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'tabs that are ignored' 0
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'possible tabs that could get discarded' 6
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'discarding' 1
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'discarding aborted' 'tab is not old'
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'tabs that are ignored' 1
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'possible tabs that could get discarded' 5
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'discarding' 1
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'tabs that are ignored' 0
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'possible tabs that could get discarded' 6
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'discarding' 1
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'discarding aborted' 'tab is not old'
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'got meta data of tab'
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'tabs that are ignored' 1
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'possible tabs that could get discarded' 5
​ Wed Jan 18 2023 00:17:08 GMT-0800 (Pacific Standard Time) 'number check' 'discarding' 1
background.html:1 Unchecked runtime.lastError: No tab with id: 1939841384.
background.html:1 Unchecked runtime.lastError: No tab with id: 1939841394.

In the above logs, the problematic tab was closed at "00:17:08".