Repository navigation
Conversation
Every ViewModel built its own GlossoApi, so each had its own manifest lock and state. On start the Today, lessons, stories, exercises and practice screens all asked for the ~900 KB manifest at once; with an empty HTTP cache (fresh install, content version change, server switch) that downloaded it three times, and every launch sent four requests. ViewModels now use the process-wide appApi, and manifest() is single-flight: a call that waited while another fetch ran takes its result (only for the same server and language). Claude-Session: https://claude.ai/code/session_01FcVpZoyr8VdRLp1QecX1Ng
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every ViewModel built its own
GlossoApi(AppServices.newApi), each with its own manifest lock,lastManifestand HTTP client. On start several screens ask for/v1/content/manifest(~900 KB) at the same moment, so with an empty HTTP cache (fresh install, content version change, server switch) the full body was downloaded 3 times, and every launch sent 4 requests.Fix
appApi;AppServices.newApiis removed.GlossoApi.manifest()is single-flight: a call that waited while another fetch ran takes that result, only when it was for the same server and language (a switch from feat(app): let the learner point the app at a self-hosted server #15 can land mid-fetch). Later calls still revalidate with the ETag (cheap 304), so newly published content still shows up.ensureAssetVersion()goes through the same path.Measured against a local server (counted in the server log)
Session: fresh install, cold launch, skip onboarding, Lessons, Library, Today, open a lesson, practice, background, foreground, kill + relaunch.
The earlier report of ~54 full downloads was not reproducible without the proxy: with a warm cache the app sends 304 revalidations, so the proxy most likely broke the conditional requests.
Tests
GlossoApiManifestTest: 4 concurrent calls share 1 request (it fails before with 4), and a later call still revalidates.:shared:testAndroidHostTest,:androidApp:testPlaystoreDebugUnitTest,:androidApp:testFdroidDebugUnitTest,:androidApp:lintPlaystoreDebugpass.https://claude.ai/code/session_01FcVpZoyr8VdRLp1QecX1Ng