From 835b7bd7bd667abd632822c98898972e5124dbb6 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Wed, 4 Jun 2025 13:45:48 +0200 Subject: [PATCH] fix(YouTube - Hide Shorts components): Disable A/B player that prevents hiding buttons (#5104) --- .../layout/hide/shorts/Fingerprints.kt | 18 ++++++++++++++ .../hide/shorts/HideShortsComponentsPatch.kt | 24 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/Fingerprints.kt index f3a6244c3..cc883425b 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/Fingerprints.kt @@ -74,3 +74,21 @@ internal val setPivotBarVisibilityParentFingerprint = fingerprint { parameters("Z") strings("FEnotifications_inbox") } + +internal val shortsExperimentalPlayerFeatureFlagFingerprint = fingerprint { + accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) + returns("Z") + parameters() + literal { + 45677719L + } +} + +internal val renderNextUIFeatureFlagFingerprint = fingerprint { + accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL) + returns("Z") + parameters() + literal { + 45649743L + } +} diff --git a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt index 61b29975b..551a109f7 100644 --- a/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/youtube/layout/hide/shorts/HideShortsComponentsPatch.kt @@ -18,6 +18,7 @@ import app.revanced.patches.youtube.misc.litho.filter.addLithoFilter import app.revanced.patches.youtube.misc.litho.filter.lithoFilterPatch import app.revanced.patches.youtube.misc.navigation.navigationBarHookPatch import app.revanced.patches.youtube.misc.playservice.is_19_41_or_greater +import app.revanced.patches.youtube.misc.playservice.is_20_07_or_greater import app.revanced.patches.youtube.misc.playservice.versionCheckPatch import app.revanced.patches.youtube.misc.settings.PreferenceScreen import app.revanced.patches.youtube.misc.settings.settingsPatch @@ -26,6 +27,7 @@ import app.revanced.util.forEachLiteralValueInstruction import app.revanced.util.getReference import app.revanced.util.indexOfFirstInstructionOrThrow import app.revanced.util.indexOfFirstLiteralInstruction +import app.revanced.util.returnLate import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction import com.android.tools.smali.dexlib2.iface.reference.MethodReference @@ -252,5 +254,27 @@ val hideShortsComponentsPatch = bytecodePatch( } // endregion + + // region Disable experimental Shorts flags. + + // Flags might be present in earlier targets, but they are not found in 19.47.53. + // If these flags are forced on, the experimental layout is still not used and + // it appears the features requires additional server side data to fully use. + if (is_20_07_or_greater) { + // Experimental Shorts player uses Android native buttons and not Litho, + // and the layout is provided by the server. + // + // Since the buttons are native components and not Litho, it should be possible to + // fix the RYD Shorts loading delay by asynchronously loading RYD and updating + // the button text after RYD has loaded. + shortsExperimentalPlayerFeatureFlagFingerprint.method.returnLate(true) + + // Experimental UI renderer must also be disabled since it requires the + // experimental Shorts player. If this is enabled but Shorts player + // is disabled then the app crashes when the Shorts player is opened. + renderNextUIFeatureFlagFingerprint.method.returnLate(true) + } + + // endregion } }