@@ -74,15 +74,36 @@ private static void findAsciiStrings(StringBuilder builder, byte[] buffer) {
74
74
}
75
75
}
76
76
77
+ /**
78
+ * Litho layout fixed thread pool size override.
79
+ * <p>
80
+ * Unpatched YouTube uses a layout fixed thread pool between 1 and 3 threads:
81
+ * <pre>
82
+ * 1 thread - > Device has less than 6 cores
83
+ * 2 threads -> Device has over 6 cores and less than 6GB of memory
84
+ * 3 threads -> Device has over 6 cores and more than 6GB of memory
85
+ * </pre>
86
+ *
87
+ * Using more than 1 thread causes layout issues such as the You tab watch/playlist shelf
88
+ * that is sometimes incorrectly hidden (ReVanced is not hiding it), and seems to
89
+ * fix a race issue if using the active navigation tab status with litho filtering.
90
+ */
91
+ private static final int LITHO_LAYOUT_THREAD_POOL_SIZE = 1 ;
92
+
93
+ private static final byte [] EMPTY_BYTE_ARRAY = new byte [0 ];
94
+
95
+ /**
96
+ * Placeholder for actual filters.
97
+ */
98
+ private static final class DummyFilter extends Filter { }
99
+
77
100
private static final Filter [] filters = new Filter [] {
78
101
new DummyFilter () // Replaced by patch.
79
102
};
80
103
81
104
private static final StringTrieSearch pathSearchTree = new StringTrieSearch ();
82
105
private static final StringTrieSearch identifierSearchTree = new StringTrieSearch ();
83
106
84
- private static final byte [] EMPTY_BYTE_ARRAY = new byte [0 ];
85
-
86
107
/**
87
108
* Because litho filtering is multi-threaded and the buffer is passed in from a different injection point,
88
109
* the buffer is saved to a ThreadLocal so each calling thread does not interfere with other threads.
@@ -213,9 +234,28 @@ private static boolean handleFiltering(@Nullable String lithoIdentifier, StringB
213
234
214
235
return false ;
215
236
}
216
- }
217
237
218
- /**
219
- * Placeholder for actual filters.
220
- */
221
- final class DummyFilter extends Filter { }
238
+ /**
239
+ * Injection point.
240
+ */
241
+ public static int getExecutorCorePoolSize (int originalCorePoolSize ) {
242
+ if (originalCorePoolSize != LITHO_LAYOUT_THREAD_POOL_SIZE ) {
243
+ Logger .printDebug (() -> "Overriding core thread pool size from: " + originalCorePoolSize
244
+ + " to: " + LITHO_LAYOUT_THREAD_POOL_SIZE );
245
+ }
246
+
247
+ return LITHO_LAYOUT_THREAD_POOL_SIZE ;
248
+ }
249
+
250
+ /**
251
+ * Injection point.
252
+ */
253
+ public static int getExecutorMaxThreads (int originalMaxThreads ) {
254
+ if (originalMaxThreads != LITHO_LAYOUT_THREAD_POOL_SIZE ) {
255
+ Logger .printDebug (() -> "Overriding max thread pool size from: " + originalMaxThreads
256
+ + " to: " + LITHO_LAYOUT_THREAD_POOL_SIZE );
257
+ }
258
+
259
+ return LITHO_LAYOUT_THREAD_POOL_SIZE ;
260
+ }
261
+ }
0 commit comments