From 1c9c51ca5f7970774d4e0b5aad5ebcd064cac716 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Mon, 11 Dec 2023 22:30:36 +0400 Subject: [PATCH] fix(YouTube - Return YouTube Dislike): Wait until fetch is complete before allowing the first Short to start playback (#538) --- .../integrations/patches/ReturnYouTubeDislikePatch.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/app/revanced/integrations/patches/ReturnYouTubeDislikePatch.java b/app/src/main/java/app/revanced/integrations/patches/ReturnYouTubeDislikePatch.java index 38e4e54d..9a14366e 100644 --- a/app/src/main/java/app/revanced/integrations/patches/ReturnYouTubeDislikePatch.java +++ b/app/src/main/java/app/revanced/integrations/patches/ReturnYouTubeDislikePatch.java @@ -579,8 +579,6 @@ public class ReturnYouTubeDislikePatch { } final boolean waitForFetchToComplete = !IS_SPOOFING_TO_NON_LITHO_SHORTS_PLAYER && videoIdIsShort && !lastPlayerResponseWasShort; - lastPlayerResponseWasShort = videoIdIsShort; - lastPrefetchedVideoId = videoId; LogHelper.printDebug(() -> "Prefetching RYD for video: " + videoId); ReturnYouTubeDislike fetch = ReturnYouTubeDislike.getFetchForVideoId(videoId); @@ -594,8 +592,11 @@ public class ReturnYouTubeDislikePatch { // // If an asynchronous litho Shorts solution is found, then this blocking call should be removed. LogHelper.printDebug(() -> "Waiting for prefetch to complete: " + videoId); - fetch.getFetchData(10000); // Use any arbitrarily large max wait time. + fetch.getFetchData(20000); // Any arbitrarily large max wait time. } + // Set the fields after the fetch completes, so any concurrent calls will also wait. + lastPlayerResponseWasShort = videoIdIsShort; + lastPrefetchedVideoId = videoId; } catch (Exception ex) { LogHelper.printException(() -> "preloadVideoId failure", ex); }