Skip to content

Commit a3a4aa0

Browse files
committed
fix
1 parent 15d0faf commit a3a4aa0

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

extensions/shared/src/main/java/app/revanced/extension/shared/patches/spoof/requests/StreamingDataRequest.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class StreamingDataRequest private constructor(
8484

8585
companion object {
8686
private const val AUTHORIZATION_HEADER = "Authorization"
87-
private const val MAX_MILLISECONDS_TO_WAIT_FOR_FETCH = 20 * 1000
87+
private const val MAX_MILLISECONDS_TO_WAIT_FOR_FETCH = 10 * 1000
8888

8989
private val SPOOF_STREAMING_DATA_TYPE: YouTubeAppClient.ClientType =
9090
BaseSettings.SPOOF_STREAMING_DATA_TYPE.get()
@@ -97,11 +97,11 @@ class StreamingDataRequest private constructor(
9797

9898
@GuardedBy("itself")
9999
val cache: MutableMap<String, StreamingDataRequest> = Collections.synchronizedMap(
100-
object : LinkedHashMap<String, StreamingDataRequest>(100) {
101-
private val CACHE_LIMIT = 50
100+
object : LinkedHashMap<String, StreamingDataRequest>(10) {
101+
private val CACHE_LIMIT = 10
102102

103103
override fun removeEldestEntry(eldest: Map.Entry<String, StreamingDataRequest>): Boolean {
104-
return size > CACHE_LIMIT // Evict the oldest entry if over the cache limit.
104+
return size >= CACHE_LIMIT // Evict the oldest entry if over the cache limit.
105105
}
106106
})
107107

extensions/shared/src/main/java/app/revanced/extension/shared/utils/Utils.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -129,23 +129,28 @@ public static void hideViewByRemovingFromParentUnderCondition(boolean condition,
129129
*/
130130
private static final ThreadPoolExecutor backgroundThreadPool = new ThreadPoolExecutor(
131131
3, // 3 threads always ready to go
132-
Integer.MAX_VALUE,
132+
10,
133133
10, // For any threads over the minimum, keep them alive 10 seconds after they go idle
134134
TimeUnit.SECONDS,
135135
new SynchronousQueue<>(),
136136
r -> { // ThreadFactory
137137
Thread t = new Thread(r);
138-
t.setPriority(Thread.MAX_PRIORITY); // run at max priority
138+
t.setPriority(Thread.NORM_PRIORITY); // run at norm priority
139139
return t;
140-
});
140+
},
141+
ThreadPoolExecutor.DiscardPolicy()
142+
);
141143

142144
public static void runOnBackgroundThread(@NonNull Runnable task) {
143145
backgroundThreadPool.execute(task);
144146
}
145147

146148
@NonNull
147149
public static <T> Future<T> submitOnBackgroundThread(@NonNull Callable<T> call) {
148-
return backgroundThreadPool.submit(call);
150+
ThreadPoolExecutor submitThreadPool = backgroundThreadPool;
151+
submitThreadPool.allowCoreThreadTimeOut(true);
152+
153+
return submitThreadPool.submit(call);
149154
}
150155

151156
/**

0 commit comments

Comments
 (0)