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

Make games launch faster by loading resources in the background #5572

Merged
merged 53 commits into from
Nov 22, 2023

Conversation

D8H
Copy link
Collaborator

@D8H D8H commented Aug 16, 2023

Blocked by

Changes

  • The 1st loading screen only appear while the 1st scene is loading.
  • The other scenes are downloaded in background.
  • Big games may not have the time to load completely while users navigate in the menu in this case a 2nd loading screen may happens while the level finish to load.
  • New conditions and actions allow to make a scene display a custom loading screen.
    • An action allows to prioritize a scene to be downloaded?
    • A condition and an expression allow to follow the loading progress.
  • 3D games with a lot of animated models may display a quick loading screen while they are parsed to avoid any frame skipping during the background loading.

Documentation

@D8H D8H changed the title Clean up event container dependencies analyzer WIP: Load resources per layout Aug 17, 2023
@D8H D8H force-pushed the resources-by-layout branch 2 times, most recently from 7b95a54 to 16dbc93 Compare August 30, 2023 18:19
@D8H D8H force-pushed the resources-by-layout branch 2 times, most recently from b5d4bda to f3a5bc6 Compare September 5, 2023 14:41
@D8H D8H force-pushed the resources-by-layout branch 4 times, most recently from 7108051 to fc86020 Compare September 19, 2023 17:25
@D8H D8H force-pushed the resources-by-layout branch 2 times, most recently from a8e8c2a to e0c1b40 Compare September 21, 2023 15:28
@D8H D8H force-pushed the resources-by-layout branch 2 times, most recently from 715d45d to 36fc56d Compare October 12, 2023 16:34
@D8H D8H force-pushed the resources-by-layout branch 2 times, most recently from 0c7cdf9 to f3c8295 Compare October 18, 2023 15:15
@D8H D8H changed the title WIP: Load resources per layout Load resources per layout Oct 27, 2023
Core/GDCore/Extensions/Builtin/SceneExtension.cpp Outdated Show resolved Hide resolved
GDJS/GDJS/IDE/UsedResourcesDeclarer.h Outdated Show resolved Hide resolved
_("Preload scene"),
_("Preload a scene assets as soon as possible in background."),
_("Preload scene _PARAM1_ in background"),
"",
Copy link
Owner

Choose a reason for hiding this comment

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

Shuld we move these into a "Loading" group?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is only one action, it would look odd, unless if it's for hiding it, but it would make an extra click for users without saving any space in the list.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe we could explain in the description that most games don't need to worry about it?

Copy link
Owner

Choose a reason for hiding this comment

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

Yes please. Use a Hint in newIDE/app/src/Hints/index.js to do so. Thanks!
"For most games, the default, automatic loading of resources will be sufficient. You can use this action to ensure you start loading a specific scene. This is helpful if you want to use the expressions related to loading to display a progress/loading bar."

GDJS/GDJS/Extensions/Builtin/SceneExtension.cpp Outdated Show resolved Hide resolved
GDJS/GDJS/Extensions/Builtin/SceneExtension.cpp Outdated Show resolved Hide resolved
*
* \ingroup IDE
*/
class UsedResourcesFinder : private gd::ArbitraryResourceWorker {
Copy link
Owner

Choose a reason for hiding this comment

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

We can't use use ResourcesInUseHelper?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you mean moving the features in this class?

Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure but I had the impression that we already had a class that was made to list the resources, so I was wondering if this new class could indeed be merged with the existing one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ResourcesInUseHelper search resources by type on the whole project when the new one is searching resources per scene no matter the type. It's very likely that we will want to cross these searches at some point, but we should leave it for later.
I should rename the new class SceneResourcesFinder and move it in the same folder as ResourcesInUseHelper.

GDJS/Runtime/runtimegame.ts Outdated Show resolved Hide resolved
GDJS/Runtime/runtimegame.ts Show resolved Hide resolved
GDJS/Runtime/runtimegame.ts Outdated Show resolved Hide resolved
GDJS/Runtime/runtimegame.ts Outdated Show resolved Hide resolved
/**
* @return The progress of assets loading in background for a scene (between 0 and 1).
*/
export const getSceneLoadingProgress = (
Copy link
Owner

Choose a reason for hiding this comment

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

For GDevelop users, would it be simpler to return a percentage?

Suggested change
export const getSceneLoadingProgress = (
export const getSceneLoadingProgressPercent = (

Copy link
Collaborator Author

@D8H D8H Nov 13, 2023

Choose a reason for hiding this comment

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

A percentage is a format not a value 0.1 can be formatted "10%". Values for 0 to 1 is easier to use because you don't have to divided by 100 every time you use it, for instance to calculate the position of the right side of the bar.

It would lead to aberration like "10,000.0%" if users use an extension to format the number.

Copy link
Owner

Choose a reason for hiding this comment

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

Ok, fine to keep it then, even if we have percentages in other part of the app (sounds volume, etc...).

GDJS/Runtime/runtimegame.ts Outdated Show resolved Hide resolved
GDJS/Runtime/runtimegame.ts Outdated Show resolved Hide resolved
GDJS/Runtime/scenestack.ts Outdated Show resolved Hide resolved
GDJS/Runtime/scenestack.ts Outdated Show resolved Hide resolved
GDJS/Runtime/scenestack.ts Outdated Show resolved Hide resolved
GDJS/Runtime/runtimegame.ts Outdated Show resolved Hide resolved
GDJS/Runtime/runtimegame.ts Outdated Show resolved Hide resolved
GDJS/Runtime/runtimegame.ts Outdated Show resolved Hide resolved

/**
* Load all assets needed to display the 1st scene, displaying progress in
* renderer.
*/
loadAllAssets(
Copy link
Owner

Choose a reason for hiding this comment

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

The naming is a bit outdated but let's keep it for compatibility

@D8H D8H marked this pull request as ready for review November 15, 2023 19:06
@D8H D8H changed the title Load resources per layout Make game launching faster by loading resources in the background Nov 15, 2023
@D8H D8H changed the title Make game launching faster by loading resources in the background Make games launch faster by loading resources in the background Nov 15, 2023
@4ian 4ian added this to the After next release milestone Nov 21, 2023
@4ian
Copy link
Owner

4ian commented Nov 22, 2023

Let's go!

@4ian 4ian mentioned this pull request Nov 22, 2023
@4ian 4ian merged commit 1f85264 into master Nov 22, 2023
5 of 6 checks passed
@Bouh Bouh deleted the resources-by-layout branch July 10, 2024 20:51
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

Successfully merging this pull request may close these issues.

2 participants