imimib3d0.5 - Errors on iOS5.1 with Mesh* array

BlitzMax Forums/MiniB3D Module/imimib3d0.5 - Errors on iOS5.1 with Mesh* array

thefoxsoft(Posted 2012) [#1]
Hi i need to load about 30 b3d anim files.
I have started modifying the zombie example, but i get some random errors on runtime.
The model loading is made with the following instructions

for (int i=0; i<30; i++)
mymodel[i] = Mesh::LoadAnimMesh("zombie.b3d", light);

mymodel is definied in game.h as
Mesh* mymodel[30];

can you help me?
many thanks in advance


Yasha(Posted 2012) [#2]
Not up to date on my iMiniB3D versions so this may have been fixed, but it sounds something like the issue described here: http://www.blitzbasic.com/Community/posts.php?topic=96640

The suggested fix in that instance was to try using LoadAnimB3DFile instead.


thefoxsoft(Posted 2012) [#3]
Thanks for the quick reply.
Unfortunately i have tried using LoadAnimB3DFile but the problem is still present.
I just want to highlight that this issue cames only when i load more than 20 b3d files in a Mesh* array.
I can provide the source code if necessary.


ima747(Posted 2012) [#4]
What error are you getting and where? Is the error in the loading, or when you try to use one of the >20 meshes? Have you modified iMiniB3D at all (unlinked the texture list for example...). Is it an access exec or something else. Does it crash to a specific point, and if so what's the execution tree?

First thing that would come to mind would be memory constraints... what device or the simulator are you testing on? Have you leak checked your project?


thefoxsoft(Posted 2012) [#5]
The problem is that the error changes every time on runtime, sometimes it got me an assembler error, sometimes it happens on Texture::FilterFlags() function, sometimes on Entity::FreeEntity() function and sometimes it works!
The app occupy 41MB of RAM.

To try the bug just open the zombie example and add these instructions in the Game::Init:
for (int i=0; i<30; i++)
mymodel[i] = zombie->CopyMesh();

of course you have to defining Mesh* my model[30] on game.h
Since i'm developing a soccer game, i must load at least 22 b3d files, so i desperately need it !

thank you really much for your kindly attention.


thefoxsoft(Posted 2012) [#6]
I'm developing on both iPhone simulator 5.1 and real iPhone 4S iOS 5.1, and i get the same errors


ima747(Posted 2012) [#7]
If you don't put the Mesh* mymodel[]; in the header it doesn't crash... if you put it right before the zombie copy loop, or even just skip assigning the copy results to anything (they're stored internally in iMiniB3D for the render lists, etc.) it works (copying 100 now, slow but works). Making the array a static at the top of game.mm also works. Something about putting it in the header = bad news beyond a size of about 5. Interestingly if you make it about 5 and load 5 it works, but if you make it 30 but still only load 5 it has issues...


thefoxsoft(Posted 2012) [#8]
I followed the workaround you have suggested (making the array as global) and now it works.
Anyway I hope this bug will be sorted.

Thanks


thefoxsoft(Posted 2012) [#9]
I found another bug. It happens randomly when i display a lot of sprite.
I got EXC_BAD_ACCESS here:
glBindTexture(GL_TEXTURE_2D,texture->texture.name);

I'm desperate, i cannot go on with development. Please help me because the game is going great so far! :-)


PS: the app occupyies 200 mb of RAM. The problem happens on both simulator and real device

Thank you very much in advance!

Last edited 2012


*(Posted 2012) [#10]
crikey thats a lot of ram usage, what ipod/iphone is this aimed at


ima747(Posted 2012) [#11]
that much memory usage is pretty drastic for iOS, sounds like something is getting forced out due to low memory...


thefoxsoft(Posted 2012) [#12]
I feel stupid, i cannot believe i could not spot it before.
There was a bug in my code that caused the problem


titleTexture->CreateTextTexture("hello", 256,32,0,"arial",24,1+2);



instead of

titleTexture = titleTexture->CreateTextTexture("hello", 256,32,0,"arial",24,1+2);



Thanks a lot guys, I'm really sorry you have lost your time.