FORUM CLOSED, PLEASE REGISTER AT FORUM.SIO2INTERACTIVE.COM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

BAD ACCESS crashing on App Loading

4 posters

Go down

BAD ACCESS crashing on App Loading Empty BAD ACCESS crashing on App Loading

Post  jj Wed Nov 19, 2008 6:01 am

Hey,

So another 5% to being finished with a kick ass Game thanks to sio2interactive:

About 1 out of every 3 times I try to start the app, I get a BAD ACCESS crash.

Normally this falls on the EAGLView.mm / (void)drawView; function...

Code:

- (void)drawView {

   if( !sio2->_SIO2window->_SIO2windowrender ) return; //CRASH HAPPENS HERE...
   
   else {
      //********************************
      //sio2PhysicRender( sio2->_SIO2physic,
      //             sio2->_SIO2window );
      //******************************** THIS IS CALLED IN templateRender()
      
      sio2->_SIO2window->_SIO2windowrender();
      
      sio2WindowSwapBuffers( sio2->_SIO2window );
   }
   glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
   [context presentRenderbuffer:GL_RENDERBUFFER_OES];
}

The other 25% of the time it occurs in templateAppDelegate.mm:

Code:

- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{   
   UIAccelerationValue x, y, z;
   
   x = acceleration.x;
   y = acceleration.y;
   z = acceleration.z;
   
        //attempts to fix crash
   //if (x==0) x=0.001;
   //if (y==0) y=0.001;
   //if (z==0) z=0.001;
   
   if (!acceleration) return; //attempt to fix crash
   else {

   sio2ResourceDispatchEvents( sio2->_SIO2resource,
                       sio2->_SIO2window,
                       SIO2_WINDOW_ACCELEROMETER,
                       SIO2_WINDOW_TAP_UP,
                       0,                        
                       acceleration.x * 0.1f + x * ( 1.0f - 0.1f ),
                       acceleration.y * 0.1f + y * ( 1.0f - 0.1f ),
                       acceleration.z * 0.1f + z * ( 1.0f - 0.1f ) ); //CRASH HAPPENS ON THIS LINE   
   }   
}

Any thoughts as to why I receive a crash when trying to load the 3D game on this/these function(s)?????

Note: I have not properly FREE'd and released the SIO2 resources, sounds, etc... in my application yet <--- Does the iPhone retain this $h!t and would that be causing the crash?

jj

Posts : 77
Join date : 2008-09-24

Back to top Go down

BAD ACCESS crashing on App Loading Empty Re: BAD ACCESS crashing on App Loading

Post  sio2interactive Wed Nov 19, 2008 6:38 am

Yeah, make sure that you free and flush everything, the memory is really tight on the device, and is even more sensitive than on a conventional computer... I suggest you to use EXTENSIVELY Instruments in order to make sure that everything is clean at 100%.

Cheers,
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

BAD ACCESS crashing on App Loading Empty Re: BAD ACCESS crashing on App Loading

Post  matt Wed Nov 19, 2008 1:56 pm

According to your description, all crashes happen when you access sio2 attributes, so probably such attributes are accessed too early, i.e. when SIO2 is not yet initialized? Also note that you need to initialize the sio2->_SIO2physics attribute explicitly with sio2PhysicsInit.

Best,
Matt

matt

Posts : 155
Join date : 2008-09-30

http://elfrun.net

Back to top Go down

BAD ACCESS crashing on App Loading Empty Re: BAD ACCESS crashing on App Loading

Post  jj Wed Nov 19, 2008 4:22 pm

Thanks for reply, Matt.

matt wrote:According to your description, all crashes happen when you access sio2 attributes, so probably such attributes are accessed too early, i.e. when SIO2 is not yet initialized?

This was my thought exactly, you can see where I attempted to make some exceptions... however, it doesn't like the sio2 that I am attempting to use as the active exception...

Any suggestion as to how I can prevent crash using some kind of other programmatic exception.

Also, does the iPhone "retain" the previous application cycle's sio2 if it is not freed? Sometimes right when the glView loads, I see my world in a state as it left off the previous time I exited the app (then it will refresh to the initial game state immediately)... Of course, this is only the 25% of the time that the view actually does load... Could this be a part of my CRASH scenario...?

jj

Posts : 77
Join date : 2008-09-24

Back to top Go down

BAD ACCESS crashing on App Loading Empty Re: BAD ACCESS crashing on App Loading

Post  jj Wed Nov 19, 2008 5:59 pm

I am now attempting to do proper cleanup in the: void templateShutdown( void ) function in template.mm

Code:

void templateShutdown( void ) {

        //free target objects if they haven't been freed already
   if (target1removed != 1) sio2ObjectFree(_target1);  //CAUSES BAD ACCESS CRASH, SEE CODE BLOCK BELOW
   if (target2removed != 1) sio2ObjectFree(_target2);
   if (target3removed != 1) sio2ObjectFree(_target3);
   
        //free misc. game objects
   sio2ObjectFree(_floor);
   sio2ObjectFree(_aimerArrow);
   sio2ObjectFree(_ball1);
   sio2ObjectFree(_ball2);
   
        //free sounds
   sio2SoundFree(_tableBounceSound);
   sio2SoundFree(_targetBounceSound);

        //free sensors
   sio2SensorFree(_SIO2sensor_ball1_floor);
   sio2SensorFree(_SIO2sensor_ball2_floor);
   sio2SensorFree(_SIO2sensor_ball1_target1);
   sio2SensorFree(_SIO2sensor_ball1_target2);
   sio2SensorFree(_SIO2sensor_ball1_target3);
   sio2SensorFree(_SIO2sensor_ball2_target1);
   sio2SensorFree(_SIO2sensor_ball2_target2);
   sio2SensorFree(_SIO2sensor_ball2_target3);
   
   sio2ResourceUnloadAll( sio2->_SIO2resource );
   sio2 = sio2Shutdown();
   printf("\nSIO2: shutdown...\n" );
}

Is this the proper use of this function?

When the appWillTerminate is called in appDelegate.mm and this is called (in response), I get a BAD ACCESS crash inside of sio2object.cc :: SIO2object *sio2ObjectFree( SIO2object *_SIO2object ) { }

Code:

while( i != _SIO2object->n_vertexgroup )
   {
      sio2VertexGroupFree( _SIO2object->_SIO2vertexgroup[i] ); //BAD ACCESS CRASH!
      _SIO2object->_SIO2vertexgroup[i] = NULL;
      
      ++i;
   }

I have a feeling I'm not doing something correctly... Any thoughts/suggestions?

jj

Posts : 77
Join date : 2008-09-24

Back to top Go down

BAD ACCESS crashing on App Loading Empty Clarification

Post  jj Wed Nov 19, 2008 6:07 pm

Ok, sorry for having commentary and code all over the place.

Here is my question (a 2 parter):

1. Does sio2 and sio2resource/sio2window get loaded and initialized in the same order every time the program launches?

It is odd that the program loads CORRECTLY about 25% of the time. The other 75% I get a fatal bad Access crash. (see my first post in this topic). Is there a way to program an exception to avoid these crashes? When loading the game, I receive the crash EITHER in (EAGLView.mm)DRAWVIEW, or in (templateAppDelegate.mm)ACCELEROMETER:didAccelerate (about 50-50%).

2. What is the proper way to shutdown and cleanup all sio2? I think I may have some kind of "residue" that could be causing this erratic behavior?

Thanks in advance...

jj

Posts : 77
Join date : 2008-09-24

Back to top Go down

BAD ACCESS crashing on App Loading Empty Re: BAD ACCESS crashing on App Loading

Post  sio2interactive Wed Nov 19, 2008 7:30 pm

sio2ResourceUnloadAll( sio2->_SIO2resource );

sio2 = sio2Shutdown();


That's it... if you have some SIO2thread running you'll have to close them manually since they are not "resources"
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

BAD ACCESS crashing on App Loading Empty Re: BAD ACCESS crashing on App Loading

Post  meteors Mon Jan 05, 2009 7:17 pm

Ok, so what exactly is the situation with the iPhone screen retaining graphics from the last session of SIO2?

What is causing it, exactly?

Do you know any good tricks to flush the memory?


Thanks!!!
-joshua















jj wrote:Thanks for reply, Matt.

matt wrote:According to your description, all crashes happen when you access sio2 attributes, so probably such attributes are accessed too early, i.e. when SIO2 is not yet initialized?

This was my thought exactly, you can see where I attempted to make some exceptions... however, it doesn't like the sio2 that I am attempting to use as the active exception...

Any suggestion as to how I can prevent crash using some kind of other programmatic exception.

Also, does the iPhone "retain" the previous application cycle's sio2 if it is not freed? Sometimes right when the glView loads, I see my world in a state as it left off the previous time I exited the app (then it will refresh to the initial game state immediately)... Of course, this is only the 25% of the time that the view actually does load... Could this be a part of my CRASH scenario...?
meteors
meteors

Posts : 241
Join date : 2008-11-08
Location : Sunny Florida

Back to top Go down

BAD ACCESS crashing on App Loading Empty Re: BAD ACCESS crashing on App Loading

Post  sio2interactive Mon Jan 05, 2009 8:04 pm

Just do an early glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

BAD ACCESS crashing on App Loading Empty Re: BAD ACCESS crashing on App Loading

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum