rNeomy / auto-tab-discard

Use native tab discarding method to automatically reduce memory usage of inactive tabs
https://webextension.org/listing/tab-discard.html
Mozilla Public License 2.0
888 stars 76 forks source link

Unsubmitted form detection issues (e.g. on YouTube) #312

Open trlkly opened 1 year ago

trlkly commented 1 year ago

It seems that the form unsubmitted form detection logic cannot handle situations where submitting the form does not refresh the page. One common example is the YouTube comments section. If you submit a comment, that video's page will never be unloaded.

I propose an addition to the current logic: After the first key event, add a setInterval that will check the value of that element after X seconds. If the value is "", then set window.isReceivingFormInput to false and clearInterval. (Alternatively, implement the same logic but with setTimeout).

My example case is YouTube.com. I will write it out formally:

Steps to reproduce:

  1. Make sure Auto Tab Discard extension is installed and the option "Do not discard a tab when form changes are not yet submitted" is selected.
  2. Navigate to any YouTube video (e.g. YouTube Rewind 2018 https://www.youtube.com/watch?v=YbJOTdZBX1g).
  3. Start typing a comment.
  4. Submit comment, or delete all text in comment.
  5. open another tab then use Auto Tab Discard to attempt to discard the YouTube video tab.

Expected results:

YouTube video page will be discarded.

Actual results

YouTube video page is not discarded.

System info:

Browser: Chrome 106.0.5249.61 (64-bit) OS: Windows 10 Pro version 10.0.19044 (21H2, 64-bit) Auto Tab Discard version: 0.6.3.2

rNeomy commented 1 year ago

Take a look at the new logic. https://github.com/rNeomy/auto-tab-discard/blob/master/v3/data/inject/watch.js

  1. It now stores all the edited elements, and ignores them if there is no value.
  2. If a form is submitted on the page, it resets the state and deletes all the stored elements.

Please give it a try and let me know if it works.

trlkly commented 1 year ago

I take it I should just install the current version's v3 folder as an unpacked extension? Or is there a testing version of the extension I could install through the Chrome store?

On Sat, Oct 15, 2022 at 2:54 AM rNeomy @.***> wrote:

Take a look at the new logic.

https://github.com/rNeomy/auto-tab-discard/blob/master/v3/data/inject/watch.js

  1. It now stores all the edited elements, and ignores them if there is no value.
  2. If a form is submitted on the page, it resets the state and deletes all the stored elements.

Please give it a try and let me know if it works.

— Reply to this email directly, view it on GitHub https://github.com/rNeomy/auto-tab-discard/issues/312#issuecomment-1279688864, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJVFLVVIJHTBQLJVKA4ZJTWDJPMNANCNFSM6AAAAAAQ2W5PJE . You are receiving this because you authored the thread.Message ID: @.***>

rNeomy commented 1 year ago

No, there is no testing version. Just use the current master branch (v3 directory)

https://github.com/rNeomy/auto-tab-discard/archive/refs/heads/master.zip

trlkly commented 1 year ago

I have had no problems with it. It even works if I cancel the comment. I however, haven't tested on any other sites like this, as YouTube is the main reason I use your extension.

(Chrome basically never discards YouTube tabs on its own, and so I kept running into issues where the tab would get cached out. This greatly slows down shutdown, at least on my system, since it seems Chrome reads the tabs back into memory before shutdown.)

trlkly commented 1 year ago

Oh, and BTW, my main reason for suggesting setInterval was because I was concerned about performance of checking while typing without some sort of time gate. But perhaps that was a premature performance optimization.

trlkly commented 1 year ago

Is this now available in the November 1 update in the Chrome Web Store? I'm looking to stop using the developer extension and go back to the real extension.

It seems odd that the November 1 update has the version number 0.6.3.2, which seems to be the same as the September one it was before.

rNeomy commented 1 year ago

I'll submit the new version tomorrow.