BUG? IndexOutOfBoundsException inside Scene

  ... in the unlikely case you discovered a bug, post it here.

BUG? IndexOutOfBoundsException inside Scene

Postby morthek » Tue May 10, 2011 7:57 pm


In my game i am always removing sprites inside the update thread. The scene have click, scroll and pinchZoom detectors. Sometimes when it gets lagy(Milestone with froyo sucks) i get the folowing error:

java.lang.IndexOutOfBoundsException: Invalid index 33, size is 33
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
at java.util.ArrayList.get(ArrayList.java:311)
at org.anddev.andengine.entity.scene.Scene.onSceneTouchEvent(Scene.java:314)
at org.anddev.andengine.engine.Engine.onTouchScene(Engine.java:397)
at org.anddev.andengine.engine.Engine.onTouchEvent(Engine.java:383)
at org.anddev.andengine.input.touch.controller.BaseTouchController.fireTouchEvent(BaseTouchController.java:82)
at org.anddev.andengine.extension.input.touch.controller.MultiTouchController.onHandleTouchMove(MultiTouchController.java:68)
at org.anddev.andengine.extension.input.touch.controller.MultiTouchController.onHandleMotionEvent(MultiTouchController.java:53)
at org.anddev.andengine.engine.Engine.onTouch(Engine.java:352)
at android.view.View.dispatchTouchEvent(View.java:3778)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:939)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:939)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1672)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
at android.app.Activity.dispatchTouchEvent(Activity.java:2103)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1656)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1813)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:143)
at android.app.ActivityThread.main(ActivityThread.java:4717)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)

Looking in the Scene Class, line 314 we have:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. if(touchAreaCount > 0) {
  2.                                 if(this.mOnAreaTouchTraversalBackToFront) { /* Back to Front. */
  3.                                         for(int i = 0; i < touchAreaCount; i++) {
  4.                                                 final ITouchArea touchArea = touchAreas.get(i);
  5.                                                 if(touchArea.contains(sceneTouchEventX, sceneTouchEventY)) {
  6.                                                         final Boolean handled = this.onAreaTouchEvent(pSceneTouchEvent, sceneTouchEventX, sceneTouchEventY, touchArea);
  7.                                                         if(handled != null && handled) {
  8.                                                                 /* If binding of ITouchAreas is enabled and this is an ACTION_DOWN event,
  9.                                                                  *  bind this ITouchArea to the PointerID. */
  10.                                                                 if(this.mTouchAreaBindingEnabled && isActionDown) {
  11.                                                                         this.mTouchAreaBindings.put(pSceneTouchEvent.getPointerID(), touchArea);
  12.                                                                 }
  13.                                                                 return true;
  14.                                                         }
  15.                                                 }
  16.                                         } ...
Parsed in 0.012 seconds, using GeSHi

If a game that inserts and removes sprites and its toucharea all the time. Can the for loop starts by going from 0 to 33, and, because the game is lagy, one spites gets removed before the loop has ended, making the toucharea array size 32, resulting in a IndexOutOfBoundsException?
Victor Araujo
Posts: 29
Joined: Wed Sep 22, 2010 6:31 pm

Re: BUG? IndexOutOfBoundsException inside Scene

Postby alex_pof » Wed Jul 13, 2011 12:46 am

I'm running into the same problem. I cant really give any more information than what is provided though. Is this a confirmed bug or am i doing something wrong?
Posts: 1
Joined: Wed Jul 13, 2011 12:45 am

Re: BUG? IndexOutOfBoundsException inside Scene

Postby senhor » Fri Jul 04, 2014 5:48 pm

It has been 3 years and I still have the same problem. Isn't there any solutions?
Posts: 7
Joined: Tue Jul 01, 2014 5:26 pm

Return to Bugs

Who is online

Users browsing this forum: No registered users and 3 guests