PixiJS Assets maxConcurrency exceeding browser connection limits causes queuing latency
0 reputation · 17 Aug 2021, 13:20 UTC
0 reputation · 17 Aug 2021, 13:20 UTC
When loading many assets with Assets.load() the total load time grows disproportionately once the number of simultaneous requests surpasses the browser's per‑origin connection limit. The default maxConcurrency of 10 can exceed the ~6 concurrent connections allowed under HTTP/1.1, so excess requests are queued and experience added latency.
maxConcurrency?35775 reputation · 17 Aug 2021, 16:27 UTC
The default maxConcurrency: 10 in PixiJS Assets v7+ exceeds the typical browser per-origin connection limit of ~6 under HTTP/1.1. When the pool size surpasses the browser's actual capacity, excess requests sit in the browser's internal queue, adding latency that grows with the number of assets. Under HTTP/2 the limit is higher (roughly 6–10 concurrent streams), but the same queuing behavior appears once the stream cap is reached.
maxConcurrency controls all Assets.load() calls. The default of 10 is chosen for HTTP/2 environments and will trigger browser queuing on HTTP/1.1.When the internal pool size exceeds the browser's connection or stream limit, the browser queues the excess requests. PixiJS's own queue then shows those requests as "pending" while they wait for a free browser slot. This double-queue effect is what produces the disproportionate latency growth. The exact stream cap varies by browser vendor, version, and TLS configuration, so the 6/10 figures are guidelines, not specifications.
Assets.maxConcurrency accordingly:
if (window.location.protocol === 'http:') {
// Heuristic: assume HTTP/1.1 if not HTTPS
Assets.maxConcurrency = 6;
} else {
// HTTPS usually means HTTP/2 capable
Assets.maxConcurrency = 8; // conservative HTTP/2 cap
}
Assets.load(criticalManifest) before the bulk load. The global pool still applies, but the first call gets the first available slots.
await Assets.load(criticalManifest); // first-frame textures
await Assets.load(restManifest); // remaining assets
maxConcurrency are active, lower the value until queuing disappears.Assets.load().As of PixiJS v7.x there is no supported priority flag on individual Assets.load() calls. The only way to guarantee first-frame textures load ahead of others is to sequence the loads as shown above. A future release may add a priority option; check the changelog for v8+.
What protocol does your production origin serve (HTTP/1.1 or HTTP/2), and do you control the server configuration? The answer determines whether a static maxConcurrency: 6 is safe or whether you can keep a higher value with HTTP/2.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.