Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change .reset() to properly cancel running requests #49

Closed
lukastaegert opened this issue Mar 14, 2016 · 0 comments
Closed

Change .reset() to properly cancel running requests #49

lukastaegert opened this issue Mar 14, 2016 · 0 comments

Comments

@lukastaegert
Copy link

As noted in https://github.com/pixijs/pixi.js/pull/2394, it would be nice if the reset functionality of the loader would properly cancel any running tasks. On reset, I would expect the following logic:

  • If a resource has not started loading, simply remove it from the queue
  • If a resource has started loading, cancel this process; if there has already been a network request, also call XMLHttpRequest.abort()
  • If the network request has completed, one should probably still run the corresponding "after"-middlewares (could also be made an option, open for debate)

What would be the use case for this?
Maybe an applications requests a large number of assets, some of which are needed right now and some of which will probably be needed soon. Then, however, the user makes a choice that switches the context of the application and instantly changes the required assets (or at least their priority). In this situation, one would probably want to stop any downloads currently in progress (at least the ones that have not started yet, but possibly all of them) to free up download spots for the assets that are actually needed right now (recall that both the browser and the resource loader have limits on the number of concurrent downloads).

This situation might occur when switching levels in a game or when providing a zoom functionality that uses different assets for different zoom levels (which is the motivation for this request).

Currently, loader.reset() does not cancel xhr requests. In the case of PIXI sprite sheets, this can also lead to a situation where there are _image resources in the resource cache that do not have a corresponding .json resource in the resource cache of the loader.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant