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 / Limitations to agk tier 1 strings ?

Author
Message
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 8th Dec 2013 13:18 Edited at: 8th Dec 2013 13:20
I spent a week trying to solve an crash bug ?

And when I tracked it down so did it amaze me to be as simple as this line.


Load_wav$=Twav$+str(Isound)+".wav"

But you see the problem is in this.

str(Isound)

Because when I splitted the string creation so whas it always this command that crashed the app.

So now do I wonder if there is some limitations to its memory or the string part of agk gets garbaged when used a lot?

van and I use this string conversion a lot in our game.

And the crashes is always at the same place and seam very random?

And I mean we use this a lot in our script reader and large parts of the game .

The funny thing is that we had this bug ingame before but when van added the shop code so have it now moved out of the game loop in to the creation of it.

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 8th Dec 2013 15:03 Edited at: 8th Dec 2013 15:10
what is the len(Twav$) before crash appear?
what agk version u use?
crash at what device?

hmm, no problem with this at pc:



AGK 108 B19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 8th Dec 2013 17:26
Could the app be reaching this command before Isound is defined?

That could cause a crash.
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 8th Dec 2013 17:39 Edited at: 8th Dec 2013 17:45
Quote: "what is the len(Twav$) before crash appear?
what agk version u use?
crash at what device?

hmm, no problem with this at pc:"

iam going to see if I can get that as its the str() command that crashes.
and this happens after a while and always at this place.
agk beta 19
win 7
Quote: "Could the app be reaching this command before Isound is defined?

That could cause a crash."

isound is the variable in an for to loop.




edited.............
yes I cant even do this.

print(len(str(s)))
sync()

str()
crashes everything to a shutdown.

I have strong belives in an string bug of some kind in agk?
I know ios and android have huge limitations on handeling strings and empty them properly.

It could also be that van and I have reached some kind of garbage collection limitation in agk.

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 8th Dec 2013 17:51
Just out of curiosity, what happens if you drop the 'Load_wav$=""' command? It is not needed (since you immediately assign a new string to it) and you are actually causing AppGameKit more work handling strings than you need to. Even though it is a blank string, the AppGameKit engine must first do whatever garbage collection it does and then create a blank string and assign it.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 8th Dec 2013 17:53
Quote: "Just out of curiosity, what happens if you drop the 'Load_wav$=""' command? It is not needed (since you immediately assign a new string to it) and you are actually causing AppGameKit more work handling strings than you need to. Even though it is a blank string, the AppGameKit engine must first do whatever garbage collection it does and then create a blank string and assign it."

I added this in an attempt on emptying any garbage as I cant check if its empty when it crashes?

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 8th Dec 2013 18:18
I also missed to mention that this is done in an gosub.
I know that gosubs have bin a bit whack before?
But I cant create types inside functions still in agk?

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 8th Dec 2013 18:31
Quote: "But I cant create types inside functions still in agk?"

Do you mean returning a UDT as the result of a function?

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 8th Dec 2013 18:59 Edited at: 8th Dec 2013 19:00
No I meant creating working udts outside that function !

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 8th Dec 2013 19:58
I have decided to rewrite almost all code van and I have to see if I can workaround this somehow?
It will take some time but hopefully will it work after that.

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 8th Dec 2013 20:05
You can use UDTs or arrays of them if they are declared global. Then you can change or set them from within a function.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 8th Dec 2013 20:06
That sounds horrific mate... maybe a plan B would be to put the code on ice until AppGameKit v2?

I am the one who knocks...
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 8th Dec 2013 20:29 Edited at: 8th Dec 2013 20:33
Quote: "You can use UDTs or arrays of them if they are declared global. Then you can change or set them from within a function."

Quote: "That sounds horrific mate... maybe a plan B would be to put the code on ice until AppGameKit v2?"

Initial tests are great
Before so did I get an app crash every 3-6 restart of shop or dungeon level.

Now have I only so far done it like this.

in the main file so do I call an gosub to setup the player udt once when the game starts.
It looks like this.

And then do I have a function to setup all globals,sprites,objects etc in an function everytime a dungeon or shop starts.

The problem don't seam to be the str() command but agks gosub command that seams to leave garbage everytime they are executed.

And we execute a lot of gosubs everytime a dungeon or shop are created.

I restarted shop and dungeon levels over 30 times until I got tired of it without any crashes so far.

Nead to test some more but seams to be a combination of a young programming language and 2 messy coders

Now do I only have to do this for all items,enemys,map files also , and there is a lot of them.

Van and I want to have all stuff tied to them in an file of there own ,to be easy to change and update .
sothis is a working solution for that if I don't get more crashes?

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 8th Dec 2013 20:58
is this the compleate Initiate_Player_Udt: sub routine?
looks odd. the type is read from compiler and the globals to,
there is nothing to jump in?
you should only jump where you set the Player_Prop.xy=
this can also be done in a function because udt var is global.

Function Init()
Player_Prop.ATT=123
EndFunction

AGK 108 B19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 8th Dec 2013 21:29 Edited at: 8th Dec 2013 21:47
Quote: "is this the compleate Initiate_Player_Udt: sub routine?
looks odd. the type is read from compiler and the globals to,
there is nothing to jump in?
you should only jump where you set the Player_Prop.xy=
this can also be done in a function because udt var is global.

Function Init()
Player_Prop.ATT=123
EndFunction"


No this is the complete player init.



Our problem is that we have a really huge project with huge amounts of code.

And some parts seam to not work as they should in functions or gosubs.

We initiated this before everytime a new level or shop level whas created that caused painfull crashes.

We nead to setup many player values before we create dungeons and enemys as they are placed,textured etc depending on texture variations and scripts in these files.

We have so much media during gameplay that change that we don't want to keep in memory between levels.

Its hard to explain when you don't see the mass amount of code it have

The last changes have stopped all crashes so far

And as an side note so cant we create all udts in the main file as it would get extremely large and hard to follow or debug.

You should keep in mind that this is only the player and we then have.
gui
map
enemy
items
particles
shop
inventory

and the list goes on

Edited............
Van and I created a simple solution for working on this at the same time even if we don't have so much time to do so.
We split as much as possible in to separate files so we can work on it and don't mess it up for each other to much.
he simply writes iam working in screen_shop.agc and then I don't touch that file until he is done and simply copies it in to my projects and the same for him



Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz

Attachments

Login to view attachments
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 9th Dec 2013 00:36
hmm, ok.

the Global or Global Dim i would not use inside a function
because a function have it own memory until it used (in some languages).
i don't know what the agk compiler do with it.
maybe just use a jump mark for easy navigation in ide and always write
this globals at top level.

AGK 108 B19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 9th Dec 2013 04:28
Using Global and Global dim will work in a function. But you need to call them before you try to access the things defined in the statements.

And, it is a very good idea to make sure that all UDTs are defined as the very first set of things done. When my WIP was in Tier 1, I included a file that defined all the UDTs before I did anything else.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 9th Dec 2013 07:49
Knowing AppGameKit it might not be the line of code it is reporting that is faulty. Sometimes other errors cause weird results.

You do not need to declare arrays as global, all arrays are global.

I declare all my global variables (and types) at the top of my files, outside of functions. You could even create a file called globals and include it at the top of main. Hmm, maybe I should try that. Sounds potentially easier than searching for those declarations.

Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 9th Dec 2013 19:24 Edited at: 9th Dec 2013 19:35
Hi DA.
Quote: "Knowing AppGameKit it might not be the line of code it is reporting that is faulty. Sometimes other errors cause weird results."

The problem whas that agk did not report anything.

I made the slow process like this to find wath it whas.

print("before")
sync()
line of code that do some fun stuff.
print("end of this stuff")
sync()

Agk simply made a app crash exit and don't tell me anything and did this completely random.

Quote: "You do not need to declare arrays as global, all arrays are global."

Yes if you declare them in the main file so are they global,but I know that if you create arrays in an included file so whas an old bug that they where not global at all.
So for safety during development do I declare all arrays as globals.

Quote: "I declare all my global variables (and types) at the top of my files, outside of functions. You could even create a file called globals and include it at the top of main. Hmm, maybe I should try that. Sounds potentially easier than searching for those declarations."

This early in development when van and I only have completed about 55% of the game and already have so much code so do that get a bit painfull during development.

But its a sure thing when we know that they are not going to change any more to do it like that

Quote: "Using Global and Global dim will work in a function. But you need to call them before you try to access the things defined in the statements."

The fun thing is that it works in tier 1 and that's why I sticked to it during these early development months and many things change constantly.
Quote: "And, it is a very good idea to make sure that all UDTs are defined as the very first set of things done. When my WIP was in Tier 1, I included a file that defined all the UDTs before I did anything else."

This is a thing I have made completely wrong before and may have caused some of my crashes.
This is why I have you guys and girls that know to tell me wath I do wrong.
The way I do it know works and seam to have ended a lot of weird crashes and errors.

You should keep in mind that iam not a programmer but a grafix artist that turned to dark basic and now agk and smash some keys until something work
But we should keep in mind that if I can make something work in agk so can anyone do the same with no experience
Iam the perfect beta tester as I write code without knowing wath I do and get funny results sometimes.

Quote: "hmm, ok.

the Global or Global Dim i would not use inside a function
because a function have it own memory until it used (in some languages).
i don't know what the agk compiler do with it.
maybe just use a jump mark for easy navigation in ide and always write
this globals at top level."

Could you explain this some more about functions?
Iam always happy to learn
I always use a lot of functions as it makes it easy for me to gather code stuff that belonge together in there own files for easy acces.
This is more or less something I started with in agk as the ide is pretty underdeveloped so far and hard to find functions when you nead them in large parts of code.

I loved this in dbp to simply have them listed on the side of the ide and could just click on them to get there.

I have great hopes for agk 2 because I love the tgc programming languages.

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 9th Dec 2013 20:33 Edited at: 9th Dec 2013 20:44
dependent on the compiler a function can have a lifetime.
they did not exist in memory until you want call it.
this make sense because you did not know how often this function
can be called, because you can call a function recursive, means
you can call inside a function the self again and each will have
the own local variables.
the word Global inside a function should give you a compiler error
because it is on the wrong position in code but visual basic allowed it too.
if a function returns it return value the used memory will be freed.
(allocating memory again and again cost also time)
as an exception, in visual basic you can define a function static,
the memory will allocated once and stay in memory,this is good
for tuning if you need a fast function much often.
i you call a vb6 static function direct again the local variables have the last assigned values.
my experience with commands are that if they work once,
they often work allways with the same situation.
yes, the agk ide can list and fold functions, it don't work yet because the opensource editor was made for c syntax.
if paul have time for this im am sure he can fix this to basic syntax.
also the debugger will be useful in v2.

"Agk simply made a app crash exit and don't tell me anything and did this completely random."
maybe a runtime problem or just extract the code that crashed at your pc and give us for testing.

you should also print some of the Benchmarking commads on screen
to be sure you don't forget something to free.
you can copy from GetDrawingSetupTime example from online help.

i remember, one user here had start a old agk version because it
was installed also. the help/about should say build 108.

AGK 108 B19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 9th Dec 2013 21:12 Edited at: 9th Dec 2013 21:17
Quote: ""Agk simply made a app crash exit and don't tell me anything and did this completely random."
maybe a runtime problem or just extract the code that crashed at your pc and give us for testing."

I don't know but I belive that agk didt like how I created udts and how it whas all done in an gosub.

The funny thing is that everything works after I only changed the players init and setup ?

I haven't got a single app crash now?

So iam for safety going to fix all the files in the project and do as our lady wrote about udts

About wath you wrote about functions so would that mean that if I have it return an value even if I don't nead it, so would it free more memory in agk then returning no value?

I think we nead some words from paul about this how functions and gosubs work in agk?

ps...
iam going to see how much coding I get done this week also as I got my 3.2 inch touch screen for my raspberry pi
It depends on how much fun it is with my prototype snapp on board.

I have this board I got today.



Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 9th Dec 2013 22:59
yes, a type inside a gosub or function is also at the wrong place but should
not the problem because the compiler need this struct only once.
i would say yes because each var need a place in memory but it depends
what the compiler translate.
cool,the raspberry+addon's is also on my wish list but i have less time for it.
a while ago i had fun with micro-controller boards+tft

AGK 108 B19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 9th Dec 2013 23:22 Edited at: 9th Dec 2013 23:23
Quote: "Agk simply made a app crash exit and don't tell me anything and did this completely random."


Ah, sounds like you got a multi-dimensional array that is out of bounds. At least I think that's what caused the random crashes for me IIRC. I made a thread about it some time ago. Or what is an UDT array? It was something about an array being out of bounds without AppGameKit reporting it. And that would cause random crashes, not seemingly related to the out of bounds issue.

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th Dec 2013 16:57
Hmmmm, I wonder if I've used too many doors in a level Cliff? - I think there's a limit of 8, but I didn't realise that until I added the locked door stuff, so I might have used too many doors.

Just going by what DG is saying, maybe we don't have a safety check in place for doors to ensure we don't overflow. Like with the items, it's probably not an issue to exceed the array, but doors might be a bit neglected.

DG, Each time a level is loaded and a door is found, it get's added to an array which holds the locked state, object etc etc, so it's quick to handle doors - I'm just thinking that it might be easy for an array overflow to creep in then.

I am the one who knocks...

Login to post a reply

Server time is: 2024-11-24 23:35:16
Your offset time is: 2024-11-24 23:35:16