fix: Prevent forced playback speed interval leak#3837
Open
hkzo wants to merge 1 commit into
Open
Conversation
The description check could keep running when window.load did not fire or had already fired. Limit the check to watch pages and stop it once maxTries is reached. Also check the subtitle on every retry so delayed description content can still be detected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a leaked description-check interval in
ImprovedTube.playerPlaybackSpeed()when "Permanent/Forced playback speed" is enabled and the playback speed is set above 1.The current description-check interval can keep running indefinitely.
Details
The existing code only clears
waitForDescriptionwhen the music subtitle check succeeds, or when thewindow.loadevent fires. On YouTube, video navigation often happens inside the SPA without a newwindow.loadevent. Also, this code may run afterloadhas already fired, so the listener will never execute. In those cases, if the subtitle check does not match, the interval is never cleared.The fix makes the interval self-contained:
/watch?pages.maxTriesis reached, even when no match is found.This prevents a leaked interval while preserving the intended short retry window for delayed YouTube description content, although this may slightly differ from the original implementation's intent.
Notes on Reproduction
To reproduce this leak, simply play any non-music video. Please note that the persistent execution of the interval is not visible unless you insert a
console.log()for tracking.Environment