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
GWT possibility to lazy load assets #5677
Conversation
# Conflicts: # backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/preloader/Preloader.java # backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/preloader/PreloaderBundleGenerator.java
13cfee7
to
95045c4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like the WebAudio PR, this has been tested for years and is known to work. I'm not sure if I could just merge this now? Should I hold off until there are more reviews?
I should mention that I don't currently use an AssetManager, so my review can't really cover any technical details.
We don't need to wait for other reviews, but I need to update CHANGES, make a comment on the main Asset manager to note that there is an emu (and compare them for changes) and will transfer the information from the first comment to the wiki. So it's good you waited. :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't notice any issues testing this locally or with a project uploaded to Itch.
Based on the idea of #4265, I implemented a solution to skip the GWT preloader if it is not needed.
The preloader prefetches all assets before the game is started. That's useful for all assets that are accessed directly from the render thread and can't get fetched asynchronously, but assets that are loaded via AssetManager don't need to be preloaded.
This PR extends the AssetFilter with a new method that can be overriden to filter assets that don't need to be preloaded, and changes the Preloader to respect this setting and the AssetManager (via AssetLoadingTask) to download the asset if not already done.
To test this, specify an own AssetFilter in your game (as described here) and override the
preload()
method. Only returnfalse
for assets that are only loaded via AssetManager and not withAssetManager.finishLoading[Asset]
. :)Runnable demo game: Lazy loading version - open the developer network tab, you'll see that the game load its assets on level start.
For those wanting to try or to use this in existing games: you can find Jitpack dependencies to use with libGDX 1.9.8 (working with 1.9.9, too), 1.9.10 and 1.9.11 here.