[suggestion] load the necessary images of layout

Discussion and feedback on Construct 2

Post » Thu Jan 09, 2014 5:02 pm

@Ashley - I think it should be an option we could choose, because the offline cache is only useful for some games and platforms. For those of us with larger games that aren't targeting the open web or platforms you mentioned, the offline cache is irrelevant because we're not using it since the game is offline anyway. Loading an entire large downloaded game at startup in those circumstances seems really unnecessary, and might limit some of what we can do from the high memory use (imagine something like an rpg with HD assets all being loaded at once). In addition, even if I wanted to use the offline cache for my game - which I don't - 99% of the time I'm running my game is in preview, which would load far faster if C2 had this feature.

This is one of those scenarios where choosing to have the feature or not causes problems for the people who are on the other side of the fence - which is why having an option to choose would be optimal for all users (something simple like if use offline cache is set to on, all manual memory management events are ignored).Arima2014-01-09 17:06:01
Moderator
B
94
S
33
G
33
Posts: 3,006
Reputation: 27,744

Post » Thu Jan 09, 2014 8:17 pm

@jayderyu - I think you're talking about something else - the suggestion in this topic is not to download assets until they're needed. If you switch between layouts, right now that means everything is already downloaded but it still needs to load stuff in to memory. If there is 250mb of images to load in to memory in the next layout, that's just plain and simple a lot of work, and even a native engine is going to take a few seconds to get through that (indeed, that all happens in the browser engine which is actually native code). So that's simply a very large amount of work given the current capabilities of computers.

@Arima - if your game is already offline (e.g. node-webkit), then there is nothing to download. As above, there may still be pauses between switching layouts not because anything is being downloaded, but simply because loading all the images in to memory can take a moment. And to clarify, layout-by-layout memory management means it does not load the entire game to memory on startup, only the first layout, and when you switch layout it only loads the next layout's images, and so on.Ashley2014-01-09 20:18:57
Scirra Founder
B
387
S
230
G
88
Posts: 24,251
Reputation: 192,464

Post » Thu Jan 09, 2014 8:55 pm

[QUOTE=Ashley]@Arima - if your game is already offline (e.g. node-webkit), then there is nothing to download. As above, there may still be pauses between switching layouts not because anything is being downloaded, but simply because loading all the images in to memory can take a moment. And to clarify, layout-by-layout memory management means it does not load the entire game to memory on startup, only the first layout, and when you switch layout it only loads the next layout's images, and so on.[/QUOTE]

@Ashley - Sorry, I suppose I wasn't clear - I'm aware of what you stated. By "Loading an entire large downloaded game" I wasn't referring to downloading assets from the internet when running a node webkit game, I was talking about a node webkit game that had been downloaded before running, and loading all of the assets from disk at once at the start being unnecessary, increasing startup and preview times, since as I understand it even with layout by layout loading, all files are loaded into ram at the start, they're just not all loaded into VRAM on the GPU at once.

Also, with the actions I mentioned before, I was theorizing that in addition to the action to preload assets from disk, there could also potentially be an action that could preload stuff to the GPU like CC had, which could be used to eliminate that pause. Perhaps this is better wording:

Use offline cache: on (same as current, loads or downloads everything at start)
Use offline cache: off (loads or downloads files of only the first layout)

Preload layout assets to RAM - downloads from Internet or loads from disk, depending on platform. Happens invisibly behind the scenes
Preload layout assets to GPU - sends assets of a layout to the GPU. If the files have not been downloaded or loaded from disk yet, they are downloaded/loaded first.
And triggers for each when they're done.Arima2014-01-09 20:58:33
Moderator
B
94
S
33
G
33
Posts: 3,006
Reputation: 27,744

Post » Thu Jan 09, 2014 10:20 pm

I think the browser keeps the compressed image data in memory, but can flush it out if it runs out of memory and load it from disk again later if things get tight. However if it does not even keep the compressed image data in memory, the pauses between layouts will get even longer, since it not only has to decode the compressed image but also go all the way to disk to load it. Are you sure that's what you want?

I'm not sure adding actions to manage texture creation is such a good idea - what could you do that's better than layout-by-layout loading without either using even more memory or having janky games which keep loading textures mid-game?
Scirra Founder
B
387
S
230
G
88
Posts: 24,251
Reputation: 192,464

Post » Thu Jan 09, 2014 10:44 pm

I could see where it would be useful for something that's rarely seen like a powerup, or a badge, notifications, etc.
For example you might have a little in-game tutorial that the player can go back and look at.

Then again those images would probably take up little memory, or placed in another layout.
Image ImageImage
B
168
S
50
G
164
Posts: 8,238
Reputation: 105,595

Post » Thu Jan 09, 2014 11:06 pm

Sorry I haven't managed to make this clear. Here's an example:

Current scenario, with C2 as is: on preview or double-clicking a node webkit exe, NW or the browser starts up and loads all of the files from disk into memory, decompresses the needed ones for the first layout, sends them to the graphics card and starts the game. For this example, let's say with this process the game takes 1 minute to load.

Suggested scenario: on preview or double-clicking a node webkit exe, NW or the browser starts up and loads the files for the first layout from disk into memory, decompresses them, sends them to the graphics card and starts the game. This will result in the game loading in a fraction of the time.

With no interaction, the game will not load any other layout's images, from disk or into VRAM, and upon switching layouts, the game will pause as it loads the images from disk, decompresses them and sends them to the gpu. While that at first seems like it's worse, it's actually better when used with the actions I suggested, which results in this:

- On preview or double-clicking a node webkit exe, NW or the browser starts up and loads the files for the first layout from disk into memory, decompresses them, and sends them to the graphics card. This starts the game much quicker than loading everything at the start.

- First layout starts with a company logo and maybe an intro sequence before showing title screen. At the start of this layout, the action 'preload layout images to ram: "Level 1" is run. While the user watches the logo/intro and messes with the settings in the title, the game loads level 1's images from disk. This is basically what C2 does automatically once with the loader layout, except in this case it doesn't load the whole rest of the game - just the layout specified. When complete, this trigger event runs:

-> on finished loading images to ram: "Level 1"
   -action: preload layout images to VRAM: "Level 1"

Now C2 loads level 1's images to VRAM, while the user continues through the title layout. When it's done:

-> on finished loading images to VRAM: "Level 1"
   - action: set variable level1loaded to true

Now, when the player clicks new game and goes to level 1's layout, there will be no loading times at all, not to get the files from disk or into VRAM.

If the player clicks new game before the loading is complete:

->If clicked on new game
Level1loaded is false
- action: show layer: "Loading"

-> on finished loading images to VRAM: "Level 1"
If layer "Loading" is visible
- action: go to layout "Level 1"

At the start of layout "Level 1"
- action: preload layout images to ram: "Level 2"

...and level 2 loads in the background as the player plays level 1.

Using this method, all loading aside from the initial layout can be hidden, as long as the player doesn't tear through the startup screen, and even if they do, as I showed in my example, then an animated loading screen can be shown, and this would solve the problem Jayderyu was having with the music pausing as well when the game pauses for too long.

The result: even the most impatient player will be playing level 1 long before the game would have loaded otherwise if the entire game needed to be loaded. This would help a lot also for online games, getting them into the action quicker since downloading is slower. Maybe an extra action could be made: 'create offline cache' which would then download everything that hasn't already loaded. This way we could have both reduced start times and create an offline cache, the best of both worlds for the platforms that would use offline cache.

It would also benefit preview times tremendously, as it would only load the single layout, instead of the whole game, and I don't know about others, but most of the times I preview it's to test one layout. Larger games do start taking a while to load without something like this.

Again, this could be an option, so those who don't want or need to use it don't have to, and can keep using C2 as it currently is. It's one of the features I want most, actually, because of the reduced preview times.Arima2014-01-09 23:27:58
Moderator
B
94
S
33
G
33
Posts: 3,006
Reputation: 27,744

Post » Thu Jan 09, 2014 11:42 pm

@Arima: +1

I dislike when people do the +1 thing, but i don't have anything to add, and i need to express my support. Kudos on the detailed post and persistence.


Be nice until it's time to not be nice
B
36
S
9
G
9
Posts: 293
Reputation: 6,662

Post » Fri Jan 10, 2014 2:49 am

@Ashley

Since the key of initial loading is file "offline.appcache". It might be better to have an exported option in C2 editor which could turn on/off the file "offline.appcache" (have it or not, maybe).

The action of loading asserts from server manually is another issue. I like it, too.
B
108
S
26
G
260
Posts: 4,435
Reputation: 146,195

Post » Fri Jan 10, 2014 3:13 am

+1 on Arima's last comment
B
12
S
3
G
1
Posts: 347
Reputation: 2,866

Post » Fri Jan 10, 2014 4:48 am

+1 on Arima
B
34
S
11
G
3
Posts: 97
Reputation: 3,453

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 1 guest