Collections read without member counts (1.0 RC3-6, build 48)
release-gate / verify (push) Successful in 9m18s
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 3m39s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 11m22s

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 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 23:33:09 +00:00
co-authored by Claude Opus 5.5
parent 3ddc228458
commit 71479eb9e0
3 changed files with 14 additions and 8 deletions
+1 -1
View File
@@ -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
@@ -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<String, JSONObject>? = null): Pair<List<JSONObject>, 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<String, JSONObject>? = 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<String>
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<String, JSONObject>?): 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) }
}
@@ -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
}