Align file-download scheduling with TDLib and fix forum topic loading#344
Open
tdrkDev wants to merge 2 commits into
Open
Align file-download scheduling with TDLib and fix forum topic loading#344tdrkDev wants to merge 2 commits into
tdrkDev wants to merge 2 commits into
Conversation
Foreground media (opening an image full screen, a story, a just-opened chat) loaded slowly because the app-level FileDownloadQueue withheld requests from TDLib and ordered them opposite to how TDLib schedules. TDLib has no concurrent-download cap and, among equal priorities, serves the most recently requested file first (LIFO, per td_api.tl). The queue capped DEFAULT downloads at 4, sorted equal priorities FIFO, and inferred "user intent" from priority >= 32 -- which viewport auto-download also passed, so every scrolled-past thumbnail was marked manual and became un-evictable, silting up the slots. Changes: - Make user intent explicit (userInitiated) instead of inferring it from priority; thread it from the tap gesture down to the queue. - De-saturate calculatePriority so 32 is reserved for real user actions. - Invert the equal-priority tie-break to LIFO to match TDLib. - Raise the concurrency caps and remove the 160ms inter-start gap; TDLib paces part issuance itself. - Bypass the queue for user-initiated requests so they reach TDLib at once. - Re-issue DownloadFile on user action (free bump-to-front in TDLib). - Cancel stale in-flight downloads (scan activeRequests), not just pending. - Fix an indefinite story hang: bound the synchronous wait with a timeout and never silently drop a synchronous request. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Tapping a topic while the forum root was still loading (~2s) silently dropped the load and left the screen permanently blank with nothing to retry it. handleTopicClick() clears `messages` and sets viewportPhase=Initializing, then calls loadMessages(force = true). But loadMessages returned early on `if (state.isLoading) return` -- checked before `force` was honoured -- so the forced load did nothing. With 0 messages and 0 topics the viewport never settles, so the content animates to alpha 0: no spinner, no error, no retry. - Honour force: `if (state.isLoading && !force) return`. cancelAllLoadingJobs() already tears down the in-flight load, so pre-empting is safe. - Guard the finally block with isActive so a pre-empted job (cancelled without join) can't clear isLoading after the replacement load set it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Claude pls fix long loading of chats and media 😭🙏