Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[core] Incremental offline downloads #6446

Merged
merged 4 commits into from
Sep 26, 2016
Merged

Conversation

jfirebaugh
Copy link
Contributor

Don't allow OfflineDownload to flood the request queue. Fixes #4414.

@mention-bot
Copy link

@jfirebaugh, thanks for your PR! By analyzing this pull request, we identified @mourner, @1ec5 and @tmpsantos to be potential reviewers.

@jfirebaugh jfirebaugh force-pushed the incremental-offline-download branch from 67894fc to 81bb29f Compare September 23, 2016 22:48
@tobrun
Copy link
Member

tobrun commented Sep 26, 2016

I was thinking of picking up this gl-school ticket. Really cool to see it happening and need to admit I wouldn't have come up with same code. 👀 and 📓 ✏️ 'ing.

if (status.complete()) {
setState(OfflineRegionDownloadState::Inactive);
}
continueDownload();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we call continueDownload() also on error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A request that errors will be retried after some delay. So in that sense it's still "active" and consuming resources, notably the request object, its timer, and network resources when the timer fires.

We could try to squeeze in subsequent requests while we wait for the errored request to retry. But that risks overloading the upstream request queue -- defeating our own metering here -- if there are a lot of errored requests that all come up for retry at the same time.

Many times, the cause of a request error will apply to many requests of the same type. For instance if a server is unreachable, all the requests to that host are going to error. In that case, continuing to try subsequent resources after the first few errors is fruitless anyway.

I'll add the above rationale as a comment.

Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit; otherwise looks good.

result.requiredResourceCount += spriteResources(parser).size();
result.requiredResourceCount += glyphResources(parser).size();
if (!parser.glyphURL.empty()) {
result.requiredResourceCount += parser.fontStacks().size() * 256;
Copy link
Contributor

@1ec5 1ec5 Sep 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Factor 256 (used multiple times here) into a global constant?

@jfirebaugh jfirebaugh merged commit a9842db into master Sep 26, 2016
@jfirebaugh jfirebaugh deleted the incremental-offline-download branch September 26, 2016 21:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants