From 71479eb9e0ae9c2eb1185d1272cde65024424192 Mon Sep 17 00:00:00 2001 From: Pauljd Date: Sat, 14 Nov 2026 23:33:09 +0000 Subject: [PATCH] Collections read without member counts (1.0 RC3-6, build 48) The capacity test on Paul's server (14 November 2026) stopped at its gentlest step: a page of collections with Fields=ChildCount took 50 seconds to answer (2,040 collections), and 0.3 seconds without. Orbit no longer asks for the count; a collection read whole before is kept, and changes are noticed at the full refresh every fourth time. With that mix the server showed no strain up to ~126 requests a minute. Co-Authored-By: Claude Opus 5.5 --- android/app/build.gradle.kts | 2 +- .../tv/orbit/classic/EmbyPlaybackProtocol.kt | 18 ++++++++++++------ .../tv/orbit/classic/ServerRequestsTest.kt | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 9b9646a4..bd787fe3 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -3,7 +3,7 @@ plugins { id("org.jetbrains.kotlin.plugin.compose") } /** The release's build number: versionCode is this x 10 plus the edition's channel. */ -val ORBIT_BUILD = 47 +val ORBIT_BUILD = 48 android { namespace = "tv.orbit.classic" compileSdk = 36 diff --git a/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackProtocol.kt b/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackProtocol.kt index 135647f7..70ccc72d 100644 --- a/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackProtocol.kt +++ b/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackProtocol.kt @@ -326,8 +326,9 @@ internal class EmbySampleSession(private val transport: EmbyTransport, private v */ fun readCollections(start: Int, limit: Int, /** - * Collections already read, by ID (0.129): one whose member count (ChildCount) is unchanged is kept as it was, with no - * request for its members. A whole refresh then costs a request per page of collections, not one per collection. + * Collections already read, by ID (0.129): one read whole before is kept as it was, with no request for its members. + * A whole refresh then costs a request per page of collections, not one per collection; every fourth refresh reads + * everything again ([CollectionRefresh]), which is when a changed collection is noticed. */ known: Map? = null): Pair, Int> = readCollectionsPage(start, limit, known).let { if (it.pacedOut && it.sets.isEmpty()) throw PacedOut() else it.sets to it.total } @@ -340,7 +341,7 @@ internal class EmbySampleSession(private val transport: EmbyTransport, private v * 200 collections cut short threw away every member list already read on it, and the next round read them all again. */ fun readCollectionsPage(start: Int, limit: Int, known: Map? = null): CollectionsPage { - val reply = transport.execute(EmbyRequest("GET", "/Items?UserId=$userId&IncludeItemTypes=BoxSet&Recursive=true&StartIndex=$start&Limit=$limit&Fields=ProviderIds,ChildCount" + + val reply = transport.execute(EmbyRequest("GET", "/Items?UserId=$userId&IncludeItemTypes=BoxSet&Recursive=true&StartIndex=$start&Limit=$limit&Fields=ProviderIds" + "&SortBy=SortName&SortOrder=Ascending&EnableImages=false&EnableUserData=false", token = currentToken(), readTimeoutMs = WHOLE_SERIES_TIMEOUT_MS)) EmbyClient.expectSuccess(reply.status, false) val body = EmbyClient.parse(reply.body) @@ -666,11 +667,16 @@ internal fun timesBlurb(tagline: String?, overview: String?, leads: List internal const val TIMES_BLURB_MAX = 150 /** - * A collection read before whose member count hasn't changed (0.129), kept as it was; null when it must be read again: new, - * a different count, incomplete before, or a server that doesn't say how many members a collection has. + * A collection read whole before, kept as it was; null when it must be read again: new, or incomplete before, or a + * different member count where the server gives one. + * + * Orbit no longer asks for the count (capacity test, 14 November 2026): on Paul's server, with 2,040 collections, a page + * of collections with their member counts took 50 seconds to answer, and 0.3 seconds without. A changed collection is + * instead noticed at the full refresh every fourth time ([CollectionRefresh]). */ internal fun unchangedCollection(set: JSONObject, known: Map?): JSONObject? { val before = known?.get(set.optString("Id")) ?: return null - if (!set.has("ChildCount") || !before.optBoolean("complete")) return null + if (!before.optBoolean("complete")) return null + if (!set.has("ChildCount")) return before return before.takeIf { set.optInt("ChildCount", -1) == it.optInt("total", -2) } } diff --git a/android/app/src/test/java/tv/orbit/classic/ServerRequestsTest.kt b/android/app/src/test/java/tv/orbit/classic/ServerRequestsTest.kt index 5e19435d..02fb65bf 100644 --- a/android/app/src/test/java/tv/orbit/classic/ServerRequestsTest.kt +++ b/android/app/src/test/java/tv/orbit/classic/ServerRequestsTest.kt @@ -92,7 +92,7 @@ class ServerRequestsTest { assertNull(unchangedCollection(JSONObject().put("Id", "c1").put("ChildCount", 13), before)) // a member added assertNull(unchangedCollection(JSONObject().put("Id", "c2").put("ChildCount", 5), before)) // incomplete before assertNull(unchangedCollection(JSONObject().put("Id", "c3").put("ChildCount", 1), before)) // new - assertNull(unchangedCollection(JSONObject().put("Id", "c1"), before)) // server gives no count + assertNotNull(unchangedCollection(JSONObject().put("Id", "c1"), before)) // no count asked for: kept until the full refresh assertNull(unchangedCollection(JSONObject().put("Id", "c1").put("ChildCount", 12), null)) // a full read }