From f72faa761cca306952f270208bee4a8f59c59dda Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Wed, 7 Feb 2024 19:25:46 +0400 Subject: [PATCH 1/2] fix(YouTube - Litho Filter): Ignore null buffers (#565) --- .../patches/components/LithoFilterPatch.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/components/LithoFilterPatch.java b/app/src/main/java/app/revanced/integrations/youtube/patches/components/LithoFilterPatch.java index f98a5bb2..f77a9ac5 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/components/LithoFilterPatch.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/components/LithoFilterPatch.java @@ -503,12 +503,18 @@ public final class LithoFilterPatch { * Injection point. Called off the main thread. */ @SuppressWarnings("unused") - public static void setProtoBuffer(@NonNull ByteBuffer protobufBuffer) { + public static void setProtoBuffer(@Nullable ByteBuffer protobufBuffer) { // Set the buffer to a thread local. The buffer will remain in memory, even after the call to #filter completes. // This is intentional, as it appears the buffer can be set once and then filtered multiple times. // The buffer will be cleared from memory after a new buffer is set by the same thread, // or when the calling thread eventually dies. - bufferThreadLocal.set(protobufBuffer); + if (protobufBuffer == null) { + // It appears the buffer can be cleared out just before the call to #filter() + // Ignore this null value and retain the last buffer that was set. + Logger.printDebug(() -> "Ignoring null protobuffer"); + } else { + bufferThreadLocal.set(protobufBuffer); + } } /** @@ -523,15 +529,13 @@ public final class LithoFilterPatch { ByteBuffer protobufBuffer = bufferThreadLocal.get(); final byte[] bufferArray; - // The buffer can be null or empty when using YT 19.x. - // This is likely caused by different threads setting the buffer and calling this method. - // 100% fixing this would require passing the buffer into this method (which may not be so simple). - // For now, still filter with an empty buffer so the non proto buffer filters work correctly. + // Potentially the buffer may have been null or never set up until now. + // Use an empty buffer so the litho id/path filters still work correctly. if (protobufBuffer == null) { - Logger.printDebug(() -> "Proto buffer is null"); + Logger.printDebug(() -> "Proto buffer is null, using an empty buffer array"); bufferArray = EMPTY_BYTE_ARRAY; } else if (!protobufBuffer.hasArray()) { - Logger.printDebug(() -> "Proto buffer does not have an array"); + Logger.printDebug(() -> "Proto buffer does not have an array, using an empty buffer array"); bufferArray = EMPTY_BYTE_ARRAY; } else { bufferArray = protobufBuffer.array(); From cdd8db766edf941cd6bbc137580b51f9a592dd4d Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 7 Feb 2024 15:28:43 +0000 Subject: [PATCH 2/2] chore(release): 1.3.2-dev.1 [skip ci] ## [1.3.2-dev.1](https://github.com/ReVanced/revanced-integrations/compare/v1.3.1...v1.3.2-dev.1) (2024-02-07) ### Bug Fixes * **YouTube - Litho Filter:** Ignore null buffers ([#565](https://github.com/ReVanced/revanced-integrations/issues/565)) ([f72faa7](https://github.com/ReVanced/revanced-integrations/commit/f72faa761cca306952f270208bee4a8f59c59dda)) --- CHANGELOG.md | 7 +++++++ gradle.properties | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ddf8d45..103bcaaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [1.3.2-dev.1](https://github.com/ReVanced/revanced-integrations/compare/v1.3.1...v1.3.2-dev.1) (2024-02-07) + + +### Bug Fixes + +* **YouTube - Litho Filter:** Ignore null buffers ([#565](https://github.com/ReVanced/revanced-integrations/issues/565)) ([f72faa7](https://github.com/ReVanced/revanced-integrations/commit/f72faa761cca306952f270208bee4a8f59c59dda)) + ## [1.3.1](https://github.com/ReVanced/revanced-integrations/compare/v1.3.0...v1.3.1) (2024-02-07) diff --git a/gradle.properties b/gradle.properties index 9c7e8133..472f62ea 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ org.gradle.parallel = true org.gradle.caching = true android.useAndroidX = true -version = 1.3.1 +version = 1.3.2-dev.1