Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / Error when restarting the game multiple times and reloading frames

Author
Message
Wizard Ranch
2
Years of Service
User Offline
Joined: 24th Dec 2021
Location:
Posted: 4th Jan 2022 02:24 Edited at: 4th Jan 2022 02:33
Hey again!

When restarting/resetting my game, I reload all sprites and animation sprites again.
I do this because when I didn't, I got problems after doing scene_cleanup() and then scene_setup() again. The sprite numbers didn't seem to match anymore.

So however now, after restarting/resetting my game three times without closing it while playing, I get this error message:



It happens in the line which loads the frames:


What does this message mean?

I'm at a total loss what to do here.


I should note that I don't delete any sprites or frames in the process. When I tried deleting sprites before reloading them I got again error messages, probably again because the old sprites numbers didn't match anymore after scene_cleanup().
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 4th Jan 2022 08:40 Edited at: 4th Jan 2022 08:43
The problem is your image memory management, you are hitting a memory limit, -2 error code for that function is VK_ERROR_OUT_OF_DEVICE_MEMORY

Load the images somewhere else and store them in an array and use the ID's in AddAnimation***, you are loading the images again and again every time you restart your game and buggering up Vulkans allocated memory

You only need to load an image once, do this outside your game logic
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Wizard Ranch
2
Years of Service
User Offline
Joined: 24th Dec 2021
Location:
Posted: 5th Jan 2022 00:03 Edited at: 5th Jan 2022 00:45
Well initially I tried not to reload my images for every restart, but it didn't work.

After calling scene_cleanup() and then scene_setup() again, I receive this error message:


The line that creates this error is either this one:


or this one (depending on how I structure the script):


Edit:
So based on what you're saying I think this is what's happening:
When calling scene_cleanup(), all animations assigned to a sprite in the scene get deleted. So all my animations are not saved anymore.
So I have to load all sprites for every sprite animation again. However when I do that, I reload every image into the memory a second time.
While the animation sprites have been deleted, the loaded images themselves haven't. Which in return means that I simply have to use the method you described in my other post about fast animation, when reloading my animations on restart.

I think I get that so far.

However...
I think that's a terrible function of AppGameKit to delete all animation sprites when calling scene_cleanup(). It makes things so complicated! I have to reload every single animation again on every restart, or every time I return to the scene!
Imagine you create an adventure game where you constantly switch from one room to another, and can walk back and forth between scenes! There should be an option to cleanup the scene, without deleting sprite animations. E.g. simply:

jd_zoo
5
Years of Service
User Offline
Joined: 12th May 2018
Location: Nova Scotia
Posted: 5th Jan 2022 00:41
You cannot be loading the images while in your main loop. As PTC already mentioned, you need a separate initialization method that calls the _setup() and whatever lese you need to load for that scene. This is only called when required and it must be separate from the part of your program that is calling _sync every loop.
Wizard Ranch
2
Years of Service
User Offline
Joined: 24th Dec 2021
Location:
Posted: 5th Jan 2022 03:16 Edited at: 5th Jan 2022 03:36
Jd_zoo lol I'm not loading my images inside the main loop, I don't know where you read that. I have a separate function for that, that is called when I press the play button for example. Or the reset button.

Part Time Coder, I used our combined functions the way you advised.
Now I can reset the game 5 instead of 3 times before the buffer exceeds:


So it's still not really solved.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 5th Jan 2022 06:28
Quote: "After calling scene_cleanup() and then scene_setup() again, I receive this error message:
"


_cleanup() only deletes stuff created in the scene editor, stuff you create manually is down to you to manage, how are you loading your sprites?, are you resetting array indexes?, do you assign ID's manually?, without seeing your code its impossible to guess, but I am guessing here that you are looping sprites in loops based off sprite ID's? ... bad, put them in an array and loop the array indexes so if sprite ID's change it does not break your code, remember that ID's are assigned dynamically so using them in a static range loop is just asking for bugs

Quote: "I think that's a terrible function of AppGameKit to delete all animation sprites when calling scene_cleanup()."


so don't call it, call scene_fade(0) to hide everything but bewarned this will mess with your hit testing (if any) so you will need to use a state machine and filter events accordingly depending on the scene state
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 5th Jan 2022 06:56
Quote: "Now I can reset the game 5 instead of 3 times before the buffer exceeds:"


you do realize that using single images like this are the most inefficient way to render sprites?

this is why we use sprite sheets and atlases, less draw calls, it seems to me that you are overloading the Vulkan image memory buffer (it could be a bug, not sure yet)

try using the OpenGL backend

put this right at the start of your main file


Still crash?
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
DewarInversion
3
Years of Service
User Offline
Joined: 27th Mar 2021
Location:
Posted: 6th Jan 2022 20:00
Hi Wizard.
The scene editor does two things when you drag an image into the editor. It loadsImage() and puts the imageID in an array. It then creates a sprite from that image and puts this sprite Id in an array. When you use scene_cleanup() the function only deletes the sprite ID's in the sprite array (and so the sprites are removed from the scene.) But cleanup() doesn't remove the loadImage() array.

To delete all images from your program call deleteAllimages(). This should clear everything up, including the memory buffers.

Login to post a reply

Server time is: 2024-04-25 06:46:03
Your offset time is: 2024-04-25 06:46:03