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 Classic Chat / [BUG?] Error: Ran out of GPU memory in main.agc at line

Author
Message
PSY
Valued Member
4
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 2nd Oct 2020 18:12 Edited at: 2nd Oct 2020 18:25
Hi folks,

Today, I played around with a game I coded with AppGameKit Classic on a Samsung Galaxy S4.
Everytime I suspended the app ( Home button ) and tabbed back in, this error occurred:
Error: Ran out of GPU memory in main.agc at line 212

I had a look at the code, and the line the error occurred was the Sync() command.

So I tested the following code:


The SAME error popped up when I tabbing out and back in.
I exported to Android using different APIs, but it didn't make a difference.

I've never seen this error before, so I guess something must have changed with one of the latest patches....


Can anybody confirm? I haven't tested exporting with Studio yet...

(edit) I just checked a game ( Space Haze ) that I last updated some time ago ( March 11th, 2020 ), and tabbing in and out works flawlessly. So the problem seems to occur only in AppGameKit builds as from later than March 11th


PSY


PSY LABS Games
Coders don't die, they just gosub without return
BITBITBIT
3
Years of Service
User Offline
Joined: 2nd Apr 2017
Location:
Posted: 4th Oct 2020 04:47 Edited at: 4th Oct 2020 04:48
I have tried using the lastest AppGameKit, but with older Android phone (Xperia Z3). That error pops out when trying to choose image. Probably AppGameKit is using especially large cache of memory, and older phone ran out of RAM?
None of that error in newer phones
PSY
Valued Member
4
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 4th Oct 2020 12:58 Edited at: 4th Oct 2020 12:59
BITBITBIT,

Thank you for reproducing the error on an older phone.

You could be right, there seems to be some memory allocation problem when tabbing back into the app.

I just ran the following 4-liner and got the following error using STUDIO:

Error: Ran out of GPU memory, try using smaller or fewer images in main.agc at line 3

Quote: "
do
Print( ScreenFPS() )
Sync()
loop"


Would be nice to know if this is still a bug on older phones that can be fixed, or if not, what phones are actually supported ( regarding GPU RAM ) !
Any info from the devs maybe?


PSY


PSY LABS Games
Coders don't die, they just gosub without return
PSY
Valued Member
4
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 5th Oct 2020 22:14 Edited at: 5th Oct 2020 22:15
Posted on GitHub

https://github.com/TheGameCreators/AGK-Studio/issues/738


PSY LABS Games
Coders don't die, they just gosub without return
houndog66
1
Years of Service
User Offline
Joined: 1st Mar 2019
Location:
Posted: 13th Oct 2020 10:23
Just compiled a tiny timer app with about 3 sprites and I get the same error on my Galaxy S5, it returns the sync() command as where the error happens too.
fubarpk
Retired Moderator
15
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 13th Oct 2020 12:22
makes sence that if the gpu memory is overfull that the error happens at sync but why tabbing out causes it is just strange

fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
SFSW
18
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 13th Oct 2020 15:32
This bug also appears to prevent an app from being quickly restarted after being shut down. It's a pretty serious flaw that needs to be addressed in both Classic and Studio. As a severe crash bug with consistency, I'd hope a quick hotfix would be made available to correct it.
tarkusAB
4
Years of Service
User Offline
Joined: 15th May 2016
Location: Tokyo, JP
Posted: 21st Oct 2020 02:19
I am getting this error running my game on Windows. Been running smooth until this month....probably the same problem, but not sure.

I took some measurements. At the start of the frame, 28 images are in memory at 148MB. That frame, I loaded 4 large images bringing the GPU memory up to 323MB. (These totals are being reported with GetImageMemoryUsage()) At the end of this frame, when sync() is run at the end of the loop it crashes with that same error. Clearly I'm not overloading my GPU memory. Is it bad practice to load too many large images into memory before one sync() call? Either that, or maybe loading the large images is just making the program hang, similar to suspending on a phone....
blink0k
Moderator
7
Years of Service
Recently Online
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 21st Oct 2020 04:28 Edited at: 21st Oct 2020 04:32
I have a Sony L1.
I ran your test (From your first post), pressed home, ran another app, switched back and had no issues with it. it continues to show the frame rate and does not crash
i Have Studio V2020.07.28
Tried Classic 2020-05-04 and it worked ok as well
adambiser
AGK Developer
5
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 21st Oct 2020 06:06
I also experience this problem on a LG K20 Plus, Android 7.0 and can get it to happen with this code:

I mentioned this to Rick via email back in August, but it hasn't been resolved. I can not reproduce the bug when compiled with Classic 2019.09.27.

I had wondered whether this Sync "Ran out of GPU memory" error when restoring the app is related to this change mentioned for 2020.04.30 (before the "c" update):
Quote: ""Android apps resuming from background will now resume faster""


Classic 2020.04.30c also crashes when the Android bytecode interpreter reaches the end of the byte code.
PSY
Valued Member
4
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 21st Oct 2020 12:00 Edited at: 21st Oct 2020 12:01
Thanks so much for testing this guys

@tarkusAB
Doesn't seem to be related to images sizes at all, as codes without any images also crash

@blink0k
Have you tried to suspend/resume multiple times in a row?

@adambiser
Nice find. That change actually may be the reason for this strange behaviour...


PSY LABS Games
Coders don't die, they just gosub without return
blink0k
Moderator
7
Years of Service
Recently Online
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 21st Oct 2020 20:02
Yes. Still works
You didn't mention which version of AppGameKit you were using
PSY
Valued Member
4
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 21st Oct 2020 23:53
Oh...sorry.

Classic 2020.04.30c
Studio V2020.07.28


PSY LABS Games
Coders don't die, they just gosub without return
adambiser
AGK Developer
5
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 22nd Oct 2020 02:15 Edited at: 22nd Oct 2020 02:32
Additional information from when I first experienced the bug:

1) Tap the game icon to start it.
2) Hit the Home key on the device to return to the home screen.
3) Tap the game icon again.
Doesn't always happen, but does pretty often. After the error shows up, the game must be force closed.
I could duplicate the crash by going back into the game using the task manager, only by going back into the game by tapping the icon on the home screen (or the apps list).

Duplicated on an LG K20 Plus, Android 7.0 with 2020.04.30c.
Could not duplicate on a Samsung S6 Edge, Android 7.0.

EDIT: Looking at the GPUs for the phones mentioned here...

Crashing:
Samsung Galaxy S4 - Qualcomm Adreno 320 - OpenGL ES 3.0
Xperia Z3 - Qualcomm Adreno 330 - OpenGL ES 3.0
Galaxy S5 - Qualcomm Adreno 330 - OpenGL ES 3.0
LG K20 Plus - Qualcomm Adreno 308 - OpenGL ES 3.0

Working:
Sony Xperia L1 - ARM Mali-T720MP2 - OpenGL ES 3.1
Samsung Galaxy S6 Edge - ARM Mali-T760 - OpenGL ES 3.1

So either something to do with them having a Adreno 3xx GPU or having OpenGL ES 3.0 instead of 3.1...
blink0k
Moderator
7
Years of Service
Recently Online
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 22nd Oct 2020 21:22
Very nice sleuthing there Adam
PSY
Valued Member
4
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 23rd Oct 2020 03:21 Edited at: 23rd Oct 2020 03:21
Good work adambiser!

tarkusAB said he's getting crashes on Windows. This should rule out Adreno GPUs, as they are only used in mobile devices ( If I'm not mistaken )
So it might be an OpenGL 3.0 issue...


PSY LABS Games
Coders don't die, they just gosub without return
adambiser
AGK Developer
5
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 23rd Oct 2020 06:17
blink0k
Moderator
7
Years of Service
Recently Online
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 23rd Oct 2020 21:42
I've never had that occur in windows and i do move from app to other proggies a lot
Virtual Nomad
Moderator
14
Years of Service
Recently Online
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 23rd Oct 2020 22:41 Edited at: 23rd Oct 2020 23:11
no issues on my (old) samsung j320a showing ARM Mali-T720 /OpenGL ES 3.1

have you played with GetResumed(), etc. ?

i ran this without issue (manually Restoring multiple times) on Classic 2020.04.30c:

interestingly, on Windows, when i restored, the count went up by 2 each time.

also, Export Settings?
[My Itch.io Home] [#LowRezJamAGK2020]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=AGK] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[Google Forum Search]
PSY
Valued Member
4
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 24th Oct 2020 00:32
@adambiser
@blink0k
I've also never experienced this on Windows, but tarkusAB said he did, so maybe his GFX card is pretty old and only supports OpenGL 3.0

@Virtual Nomad
GetResumed() doesn't have any effect, nor does any export setting have
I also tried your code. Roughly every sixth time I restored, the counter went up by 2.

All of the above would support the suspicion that it might be a OpenGl ES 3.0 issue...


PSY


PSY LABS Games
Coders don't die, they just gosub without return
tarkusAB
4
Years of Service
User Offline
Joined: 15th May 2016
Location: Tokyo, JP
Posted: 24th Oct 2020 23:24
I'm running a GTX 970 with OpenGL version 4.6 on Win10. 4096MB RAM. GPU drivers from April 2020.

I've gotten the crash numerous times. Always crashes on Sync() the same frame I load a series of images. However, it is not consistent. It doesn't always crash. I need to repeatedly load/unload the same set of images sometimes 5-10 times before it crashes. Sometimes it never crashes. The number of images and size is the same every time. I am monitoring GPU image usage, it never gets more than ~300MB. What I noticed is that when I enable Mipmapping, it makes the crash much more likely. Enabling mipmapping of course takes up more image memory, but even though, still under 400MB. I stress, there is no consistency with the crash.
blink0k
Moderator
7
Years of Service
Recently Online
Joined: 22nd Feb 2013
Location: the land of oz
tarkusAB
4
Years of Service
User Offline
Joined: 15th May 2016
Location: Tokyo, JP
Posted: 25th Oct 2020 00:37
That's what I'm using, printing the values directly to the screen. After about 40 tries, I got it to crash again. The loop it crashes, I am loading a series of images. I am increasing the image load from 21 images at 136MB to 31 images at 334MB. Crashes on Sync(), not on the image load commands. Are there other values I should be looking at? I'm not using more than 30 sprites. It's a 3D game. The Update/Drawing times do not update on sync() unfortunately since it crashes then, but I do know the frame it crashes, it does hang a bit to load the images, maybe a half second.

One of the images I am loading is a 5000x5000 resolution PNG at 5.93 MB. Another is a 3217x1725 JPG at 1.53 MB. The others are various PNGs around 100KB. I am suspecting it has something to do with the large images. I suppose you could argue I should reduce the image size, and I would agree, however my program has no problem loading/unloading these images 95% of the time. Sometimes I can load/unload them 20 times in the same run and have no issues. Other times it crashes after the second or third time.
PSY
Valued Member
4
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 25th Oct 2020 01:19
@tarkusAB
You don't get the crash when tabbing out of and back to your game, right?
If the crash only appears after loading/unloading images, but not when tabbing in/out, this may be caused by another issue.




PSY LABS Games
Coders don't die, they just gosub without return
Raven
15
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 25th Oct 2020 09:12
I've tested all the code in this thread and I'm having no issues with "Tabbing" out / in to an AppGameKit Studio / Classic App with the latest builds on my Nokia 1 Plus
Specifications wise it is an
ARM v7a 4 Core 1.5GHz
1.5GB RAM
PowerVR Rogue GE8100 (OpenGL ES 1.1, OpenCL 1.2)
Android 10Q [Android GO]

Unfortunately there are no other Phones I have that are Compatible., as AppGameKit doesn't support Universal Windows Platform and there is no AppGameKit Player
It does work via C++ UWP using AppGameKit SDK., and I might test it this week (my brother' borrowing my old phone as he is adamant about not "upgrading" to iOS / Android; and I don't blame him, I absolutely hate both) but we tend to work opposite shifts, so we don't actually see each other often.

That does have an ARM v5 4-Core CPU / Adreno 305 GPU., so it might have a similar issue..?
tarkusAB
4
Years of Service
User Offline
Joined: 15th May 2016
Location: Tokyo, JP
Posted: 25th Oct 2020 12:31
That's correct PSY, tabbing in/out does not crash the game. Only these load sequences on occasion. The game window is running in full screen and remaining in focus.

I would share the program, but it's so large and sophisticated I really can't. At least 6K lines split between several sheets. To give you an idea, the game is like Resident Evil, and the crash only occurs when I'm loading a new room (need to load objects, images, sprites, text, set values for a whole bunch of global variables).

I tried creating a short program of loading/unloading 700MB worth of uncompressed images repeatedly to try and recreate the crash, but it's not crashing.

I really don't understand why it's so inconsistent. To be clear: I will run the game, move between rooms a couple times and it will crash. Then, I will not change the code at all and re-run the game, take the same actions I did before, and this time it will not crash. It's truly just whatever it feels like at that moment. It's something in the background. Sorry I am not of much help.
adambiser
AGK Developer
5
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 25th Oct 2020 16:09
@Raven: Are you sure the PowerVR Rogue GE8100 only supports OpenGL ES 1.1? What I find says that it supports up to OpenGL ES 3.2.
Wikipedia
Source 2
Santman
9
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 26th Oct 2020 11:48
I get this sometimes, but I've found running Milkshape, Photoshop or Blender in the background is the cause. So for me I'm in no way put of GPU memory (GTX 1080 with 8gb, about 40% committed) but AppGameKit seems to clash with one or more of these programs and I'm not sure is returning the correct error.
Santman
9
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 26th Oct 2020 11:51
tarkusAB,

How are you loading the images? Are you doing;
LoadImage(5,FILENAME)

Or

Img = LoadImage(FILENAME)

AGK has a bug with image allocation (second version) that makes it inconsistent and easy to run over the same images allocations.
tarkusAB
4
Years of Service
User Offline
Joined: 15th May 2016
Location: Tokyo, JP
Posted: 26th Oct 2020 17:04
@Santman: The latter. In fact I am using that notation not just for images, but for sprites, objects, and text.

I am not using the DeleteAllImages() command however, so it should not be re-using image numbers ever... I am however calling DeleteAllSprites() and DeleteAllObjects() during room transitions, which resets those counters to 100,000.

Can you explain the bug further? There is so much content in this game, we really need to auto-generate these numbers. Also, I only get the error on Sync(), never on the LoadImage() call.

I'm only running Chrome and Spotify in the background also.
Paul Johnston
TGC Developer
18
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 26th Oct 2020 17:47 Edited at: 26th Oct 2020 17:48
I managed to replicate it on a Nexus 5 which uses an Adreno GPU, it looks like a bug in the Adreno OpenGL driver. I might be able to work around it by forcing OpenGL to flush the command buffer just before the app gets minimized. Try this version and see if it fixes it https://drive.google.com/file/d/1ccdrfO47qD2wEOOSR0kmfnf77UlTY67d/view?usp=sharing

The crash on Windows sounds like it might be loading too many images and overflowing the GPU memory.
tarkusAB
4
Years of Service
User Offline
Joined: 15th May 2016
Location: Tokyo, JP
Posted: 26th Oct 2020 22:32
>The crash on Windows sounds like it might be loading too many images and overflowing the GPU memory.

Thanks but unless GetLoadedImages() and GetImageMemoryUsage() are misleading me, that's not the case. I'm running those commands and printing the values to the screen literally one line before Sync() and it says 31 images / 334MB which my GTX 970 can certainly handle (and successfully does 95% of the time).
tarkusAB
4
Years of Service
User Offline
Joined: 15th May 2016
Location: Tokyo, JP
Posted: 26th Oct 2020 23:51 Edited at: 27th Oct 2020 00:02
So I was able to recreate the crash with a small set of code. The program automatically loads/reloads the images over and over. After repeatedly loading and deleting the images around 20-40 times, it crashes for me. I attached the project w/ images. Code is below too. You can press ESC to quit the program if it doesn't crash.

The problem seems to be a 5000x5000, 5.93MB PNG image I am using as a texture for a large room I built in blender. When I omit loading that image, it doesn't seem to crash. I don't see anywhere in documentation anything regarding limits to image file sizes or resolutions.

Loading large JPGs seems to cause no issues. Some of the JPGs are larger in file size than the PNG as well, though the PNG does have the largest resolution.

[Edit] Attached the test project.

Attachments

Login to view attachments
blink0k
Moderator
7
Years of Service
Recently Online
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 27th Oct 2020 01:15
83+ iterations worked fine for me.
Paul Johnston
TGC Developer
18
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 27th Oct 2020 15:38 Edited at: 27th Oct 2020 15:40
I ran the project up to iteration 227 without a crash. Are you using the 32-bit or 64-bit version of Windows, does it happen with both? You could try this version of the player https://drive.google.com/file/d/1d9Y1rDoPIkecuD2Rh-uBkmM8l18mjnDU/view?usp=sharing it's the 32-bit debug version, it will run slower but may give a reason for the crash.
PSY
Valued Member
4
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 27th Oct 2020 16:34 Edited at: 30th Oct 2020 17:12
@Paul
The new version of the AGKPlayer fixed the problem for me on my Samsung Galaxy S4. Tabbing out and back in now works flawlessly.
Thanks alot, very much appreciated



@tarkusAB
Stopped your code after I came home from shopping @ 1921 iterations....no problems at all ( Win10 64bit, NVidia 970 GTX )


PSY


PSY LABS Games
Coders don't die, they just gosub without return
tarkusAB
4
Years of Service
User Offline
Joined: 15th May 2016
Location: Tokyo, JP
Posted: 27th Oct 2020 16:55
OK so I think I fixed it.

I am running 64-bit Windows 10. I first tried replacing the 32-bit player as you suggested Paul, but it still crashed all the same. (usually, but not always, on iteration 29)

But that got me thinking to check my preferences, and sure enough the "Windows 64-bit" build option was not checked. It must have been like that since I installed AGK. After checking it, I ran 200+ iterations without a crash.

Thank you for everyone's help!
houndog66
1
Years of Service
User Offline
Joined: 1st Mar 2019
Location:
Posted: 27th Oct 2020 18:45
I can make my code work using the new player using broadcast, but I'm not sure how to build a working Apk using it. could someone explain please? Sorry if that's a daft question
adambiser
AGK Developer
5
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 28th Oct 2020 02:58
@PSY: Were you getting AppGameKit to crash when running in the player on Android? I was testing with a compiled APK. I'll have to try to get it to crash when using the player before trying Paul's fix.
PSY
Valued Member
4
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 28th Oct 2020 14:58
@adambiser
The error was thrown when broadcasting the code to the AGKPlayer on my Android phone as well as when compiling an *apk and installing it on the phone.

I updated the player on the phone with Paul's fix and broadcasted the code to the new player, and it worked just fine.


PSY LABS Games
Coders don't die, they just gosub without return
adambiser
AGK Developer
5
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 29th Oct 2020 06:16
Thanks, PSY.

One other thing I noticed with the Jul 27, 2020 build: I only seem to get it to crash in landscape mode, not portrait.
The problem seems to be fixed in the Oct 26, 2020 build.
PSY
Valued Member
4
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 29th Oct 2020 14:33
@adambiser
You're welcome

You're right about portrait mode. I just tested code in both portrait and landscape mode ( exported to Android with the respective mode, also used SetOrientationAllowed(....) with the respective mode in the code ).

Portrait WORKS
Landscape CRASHES


Very nice find!


PSY


PSY LABS Games
Coders don't die, they just gosub without return
PSY
Valued Member
4
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 14th Nov 2020 18:26
The bug has been fixed in Studio and will be fixed in Classic within a week


PSY LABS Games
Coders don't die, they just gosub without return

Login to post a reply

Server time is: 2020-12-04 21:10:10
Your offset time is: 2020-12-04 21:10:10