phoboslab/Ejecta — pull request #378 by AshleyScirra (2014-04-17 11:18:23+00:00)
Title: Lazy loading textures for locally-sourced images

Implements lazy-loading of EJTexture for Image objects with a local src (from the App folder). Data URIs and remote images should work as before. One user reported their Construct 2 game used 70% less memory and was 10x faster to start up.

This has been battle-tested with the Construct 2 engine but you might want to do your own testing since I haven't tested other engines and I was not previously familiar with the codebase.

There should not be any breaking changes here. Some types of game might find they now jank upon the first drawImage (since it will lazy-load the EJTexture on the first use), but as mentioned previously this will happen in real browsers too, so forcing game designers to deal with this will actually improve the portability of their games.

Note the two caveats from the first commit: lazy-loaded images skip the cache so don't deduplicate their EJTextures (simply because I don't know how the cache works - you might want to edit that back in yourself but it does not affect the C2 engine), and canvas2d mode does not implement least-recently-used eviction when out of memory (which is not worse than it used to be, and also does not affect the C2 engine with the default WebGL mode).