fix: Increase timeout for YT images from 5 seconds to 10

This commit is contained in:
LisoUseInAIKyrios 2024-03-27 20:57:49 +04:00
parent e88ec6af63
commit c893cd4608
2 changed files with 3 additions and 6 deletions

View File

@ -1,7 +1,5 @@
package app.revanced.integrations.shared.settings;
import android.preference.ListPreference;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

View File

@ -570,12 +570,11 @@ public final class AlternativeThumbnailsPatch {
boolean imageFileFound;
try {
Logger.printDebug(() -> "Verifying image: " + imageUrl);
// This hooked code is running on a low priority thread, and it's slightly faster
// to run the url connection thru the integrations thread pool which runs at the highest priority.
final long start = System.currentTimeMillis();
imageFileFound = Utils.submitOnBackgroundThread(() -> {
final int connectionTimeoutMillis = 5000;
final int connectionTimeoutMillis = 10000;
HttpURLConnection connection = (HttpURLConnection) new URL(imageUrl).openConnection();
connection.setConnectTimeout(connectionTimeoutMillis);
connection.setReadTimeout(connectionTimeoutMillis);
@ -593,7 +592,7 @@ public final class AlternativeThumbnailsPatch {
}
return false;
}).get();
Logger.printDebug(() -> "Alt verification took: " + (System.currentTimeMillis() - start) + "ms");
Logger.printDebug(() -> "Verification took: " + (System.currentTimeMillis() - start) + "ms for image: " + imageUrl);
} catch (ExecutionException | InterruptedException ex) {
Logger.printInfo(() -> "Could not verify alt url: " + imageUrl, ex);
imageFileFound = false;
@ -657,7 +656,7 @@ public final class AlternativeThumbnailsPatch {
? "" : fullUrl.substring(imageExtensionEndIndex);
}
/** @noinspection SameParameterValue*/
/** @noinspection SameParameterValue */
String createStillsUrl(@NonNull ThumbnailQuality qualityToUse, boolean includeViewTracking) {
// Images could be upgraded to webp if they are not already, but this fails quite often,
// especially for new videos uploaded in the last hour.