Hi guys
I would like to do an experiment with the new "Threading System" to see if it helps with the HTML5 dilemma I'm having, but have no idea, how to use it.
Currently, when I export to HTML5, Gideros seems to load the whole game into memory before starting.
Is there a way I can use the threading system to load atlases in the background, instead of all at once.
PS. I'm currently loading one Atlas per Level, yet the HTML5 export still seems to load all of the game into memory before starting.
Thank you in advance for any ideas
Comments
I don't think the new threading system will help you with your loading issue. As said before, in HTML5 all assets are loaded in memory even before lua is called.
However, you could put your per-level assets on a server and load them on-demand with UrlLoader. See ImageLoader example: in your case you can save the image files in temp dir (|T|), load a texture from them, and immediately remove the temp file.
https://deluxepixel.com
1. A slider selects levels.
2. When the slider stops it loads the level with asyncCall.
3a. If the slider remains in the same position when the asyncCall is done, it shows the level in the background.
3b. If the slider stops at another level before asyncCall is done, it discards the previous asyncCall, and starts loading the new level instead.
Likes: antix
What you could do is load the assets in a loop, with itself in a retry loop. At one part of the loop check to see if a new selection has been made, if it has then break out of the loading loop and loop back for the retry.
eg (this code I just typed here, it might not work!):
Likes: totebo, hgy29
https://deluxepixel.com
https://deluxepixel.com
But on the other hand, it is a better practice to gracefully end your thread within itself, like @SinisterSoft suggested.
Thanks for reporting your experiments about them here, we think it is a great feature but you will know better
Likes: SinisterSoft
Likes: totebo
https://deluxepixel.com
Likes: antix, totebo
https://deluxepixel.com
https://deluxepixel.com
Luckily the lag is much less noticeable on newer devices.
What you could do is have one very large image split into say 32 parts.
Figure out the scaling and define the right size of texture for the device.
Define a rendertexture for that size. So an old phone will have a smaller texture than a new retina device.
Draw each section of the image scaled to the rendertexture.
Draw the render texture to the screen.
This way you only need one version of the image - for all your devices - and you can put in a loading bar that has 32 sections and does get updated whilst it loads.
https://deluxepixel.com
Big scenes take some time to load, and they have to be completely loaded before they can be displayed, making the player hang for a while on scene transition.
If I write the async code in the init section of the scene it won't be accessible until the whole scene is loaded, if I write it in sceneManager:changescene I obviously can't tell at which point of the loading progress it is. So I guess it's not possible.. but maybe someone has a great idea
Thank you
I am using a progress flag as you suggested to keep track of my loading status. The status is updated some times in the init function of my scene.
However it seems that the new scene is being executed only after it has been fully loaded, so everything in newscene:init would be available only after the scene is loaded, which means that the "lag" has happened already.
I tried also placing the asyncCall code in my previous scene (just before calling changeScene ) and in scenemanager:changescene() itself:
unfortunately I was unable to avoid the lag when the next scene is loaded: the progressbar won't appear until just after the lag, and then it fills in a hurry (and is being removed).
I made a test project using scenemanager source example and a really huge number of liquidfun particles to quickly simulate a complex scene. In most cases the progressbar is removed "at the same time" it is placed so you won't even see it, but you can feel the lag.
The progressbar should appear before lagging and do at least 2 steps to give the illusion that the phone is not stuck.. :P
asyncCall code is in scenemanager:changeScene(..)
The lag is better seen on device since laptop handles things faster.
Am I doing something wrong or is this a "limit" of asyncCall/scenemanager combo?
thank you
I modified a little your project, see attached and tell me if it is what you wanted to achieve. While doing this I discovered a bug with fakethreads, which cause fakethreads to be stuck under heavy cpu load. Some test for that case in gideros code was buggy and will be fixed in some future release. Meanwhile I commented out your liquidfun world:step().
Likes: pie
I didn't get that I had to use 2 distinct asyncCall to switch between those, I thought that the main thread was enough.
I tried using your scenemanager in my existing project but I get an error:
scenemanager.lua:298: attempt to index local 'options' (a thread value)
what is a thread value, and why options is not a table as usual?
However as soon as this works (it works in the example project so I assume there is just some tweak to do) it should be pushed to scenemanager github: it's a golden feature for scenemanager
Thank you again
However I don't why your options contains a thread. Threads are returned by Core.asyncCall() they represent the lua view of a fakethread, ie a coroutine.
Likes: pie
In addition after changing the scenes 5-6 times screen becomes like this in the attachment. (ss1)
I made a clean install of new gideros studio and player from the website before posting.
It works as it should on device, while on laptop it fails to show the scene - which is loaded because I can see its printouts. I will try to figure this out but since it happens on a heavy cpu load scene I wonder if it's better to try this after you manage to fix the fakethreads bug you were speaking about earlier
Thank you