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 / Optimization Pro-Tips?

Author
Message
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 26th Dec 2016 07:51
Hi all.

I'm experiencing strange slow-down in my game, despite doing fairly severe garbage collection between rounds. I use DeleteAllImages, DeleteAllObjects, DeleteAllSprites and DeleteAllText each time the game loads up a new level (there are no sounds or music in place yet). And still, the game unexplainably gets slower each round. I'm even monitoring object counts, sprite counts, etc, to see if anything is "clogging up" due to extraneous loads, etc, but I'm just not seeing anything...

Does anyone here have any advice on things to look for or other tips on how I can go about trying to make my game leaner and cleaner?
Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 26th Dec 2016 09:49
Fill rate? As a good rule of thumb, you do not want to be drawing more than 2 and a half times the number of pixels on screen. Transparent areas count towards this...
Using AppGameKit V2 Tier 1
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Dec 2016 10:26
That wouldn't be be affecting his game speed, otherwise he'd notice the slow down from the start.
You have a leak somewhere. Something is not getting cleaned up. Maybe an array that keeps growing? I can only speculate without seeing code.

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 26th Dec 2016 10:32
Over 30k lines of it by this stage

I'm not using any dynamic arrays, so I doubt it's that...

I've noticed that I can get better framerates when I don't rely on the in-built occlusion culling and do it myself, but even then I'll sometimes get a round where the game runs super slow...

With transparencies I'm not using any semitransparent pixels, just to make it as optimized as possible. I know that can take a chunk out of your frame rate...

Any ideas on diagnostics I can run? Numbers I can monitor? Outputs of some kind I could keep an eye on to get a clue as to what might be going on?
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 26th Dec 2016 10:33 Edited at: 26th Dec 2016 10:33
I have no idea if it'd help, but here's some gameplay footage in case you spot anything. This is all from GOOD framerate times, though, so it may not help...

PSY
Developer
7
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 26th Dec 2016 19:53
Have you tried GetPolygonsDrawn() ?

You might also want to have a look at the benchmarking commands...they are very useful when it comes to leaks.

Like
GetDrawingTime()
GetPixelsDrawn()
GetParticleDrawnQuadCount()

and so on...
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 26th Dec 2016 20:51
I sometimes throw all of the important stats into a csv file as the game plays. you can load these into Excel and display graphs to see if there are any trends or spikes.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 26th Dec 2016 21:58 Edited at: 26th Dec 2016 22:01
My current project loads over a hundred 3d objects per level, with multiple levels and I'm not seeing any slowdown like you're describing. The things I'm doing differently to you are:

1) I don't delete everything per level. Any media required for the each level - such as bullets - are loaded once and only delete when the game goes back to the main menu. Media only required for a particular level is loaded at the start of the level and deleted once the level is completed.
2) I don't use any of the "delete all" commands. Everything is deleted manually. I think this is probably the one worth trying but I've never used any of the "delete all " commands so I can't say whether this is definitely a problem or not.
3) I'm probably not loading as many images as you are: only four images are being loaded per level (I've not gotten around to loading in all the sound effects but it current stands at five)

Apart from that, I'm using my own culling (but, like Phaelax said, something like culling or fill rate wouldn't cause a progressive slow down), I don't create any new media once the level has started, I don't use dynamic arrays, arrays are manually reset at the start of each level.

I hate it when problems like this crop up, you can really tear out a lot of hair before it all gets sorted.
Hover Car Race Challenge! - available now on Google Play
Invaders of the 29th Dimension - available now on Google Play
Find me on indieDB
Carharttguy
7
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 26th Dec 2016 22:02
Could you play the game on a desktop, check the RAM when you play the first level. Play a few levels till it get slow, check the RAM again. If the difference is huge, you OR AGK2 are/is having a memory leak.
Carharttguy
7
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 26th Dec 2016 22:03
Also, are the level loading times longer, or just the game?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 26th Dec 2016 22:10 Edited at: 26th Dec 2016 22:11
try simulate the rounds, quick exit it and then start again so a leak will show soon. if 1=1

AGK (Steam) V2.0.22 : Windows 10 Pro 64 Bit : AMD (16.12.1) Radeon R7 265 : Mac mini OS Sierra (10.12)
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 27th Dec 2016 00:18
Use procmon and watch the memory usage, you will set it rising pretty easily if there is a memory leak.

Does it slow down if you keep it on the same level for a good length of time or only when switching levels with a load/unload

Regardless, a large preject it is always good to track timing metrics for each major process/component and see exactly where your fps time is going.


A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
http://games.joshkirklin.com/sulium
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 27th Dec 2016 05:19
Wow, what a thing to wake up to. Some awesome pro-tips guys! Lemme try and respond properly...

@PSY - I haven't tried that, no. That would definitely prove my hypothesis about the occlusion culling being the culprit. I'll give that a go, thanks!

@BatVink - I'm a sucker for stat reports, so I'll definitely give this a go.

@29 Games - Oh I don't delete everything every level load. It's just something I had been trying in case there was something I was forgetting to delete which was building up. Only thing is, this happens sporadically, so I'm not sure if it's actually to do with the between-level sequence. I like to recycle where possible to cut down on load times/resources. You're right that it can definitely get frustrating! As you can probably tell from the youtube clip, I've put a LOT of time and effort into this for this to start happening during the final stages before release!

@Carhartguy - Interesting factoid here... It always, 100% of the time, works perfectly on the PC. The slowdown only happens during broadcast to phone and even after an APK compile/install. The level load times are perfectly consistent (and very small, if I do say so myself). The slowdown only happens during gameplay, and only sometimes. It's almost as if something else happening on the phone is taking up resources which my game needs.

@Markus - That's an interesting concept. I might combine that with BatVink's suggestion of csv reports and see what I get...

@Ortu - I'm not sure I'm at that point yet. I think it's just something I'm overlooking in my code, however I'll definitely run that through ProcMon before going live to see if there are any inconsistencies.
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 27th Dec 2016 08:08
Oh, also... Phaelax - when it happens, I DO notice it from the start. It doesn't get slower over the course of gameplay. It gets slower over the course of running builds.
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 27th Dec 2016 14:49
Starting to sound more like a device/system issue than a program issue.

Testing on another device would be good if possible


A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
http://games.joshkirklin.com/sulium
damothegreat
User Banned
Posted: 27th Dec 2016 15:45
I wouldn't do any of these in the main sync loop - note:- functions been called inside main loop also should be examined and considered

- Load Functions

- Create Functions

- Embedded FOR loops that takes an age to exit on each frame pass

Cause the video shows a wonderful tower full of sprites - maybe your putting into play the whole of the enemy sprites (so lets say you having 1,000 in each level)
and processing them all in one go, then this may cause lag.

Perhaps just concentrate on the sprites (in screen view) instead of working on the whole of them in one pass

Similar to a skybox game - where in the distance there will be some trees (cannot see the trees) but still processed.. Once you get into promixity of them (a few 100 yards say) then they
start been visible and put into view.

Damo
Using Tier 1 AppGameKit V2
Started coding with AMOS
Anything is possible if put mind to it
damothegreat
User Banned
Posted: 27th Dec 2016 16:15
EG.

Load and initialise Enemy sprites - use TYPE to create and keep an eye on them
One of the variables maybe

Enemy.Destroyed = TRUE / FALSE

Do

When an enemy sprite is in view then process its actions and movements but only if Enemy.Destroyed = False

When an enemy sprite is Destroyed, delete its ID and change Enemy.Destroyed=TRUE so it doesn't get heavily processed again

Loop

You may have 100+ sprites been processed even though enemies are not viewable anymore = unwanted processing


Maybe!!!

Just throwing ideas about

Damo
Using Tier 1 AppGameKit V2
Started coding with AMOS
Anything is possible if put mind to it
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 27th Dec 2016 17:01 Edited at: 27th Dec 2016 17:01
-Snip
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 28th Dec 2016 00:54
@Ortu - I thought that, too, but it happens across several devices. I think it's to do with a particular combination of the tower construction. I am running my own particle system so it's likely something to do with that - perhaps the alpha channels used on the particles?

@DamoTheGreat - All good ideas but unfortunately all of that has been considered. Enemies aren't handled except in raw data if they're not in frame - same with particles - no load or create commands are happening during the main loop, everything is handled using TYPES and rather than using multiple FOR/NEXT loops to process the various things each frame I have one master routine which does everything in one sweep. I'm a neat coder, I promise!

@hakimfullmetal - ?
damothegreat
User Banned
Posted: 28th Dec 2016 00:58
But why does frame rates deteriorate for every level? ermmm

Whats your processes for end and beginning levels.

Damo
Using Tier 1 AppGameKit V2
Started coding with AMOS
Anything is possible if put mind to it
damothegreat
User Banned
Posted: 28th Dec 2016 01:04
Could you stick

print(screenfps())

just before your game loop synch and see if this decreases or is it genuinely a memory hog


decrease of FPS - means you got bad loops and creations somewhere
Damo
Using Tier 1 AppGameKit V2
Started coding with AMOS
Anything is possible if put mind to it
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 28th Dec 2016 10:46
Quote: "I am running my own particle system so it's likely something to do with that"
Try some of the benchmarking commands to see whether your particles are doubling up:

GetManagedSpriteDrawnCount ( )

GetParticleDrawnQuadCount ( )

GetDrawingTime ( )

GetDrawingSetupTime ( )

GetManagedSpriteDrawCalls ( )

GetPixelsDrawn ( )
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 28th Dec 2016 12:36
@damothegreat - It's actually more of a problem that SOME levels have the problem and some don't. The "tower" is randomly generated, so some configurations clearly aren't being liked. I've looked at the numbers of each tower element to see if perhaps too many particle emitters are being built or something like that, but all that looks normal, which leads me to think that it's something inherent in the rendering/handling routine of something... Perhaps billboards, perhaps particles... I'm not using any sprites except for the UI, since it's a 3D environment, so all the billboards are plane objects.

@CJB - That's what I'm currently in the process of doing now based on PSYs suggestion. Hopefully it helps shed some light on what's happening!
Jack
19
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 28th Dec 2016 14:38
Try to use image atlas textures and GLSL shaders where you can. Each line of code that you can achieve in GLSL is a way faster than a line of code in AGK.
To debug your app, create a logging function, save max view polys, loaded textures.
If you install Android Studio and pair it with your anroid device, while running the AppGameKit Player, you can debug the RAM and VRAM by graph. (And do some interesting screen-caps)

Create an array for your media, in order to check that loaded images, sounds and models are unique. Use them as instances for your level media.

[/url]
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 28th Dec 2016 18:37
Quote: " It's almost as if something else happening on the phone is taking up resources which my game needs."

it probably is. Downloading updates? Virus scanning? The Os optimizing RAM/apps.
There could be all kinds of things happening in the background of the mobile device we don't know about that could cause it.

What happens if you run it on a device in airplane mode? (I.E. no network connection)
Are you running it with USB debugging turned on? (If so, turn it off.)
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 29th Dec 2016 00:31
What frame rate have you set? For 3D games on android I always set it for 30 FPS as this gives a consistent refresh rate on my devices (Nexus 10 and an old Arnova tablet).
Hover Car Race Challenge! - available now on Google Play
Invaders of the 29th Dimension - available now on Google Play
Find me on indieDB
haliop_New
User Banned
Posted: 29th Dec 2016 13:26
what i usually do is:

first when expriancing fps drops i remove stuff just to see what happens
so maybe try to disable particles or disable sprites and then play it like you would with or without then see what happens use GetScreenFPS to see it

second
im all about instancing objects and sprites i have one "original model" that is hiding somewhere in the 3d world and all game objects that are equall are being instanced
about sprites some times instead of creating 100 sprites i create just some sprites and then in the game loop or pherhaps the draw loops
i call


also , you can try
i hardly use it but sometimes i give it a go



in addition

Try to Install your game (not broadcast) on diffrent devices see diffrences however this is not the problem if it is then your device alone has somekind of problem but that should not really be the case
but trying on diffrent devices may give you diffrent results.

hope you'll fix it , i cant wait to play this game looks amazing good job.
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 29th Dec 2016 13:58
@Jack - Some solid tips there. I'm currently not using ANY shaders, but it's good to know that they can speed things up.

@Mobiius - My only thought with that is, if my end-user has that stuff going on in the background, are they going to calmly think "oh, perhaps I have stuff going on in the background on my phone" or are they likely to go "this game is terrible! I'm uninstalling it!". My bet would be on the latter

@29 Games - Originally I had mine set to 30, but it genuinely runs faster and smoother on all devices when I set it to 60

@haliop_New - Removing things systematically is a good idea... Especially given that I have certain suspicions in a few areas. Funny how you can get so focused on something that the obvious solutions can just pass you by hahaha. I'm all about the instancing, too, and am making thorough use of that! I've done the multiple device testing and it happens pretty consistently across devices, which narrows the issue down... Also, thanks for the feedback! You can kiiiiiiind of play it now if you want. My team orginaly made this game in Unity and released it on Android. We then tried to get it working on iOS using Unity and after months (literally months) of work trying to make it happen, we realised it would literally be faster to re-write the game from the ground up in AppGameKit, since it goes cross-device so smoothly. So the remake that you're seeing here has been being built since mid-September and should be finished sometime in January. I've been doing 16 hour days hahaha. But yes, if you go to the Google Play store, you can get the Unity version of the game there. Just search for Wizzed Off! We'll be swapping that build out for the AppGameKit version (which is far superior if you ask me) once it's done in January.
haliop_New
User Banned
Posted: 29th Dec 2016 14:49
i tried.. but its unplayable the fps is too low maybe its my device..
i got a HUAWEI simple , its a kinda of a very simple low version of a phone but everything else is running pretty well
so i guess your unity version is kinda lame..

still a good game i'll wait for the AppGameKit version see if theres a difference .
(Rated 5STARS and commented )
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 29th Dec 2016 16:15
Quote: "We'll be swapping that build out for the AppGameKit version (which is far superior if you ask me) once it's done in January."
Haha! Fantastic! TGC could (should) get some good press coverage from this!
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 30th Dec 2016 00:14
Oh yeah, totally. I was utterly appalled by Unity's mandatory overheads. I was experiencing the same slow FPS on even a modern phone (Samsung Galaxy s5). But with the AppGameKit version (most of the time - when I'm not experiencing this mystery bug) I'm easily pulling 60fps!

AGK all the way, baby.

I actually make games full time, and I've switched all of my mobile development across to AppGameKit now.
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 31st Dec 2016 10:24
INTERESTING UPDATE!

I'm still trying to narrow down the problem, but I noticed a very interesting symptom...

My animated sprites in the UI still play at normal speed when the rest of the game slows down... Not sure if they're operated separately, but I think it certainly narrows things down a little!
damothegreat
User Banned
Posted: 31st Dec 2016 21:25 Edited at: 31st Dec 2016 21:37
Just out of interest - How big are your images for each of your sprites,textures, animations

Say for example they are 256 x 256 - these are ok for PNG cause they are compressed images

but AppGameKit uncompresses tham and use memblock style data for every single one.

and they are transformed as bits such like

12 + ( ( 256 x 256) x 4 ) = 274,432 - so for a 256 x 256 image - it will use 0.25 mb of memory.

If you are loading 100+ of these in one game cycle say.
That would be 0.25mb * 100 = 26mb memory

If your not releasing memory at end of levels, then this will increase.

----

So lets say your images are a bit larger - 512 x 512 sprites = 1mb per image loaded = 100mb for 100 sprites

and if want the apps to run on mobile phone / tablet. gotta think about the general size of memory each and every member in society would have.

How does it run on your PC / MAC --- Same?



Just something to think about
Using Tier 1 AppGameKit V2
Started coding with AMOS
Anything is possible if put mind to it
damothegreat
User Banned
Posted: 31st Dec 2016 23:21 Edited at: 31st Dec 2016 23:26
For example, you can use the following bit of this code ive created



instead of using CreateSprite and DeleteSprite use Bcreatesprites and bdeletesprite - does the same thing except it calculates the memory for each an ever sprite which loads into memory

Change the sprite path image.png file to obviously to what you want to load.

You can figure out memory consumption using it - by adding up to the totals in the array length of memsize[ x ] .size

Suppose everyone is out celebrating

I'm off to bed

Damo
Using Tier 1 AppGameKit V2
Started coding with AMOS
Anything is possible if put mind to it
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 1st Jan 2017 03:37
That's an exciting little snippet for me to use, there, damo. Thanks for that.

Unfortunately, I'm loading the exact same set of resources for each and every round of the game, so if that was causing my problem, surely I'd see the slowdown every single round and not just on occasional rounds?
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 1st Jan 2017 03:38
And yeah, everyone else is out celebrating, and I'm here coding hahaha
damothegreat
User Banned
Posted: 1st Jan 2017 07:36
Thanks for the snippet comment on memory finding.. I think I might develop more into this and give out a full set of routines later in week
to identify your memory usage in your apps.

think it will be a very good thing to have

damo
Using Tier 1 AppGameKit V2
Started coding with AMOS
Anything is possible if put mind to it
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 1st Jan 2017 09:24
I agree. AGK2 is an AMAZINGLY great tool, and only getting better as time goes on, but it does lack the diagnostic tools of other engines. Having toolsets like this would really make it even better.
haliop_New
User Banned
Posted: 1st Jan 2017 13:31
i guess for memory you can run it on pc and open the TaskMenu to see CPU/MEM vs other stuff ... and there are plenty of Memory diagnostics out there...
i actually did not know that agk turns images into memblocks .. good to know.
i wonder if we can have a pointer to that memblock instead of creating on of our own...
damothegreat
User Banned
Posted: 1st Jan 2017 15:34 Edited at: 1st Jan 2017 15:36
There are

CreateMemblockFromFile -- This will load an image directly from the PNG

or you can create sprite first and use

CreateMemblockFromImage - This will point to the memblock data that already been created by loadimage
i.e

Pointer = LoadImage ( IMAGE.PNG )
memory = creatememblockfromimage ( Pointer)



CreateMemblockFromSound - suppose this points to the sound source of LoadMusic - haven't used it but sounds like it does

I think!!!

I don't really wanna hijack this thread by going off the subject - if your interested more, please create a brand new thread and we all can talk about memblocks in depth


Damo
Using Tier 1 AppGameKit V2
Started coding with AMOS
Anything is possible if put mind to it
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 2nd Jan 2017 06:08
I think it's worth my time to take all of this on board and create an extremely detailed reporting system that outputs live run data into a CSV file. Something modular enough that I can add into each new project I do. I think it will save me many, many tears in future development. I do, after all, do this full time, so if I spend the time to do this now it'll make my life a hell of a lot easier later on.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 2nd Jan 2017 11:17
It was a while ago, but the way I approached ouputting to CSV was...

1. Create a spreadsheet with a list of variable names you want to output
2. Write a macro that creates an AppGameKit function to write all the variables to a file
3. In the file output function, also add time and an event column. Time allows you to plot graphical views of the data
4. When you call the function to output to CSV, you pass a string for the event. This allows you to filter by specific event in the final output.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 2nd Jan 2017 12:38
Sounds like a plan!
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 2nd Jan 2017 14:35
I've run into an issue where I can't access my outputted file, since on Android it tucks it away in an area only ROOT access can touch... Does anyone know of any way to write the data to somewhere I can find the file again on an Android device?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 2nd Jan 2017 15:01
Quote: " can't access my outputted file"

if you using agk Sockets for output, you can use a agk app at pc that listen at one port and write this data to file/hd there.
or if your game app opens a port you can output html data and connect via browser from pc.

AGK (Steam) V2.0.22 : Windows 10 Pro 64 Bit : AMD (16.12.1) Radeon R7 265 : Mac mini OS Sierra (10.12)
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 2nd Jan 2017 20:23
My logging system has gone through a few iterations now, but I'm currently running everything through a 'console.log ()' type function which writes to an open csv file.

I can set filter limits such as 'volume' 'channels' to control what and how much is getting output

For instance you can have it write only errors, or include warnings, notices, info etc. Day in debugging a specific system: character animation, I can shut off output of the UI module element handling, as is not relevant without having to comment or remove from the code.

All entries are timestamped.

Like:

System_log ("anim3d.dba", 2, "main", "Begin animation update")

System_log ("anim3d.dba", 3, "anim3d", (WARN: requested sequence not found " + reqSeq$)

Where: System_log (sourcefile, volume, channel, content)

If my logging config includes the channel and volume level, it writes the data out, else it's ignored.

Calling the function with a lot of log entries, even if most are filtered out does come with performance overheads, logging in general can significantly impact performance the more writing you are doing.

Which is why I've gone further to write a preprocessor that can split my project into multiple scopes like development vs production, in which the production source is automatically stripped of debugging code before compilation without having to maintain two different versions of the code.
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 3rd Jan 2017 05:59 Edited at: 3rd Jan 2017 06:01
That's certainly an interesting idea, Markus...

Where does that CSV file end up, Ortu? Somewhere you can grab it again afterwards?
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 3rd Jan 2017 06:06
Haven't done any work with android sorry, Windows of course you can put it wherever you want it.
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 3rd Jan 2017 06:53
Windows gets around ( ͡° ͜ʖ ͡°)
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 5th Jan 2017 15:58 Edited at: 5th Jan 2017 16:00
Quote: "I've run into an issue where I can't access my outputted file, since on Android it tucks it away in an area only ROOT access can touch"

Since version 2.0.21 you can use SetRawWritePath(GetDocumentsPath()) on Android to write to the SDCard. Be sure to save the old write path with GetWritePath before hand so you can set it back again.

Quote: "My animated sprites in the UI still play at normal speed when the rest of the game slows down"

Sprite animations are time based rather than frame based, so if a frame takes longer the animation will be advanced further

Quote: "The "tower" is randomly generated, so some configurations clearly aren't being liked.
I've noticed that I can get better framerates when I don't rely on the in-built occlusion culling and do it myself"

I assume the culling was for 3D tower objects? If so then this is almost definitely the cause. Out of interest what culling method did you use? AppGameKit uses simple frustum culling for 3D objects.
Are there a lot of transparent 3D objects? If so then the 3D transparent sorting could be causing it.
If they are mostly opaque how many different types of object are created an in what order? 3D opaque objects are drawn in the order they were created, and each has its own draw call, which can cause a lot of state changes (state changes in OpenGL are expensive). For example an object with image 1 is drawn, then an object with image 2 is drawn, then another object with image 1 is drawn would be slower than drawing both objects using image 1, then the object with image 2. Alternatively use an atlas texture containing as many images as possible and have the objects use sub images, then they won't need to change the image between draw calls. Other state changes would be different shaders or meshes, but if all the objects are using the same number of images and there are no point lights in the scene then they will all be using the same internal shader. If you are using point lights then reducing the number of lights should help. Meshes are only shared by instance objects (not cloned objects), so all instances should be created together if possible.

If you want to get really advanced you can take over the 3D render order manually by replacing all instances of Sync() with

Note that transparent objects would have to be drawn after all opaque objects, and be drawn in back to front depth order to get correct results. Opaque objects can be drawn in any order, and should be grouped into objects with the same images, shaders, and meshes for best performance.

In summary try an atlas image first (you can use up to 2048x2048 safely), then try grouping objects so instances of an object are all created at the same time. If this isn't feasible then try drawing 3D objects manually so that instances of an object are all drawn together.

Login to post a reply

Server time is: 2024-04-24 08:41:31
Your offset time is: 2024-04-24 08:41:31