Improve loading display and stages #114
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
gtfs.zone/coloring-book#114
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Right now the
feedProgressIndicatortop-bar only appears insideparseFile(), meaning there is a silent gap before it shows up:fetch()+response.blob()can take several seconds on a large feed — the user sees nothing during this time.file.arrayBuffer()(can be slow on large files) runs before the indicator appears.The fix is to call
feedProgressIndicator.startLoading()earlier — at the start ofparseFromURLfor URL loads and at the start ofparseFilefor file loads — and to add clearly-labelled "Downloading feed..." and "Reading file..." stages before the existing "Clearing existing data..." stage. No streaming or real download-percentage is needed; indeterminate is fine for the download stage.Relevant Context
src/modules/gtfs-parser.tsparseFile()(line 556),parseFromURL()(line 660)src/modules/feed-progress-indicator.tsFeedProgressIndicator, singletonfeedProgressIndicatorsrc/modules/ui.tsloadGTFSFile()(line 254),loadGTFSFromURL()(line 392) — orchestrators that call into gtfs-parserCurrent progress stages in
parseFile:startLoading)Key invariant:
feedProgressIndicator.startLoading(operation, ...)must be called before anyupdateProgress(operation, ...)— the indicator ignores updates for unknown operations.parseFilemust not callstartLoadingagain once the caller has already started it (that would reset the progress bar to 0).Phase 1 — Add "Downloading feed..." stage to URL path
Goal: Make the indicator appear the moment
loadGTFSFromURLis called, before the network request starts, so there is never a blank wait.parseFromURL(src/modules/gtfs-parser.ts), callfeedProgressIndicator.startLoading(operation, 'Downloading feed...')at the very top (use the sameoperation = 'parseFile'key so it shares state with the subsequentparseFilecall).response.blob()resolves, callfeedProgressIndicator.updateProgress(operation, 5, 'Preparing...')to signal the download is done.parseFromURLnow starts the indicator, guard thestartLoadingcall insideparseFileso it only fires when the indicator is not already active for that operation. CheckfeedProgressIndicator.isLoading()or pass an optional flag — simplest approach: add an optionalalreadyStarted = falseparameter toparseFileand haveparseFromURLpasstrue.parseFileto start at 5 (instead of callingstartLoadingwith 0 then immediately going to 10) when called from URL path, or just leave the "Clearing existing data..." call at 10 since the bar will jump from wherever the caller left it.Gotcha: The
operationstring inparseFromURLmust match the one used inparseFile('parseFile') sofinishLoadinginparseFile's catch/finally correctly cleans up regardless of which path started the indicator.Phase 2 — Add "Reading file..." stage to file-upload path
Goal: For direct file uploads, show the indicator before
file.arrayBuffer()is called, so large files don't produce a blank wait either.feedProgressIndicator.startLoading(operation, 'Loading GTFS file...')call inparseFileto before thefile.arrayBuffer()call — it already is before it, so this is just a status/label change.startLoading, update status to'Reading file...'at progress 0 to clearly communicate the file-read stage.await file.arrayBuffer()resolves, update to'Clearing existing data...'at progress 5 (or keep 10, adjust to taste).startLoadingmessage "Loading GTFS file..." by merging it into the firstupdateProgresscall, so the sequence is clean:startLoading(operation, 'Reading file...')→ progress 0updateProgress(operation, 10, 'Clearing existing data...')→ after arrayBuffer resolvesGotcha: When called from
parseFromURL,startLoadingis already active. ThealreadyStartedflag from Phase 1 preventsparseFilefrom resetting the bar to 0 or callingstartLoadingagain. In that path, skip directly toupdateProgress(operation, 5, 'Clearing existing data...')after the arrayBuffer call.Original Issue
The loading display right now is fine, but we should analyze the loading process and make sure that when we load a feed, we immediately show something. I think the issue is that we don't have a stage for actually downloading or uploading the feed. Lets analyze this process and see how we can improve it.