Asynchronous images loading issue
Monkey Forums/Monkey Beginners/Asynchronous images loading issue
| ||
Hi, monkey experts! I am developing a game with several locations. A player can only proceed from one location to the neighbour one. For instance, if you are currently in the location #3, you can go either deeper (to the level #4) or backwards (to the level #2). Each location contains a bunch of images, which are needed to be loaded into the RAM. What I want to do is to load levels images manually while step-by-step diving deeper. If I am at the level #2, I want level #3 images to be loaded silently in the background, without any visible consequences. So, each time I'm diving a level deeper, I am launching the mojo's LoadImageAsync() method for each of the next level images. Here where the issue comes: while images have not (asynchronously!) loaded yet, the UI of my application freezes. Seemes like one of the background threads, loading images, is working inside the main thread of my application, which is responsible for the User Interface. It only unfreezes when all the images are already loaded and all the OnLoadImageComplete() methods have fired. So, I wonder, is there a way to load images REALLY in background, without making the main thread waiting? Thanks in advance. |
| ||
Here where the issue comes: while images have not (asynchronously!) loaded yet, the UI of my application freezes. Monkey pulls the images back from the loader to the mainthread when you call UpdateAsyncEvents(). It then initalizes some open gl stuff for a loaded image. So, each time I'm diving a level deeper, I am launching the mojo's LoadImageAsync() method for each of the next level images. If you don't do so already have you tried to load the images asynchronously one after another? Maybe pulling the images back all at once causes a bottleneck. Also what kind of platform/target are we talking about? |
| ||
Have you tried the Ubuntu Platform ? I also meet the same problem. while images have not (asynchronously!) loaded yet is the same to me . |
| ||
The platform I am testing on is GLFW3. If you don't do so already have you tried to load the images asynchronously one after another? It makes no sence, as it will take a lot of time, I need them to load in parallel threads. Maybe pulling the images back all at once causes a bottleneck. It doesn't seem so, in this case GUI would lag only at the moment of images pulling. In my case mainthread freezes for the whole period of images loading. Have you tried the Ubuntu Platform ? No, I haven't. My final target platform is iOS For the moment I have a temporary "solution" - I just draw a static "load screen", which holds until all the images have asynchronously loaded. But I still hope to find a real solution to achieve manual loading while diving into deeper levels. BTW, images loading process takes 2 seconds. App's update rate is 60. Thus, my app should update itself 120 times while images loading process. I placed markers in Update() method. Weird thing - it fires only 4-5 times per that 2 seconds (which means it doesn't completely freezes!). After the loading has been done, it continues updating normally. |