Skip to content

fix(YouTube): Improve litho filtering performance #4904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

LisoUseInAIKyrios
Copy link
Contributor

Improves litho filtering by allowing YT litho code to behave the same as unpatched.

If a component is filtered, the null sentinel value is returned at the same return index as the unpatched method. Previously the null sentinel returned early, which causes class fields and other cached values to never be set.

This change appears to improve memory usage on some devices.

Issue and fix was identified by @0xrxL

@0xrxL
Copy link

0xrxL commented May 3, 2025

@LisoUseInAIKyrios Did you used the invoke-virtual (called before return-object) register, to retrieve StringBuilder?

@0xrxL
Copy link

0xrxL commented May 3, 2025

Anyway...this fix can work or not (for this reason, every testing feedback can be helpful), but this is my current SoT with it:

Screenshot_20250504_000504_Device care

@LisoUseInAIKyrios
Copy link
Contributor Author

Both identifier and string builder are public fields on the config object. So no invoke method is needed.

For 19.16 I had to add an invoke virtual method on a parameter object to get the config, then access the identifier and builder from the field.

@LisoUseInAIKyrios LisoUseInAIKyrios merged commit 7b43986 into ReVanced:dev May 4, 2025
1 check passed
@LisoUseInAIKyrios LisoUseInAIKyrios deleted the fix/litho_filter_memory_leak branch May 4, 2025 09:55
github-actions bot pushed a commit that referenced this pull request May 4, 2025
# [5.23.0-dev.2](v5.23.0-dev.1...v5.23.0-dev.2) (2025-05-04)

### Bug Fixes

* **YouTube:** Improve litho filtering performance ([#4904](#4904)) ([7b43986](7b43986))
@LisoUseInAIKyrios
Copy link
Contributor Author

This change needs an additional fix. Multiple threads are using the same litho object, which means storing the filtering result in an object field won't work unless it's stored in a thread local.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants