Strange error at java.util.ArrayList.rangeCheck(ArrayList.java:635)

485 views
Skip to first unread message

Gareth Murfin

unread,
Oct 19, 2015, 9:56:34 AM10/19/15
to CodenameOne Discussions
I cant work out whats causing this but I believe it must be a bug somewhere?

[Timer-0] 0:0:37,452 - ####StateMachine:NO
at java.util.ArrayList.rangeCheck(ArrayList.java:635)
at java.util.ArrayList.get(ArrayList.java:411)
at com.codename1.ui.Container.getComponentAt(Container.java:1121)
at com.codename1.ui.Container.doLayout(Container.java:1092)
at com.codename1.ui.Container.layoutContainer(Container.java:1081)
at com.codename1.ui.Container.doLayout(Container.java:1094)
at com.codename1.ui.Container.layoutContainer(Container.java:1081)
at com.codename1.ui.Display.setCurrent(Display.java:1338)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:78)
at com.codename1.ui.Display.processSerialCalls(Display.java:1147)
at com.codename1.ui.Display.edtLoopImpl(Display.java:1091)
at com.codename1.ui.Display.mainEDTLoop(Display.java:994)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
java.lang.IndexOutOfBoundsException: Index: 2, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:635)
at java.util.ArrayList.get(ArrayList.java:411)
at com.codename1.ui.Container.getComponentAt(Container.java:1121)
at com.codename1.ui.Container.doLayout(Container.java:1092)
at com.codename1.ui.Container.layoutContainer(Container.java:1081)
at com.codename1.ui.Container.doLayout(Container.java:1094)
at com.codename1.ui.Container.layoutContainer(Container.java:1081)
at com.codename1.ui.Display.setCurrent(Display.java:1338)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:78)
at com.codename1.ui.Display.processSerialCalls(Display.java:1147)
at com.codename1.ui.Display.edtLoopImpl(Display.java:1091)
at com.codename1.ui.Display.mainEDTLoop(Display.java:994)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)

Gareth Murfin

unread,
Oct 19, 2015, 11:14:58 AM10/19/15
to CodenameOne Discussions
and one android

W/ResourceType(13888): No package identifier when getting value for resource number 0x00000000
W/System.err(13888): java.lang.NullPointerException: Attempt to invoke virtual method 'void com.codename1.ui.Form.registerAnimated(com.codename1.ui.animations.Animation)' on a null object referen
ce
W/System.err(13888):    at com.codename1.ui.TextField.initComponentImpl(TextField.java:1494)
W/System.err(13888):    at com.codename1.ui.Container.initComponentImpl(Container.java:741)
W/System.err(13888):    at com.codename1.ui.Container.initComponentImpl(Container.java:741)
W/System.err(13888):    at com.codename1.ui.Container.initComponentImpl(Container.java:741)
W/System.err(13888):    at com.codename1.ui.Container.initComponentImpl(Container.java:741)
W/System.err(13888):    at com.codename1.ui.Container.initComponentImpl(Container.java:741)
W/System.err(13888):    at com.codename1.ui.Form.initComponentImpl(Form.java:1491)
W/System.err(13888):    at com.codename1.ui.Display.setCurrent(Display.java:1329)
W/System.err(13888):    at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:78)
W/System.err(13888):    at com.codename1.ui.Display.processSerialCalls(Display.java:1147)
W/System.err(13888):    at com.codename1.ui.Display.edtLoopImpl(Display.java:1091)
W/System.err(13888):    at com.codename1.ui.Display.mainEDTLoop(Display.java:994)
W/System.err(13888):    at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
W/System.err(13888):    at com.codename1.impl.CodenameOneThread$1.run(CodenameOneThread.java:60)
W/System.err(13888):    at java.lang.Thread.run(Thread.java:818)

Shai Almog

unread,
Oct 19, 2015, 11:23:52 PM10/19/15
to CodenameOne Discussions
Do you have an animation in progress or are you changing the UI from a separate thread?

Gareth Murfin

unread,
Oct 20, 2015, 1:55:31 PM10/20/15
to CodenameOne Discussions
No i dont think so, its happening on ios and simulator though. it would be very handy if the stacktrace it threw pointed to a line in my code but it doesnt :-(


[EDT] 0:1:30,425 - Error java.lang.IndexOutOfBoundsException: 2 out of: 0
[EDT] 0:1:30,431 - Current Form GOODLUCK
[EDT] 0:1:30,433 - Exception: java.lang.IndexOutOfBoundsException - 2 out of: 0
java.lang.IndexOutOfBoundsException
    at java_util_ArrayList.get:328
    at com_codename1_ui_Container.getComponentAt:1121
    at com_codename1_ui_Container.doLayout:1092
    at com_codename1_ui_Container.layoutContainer:1081
    at com_codename1_ui_Container.doLayout:1094
    at com_codename1_ui_Container.layoutContainer:1081
    at com_codename1_ui_Display.setCurrent:1338
    at com_codename1_ui_RunnableWrapper.run:78
    at com_codename1_ui_Display.processSerialCalls:1147
    at com_codename1_ui_Display.edtLoopImpl:1091
    at com_codename1_ui_Display.mainEDTLoop:994
    at com_codename1_ui_RunnableWrapper.run:120
    at com_codename1_impl_CodenameOneThread.run:176
    at java_lang_Thread.runImpl:153 

Shai Almog

unread,
Oct 20, 2015, 10:57:02 PM10/20/15
to CodenameOne Discussions
That generally means the layout code here failed:
        layout.layoutContainer(this);
       
int count = getComponentCount();
       
for (int i = 0; i < count; i++) {
           
Component c = getComponentAt(i);
           
if (c instanceof Container) {
               
((Container) c).layoutContainer();
           
}else{
                c
.laidOut();
           
}
       
}
        laidOut
();
        onParentPositionChange
();            

Do you see any reason why count will be 2 and then while iterating the components will no longer be there?
If you can reproduce this in the simulator I suggest starting from there.

Gareth Murfin

unread,
Oct 21, 2015, 6:07:30 AM10/21/15
to codenameone...@googlegroups.com
i am actually removing the 3 main containers from the main form just before this happens, but i dont understand why that would crash it still, when theyre removed, then cn1 should know theyve been removed and the count will drop'?
Here is the code i call not long before the crash, this isnt in call serially because then i was getting a flash of the form before it blacks out. The purpose of this method is just to be able to turn a form into a black screen when things need to happen automatically and without seeing the screen come up.

 private void blackOutForm(final Form f, String whoCalled)
    {
        _("blackOutForm start...  whoCalled->"+whoCalled);
          //this needs to fully finish a frame before we proceed
     //    Display.getInstance().callSerially(new Runnable() {
     //   public void run() {
            _("a");
            if (f.getUIID().equals("BLACK"))
            {
                _("form already blacked out no need to do it again.");
                return;
            }
             f.setUIID("BLACK");//make it an empty black form. //keep this out here
             _("b");
             
             
             //remove topbar and center
              Container TOPBAR = (Container) nl.t.findByNameX("TOPBAR_NORTH", f );
              if (TOPBAR!=null)
              {
                  _("x1");
                   f.removeComponent(TOPBAR);
              }
             
               Container CENTER = (Container) nl.t.findByNameX("CENTER", f );
              if (CENTER!=null)
              {
                  _("x2");
                   f.removeComponent(CENTER);
              }
              
                 Container SOUTH = (Container) nl.t.findByNameX("SOUTH", f );
                  if (SOUTH!=null)
              {
                  _("x3");
                   f.removeComponent(SOUTH);
              }
             
           
            _("c");
            f.invalidate();
            _("d");
             _("blackOutForm end");
      //      }
      //  });   
    }

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/WpVypoy4ANs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/fbf83382-7f24-4855-a187-5edfe976da5a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Gareth Murfin
(Android Freelancer - www.garethmurfin.co.uk)

Gareth Murfin

unread,
Oct 21, 2015, 6:30:11 AM10/21/15
to CodenameOne Discussions
Also I keep getting another similar oen that might be releasted around the same time 

[EDT] 0:0:2,783 - Exception in AppName version 1.0
[EDT] 0:0:2,783 - OS ios
[EDT] 0:0:2,783 - Error java.lang.NullPointerException
[EDT] 0:0:2,783 - Current Form SPLASH
[EDT] 0:0:2,783 - Exception: java.lang.NullPointerException - null
at com.codename1.ui.TextField.initComponentImpl(TextField.java:1494)
at com.codename1.ui.Container.initComponentImpl(Container.java:741)
at com.codename1.ui.Container.initComponentImpl(Container.java:741)
at com.codename1.ui.Container.initComponentImpl(Container.java:741)
at com.codename1.ui.Container.initComponentImpl(Container.java:741)
at com.codename1.ui.Container.initComponentImpl(Container.java:741)
at com.codename1.ui.Form.initComponentImpl(Form.java:1491)
at com.codename1.ui.Display.setCurrent(Display.java:1329)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:78)
at com.codename1.ui.Display.processSerialCalls(Display.java:1147)
at com.codename1.ui.Display.edtLoopImpl(Display.java:1091)
at com.codename1.ui.Display.mainEDTLoop(Display.java:994)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
java.lang.NullPointerException
at com.codename1.ui.TextField.initComponentImpl(TextField.java:1494)
at com.codename1.ui.Container.initComponentImpl(Container.java:741)
at com.codename1.ui.Container.initComponentImpl(Container.java:741)
at com.codename1.ui.Container.initComponentImpl(Container.java:741)
at com.codename1.ui.Container.initComponentImpl(Container.java:741)
at com.codename1.ui.Container.initComponentImpl(Container.java:741)
at com.codename1.ui.Form.initComponentImpl(Form.java:1491)
at com.codename1.ui.Display.setCurrent(Display.java:1329)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:78)
at com.codename1.ui.Display.processSerialCalls(Display.java:1147)
at com.codename1.ui.Display.edtLoopImpl(Display.java:1091)
at com.codename1.ui.Display.mainEDTLoop(Display.java:994)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)

To unsubscribe from this group and all its topics, send an email to codenameone-discussions+unsub...@googlegroups.com.

Shai Almog

unread,
Oct 21, 2015, 10:16:45 PM10/21/15
to CodenameOne Discussions
If you still have a transition or animation going this will happen since references might still exist to these components.
callSerially will postpone to the next EDT cycle not till the animations are finished. I'll need to understand what sort of animations you have going (transition, hierarchy etc.) to give you better advice.

Gareth Murfin

unread,
Oct 22, 2015, 6:16:05 AM10/22/15
to codenameone...@googlegroups.com
Im not using anything like that, its all default stuff, the only thing I can think of is I have formTransitionOut set to Slide and includeNativeBool = true 

On 22 October 2015 at 10:16, Shai Almog <shai....@gmail.com> wrote:
If you still have a transition or animation going this will happen since references might still exist to these components.
callSerially will postpone to the next EDT cycle not till the animations are finished. I'll need to understand what sort of animations you have going (transition, hierarchy etc.) to give you better advice.

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/WpVypoy4ANs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Gareth Murfin

unread,
Oct 22, 2015, 8:45:16 AM10/22/15
to codenameone...@googlegroups.com
I was just thinking, you know if you wish to remove something from a form, should that be done in POST or PRE? Im doing all my funky stuff in postShow, if I do it in preshow maybe my problems will go away ?

Chen Fishbein

unread,
Oct 22, 2015, 11:06:46 AM10/22/15
to CodenameOne Discussions
Use the "before"

Gareth Murfin

unread,
Oct 22, 2015, 1:01:47 PM10/22/15
to CodenameOne Discussions
yep that appears to have fixed a lot of my iOS hanging, i will bare this in mind for the future... thank you!

On Thursday, October 22, 2015 at 11:06:46 PM UTC+8, Chen Fishbein wrote:
Use the "before"
Reply all
Reply to author
Forward
0 new messages