From 48ba7c8fe0ea21731144053c20e6d34af05ed605 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Wed, 16 Aug 2023 15:58:27 +0400 Subject: [PATCH] fix(YouTube - Litho Filter): Don't remove the buffer until the thread stops (#461) --- .../integrations/patches/components/LithoFilterPatch.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/integrations/java/app/revanced/integrations/patches/components/LithoFilterPatch.java b/integrations/java/app/revanced/integrations/patches/components/LithoFilterPatch.java index 2429fca44..de96efadb 100644 --- a/integrations/java/app/revanced/integrations/patches/components/LithoFilterPatch.java +++ b/integrations/java/app/revanced/integrations/patches/components/LithoFilterPatch.java @@ -425,6 +425,10 @@ public final class LithoFilterPatch { */ @SuppressWarnings("unused") public static void setProtoBuffer(@NonNull 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); } @@ -452,8 +456,6 @@ public final class LithoFilterPatch { if (pathSearchTree.matches(parameter.path, parameter)) return true; } catch (Exception ex) { LogHelper.printException(() -> "Litho filter failure", ex); - } finally { - bufferThreadLocal.remove(); // Cleanup and remove the buffer. } return false;