From b0b6ff6a82820d4578c5cfc5f69ae7aaaac49c7f Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Wed, 27 Sep 2023 18:54:47 +0400 Subject: [PATCH] fix(YouTube - Client spoof): fix occasionally frozen video playback (#486) --- .../integrations/patches/spoof/SpoofSignaturePatch.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/spoof/SpoofSignaturePatch.java b/app/src/main/java/app/revanced/integrations/patches/spoof/SpoofSignaturePatch.java index 4c3fbaa6..69f00abf 100644 --- a/app/src/main/java/app/revanced/integrations/patches/spoof/SpoofSignaturePatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/spoof/SpoofSignaturePatch.java @@ -68,6 +68,8 @@ public class SpoofSignaturePatch { /** * Injection point. * + * Called off the main thread, and called multiple times for each video. + * * @param parameters Original protobuf parameter value. */ public static String spoofParameter(String parameters) { @@ -96,9 +98,14 @@ public class SpoofSignaturePatch { String videoId = VideoInformation.getVideoId(); if (!videoId.equals(currentVideoId)) { - currentVideoId = videoId; rendererFuture = ReVancedUtils.submitOnBackgroundThread(() -> getStoryboardRenderer(videoId)); + currentVideoId = videoId; } + // Occasionally when a new video is opened the video will be frozen a few seconds while the audio plays. + // This is because the main thread is calling to get the storyboard but the fetch is not completed. + // To prevent this, call get() here and block until the fetch is completed. + // So later when the main thread calls to get the renderer it will never block as the future is done. + getRenderer(); return INCOGNITO_PARAMETERS; }