<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://jogamp.org/bugzilla/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.2"
          urlbase="https://jogamp.org/bugzilla/"
          
          maintainer="sgothel@jausoft.com"
>

    <bug>
          <bug_id>866</bug_id>
          
          <creation_ts>2013-10-23 11:13:33 +0200</creation_ts>
          <short_desc>Frequent IndexOutOfBoundsException in jogamp.opengl.egl.EGLGraphicsConfigurationFactory</short_desc>
          <delta_ts>2013-10-23 16:58:53 +0200</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>JogAmp</classification>
          <product>Jogl</product>
          <component>embedded</component>
          <version>2</version>
          <rep_platform>embedded_arm</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>---</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Brice Figureau">brice.figureau</reporter>
          <assigned_to name="Sven Gothel">sgothel</assigned_to>
          
          
          <cf_type>---</cf_type>
          <cf_scm_refs>1f8a46cf71d5ecd9b8d649ccb09ccf986c48b960</cf_scm_refs>
          <cf_workaround>---</cf_workaround>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>3161</commentid>
    <comment_count>0</comment_count>
    <who name="Brice Figureau">brice.figureau</who>
    <bug_when>2013-10-23 11:13:33 +0200</bug_when>
    <thetext>In android, with jogl 2.0.2, we get a relatively large number of this exception:



If you look at the jogamp.opengl.egl.EGLGraphicsConfigurationFactory.eglChooseConfig code, you&apos;ll find this:



&gt; java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Invalid index 24, size is 24
&gt;  at jogamp.newt.c.a(SourceFile:220)
&gt;  at jogamp.newt.c.a(SourceFile:135)
&gt;  at jogamp.newt.f.runOnEDTIfAvail(SourceFile:207)
&gt;  at jogamp.newt.v.runOnEDTIfAvail(SourceFile:1670)
&gt;  at jogamp.newt.v.setVisible(SourceFile:834)
&gt;  at jogamp.newt.v.setVisible(SourceFile:839)
&gt;  at com.jogamp.newt.b.a.setVisible(SourceFile:410)
&gt;  at com.daysofwonder.tt.android.NewtBaseActivity.resumePlay(SourceFile:418)
&gt;  at com.daysofwonder.tt.android.NewtBaseActivity.onWindowFocusChanged(SourceFile:145)
&gt;  at com.android.internal.policy.impl.PhoneWindow$DecorView.onWindowFocusChanged(PhoneWindow.java:2451)
&gt;  at android.view.View.dispatchWindowFocusChanged(View.java:7433)
&gt;  at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:930)
&gt;  at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:2934)
&gt;  at android.os.Handler.dispatchMessage(Handler.java:99)
&gt;  at android.os.Looper.loop(Looper.java:137)
&gt;  at android.app.ActivityThread.main(ActivityThread.java:5039)
&gt;  at java.lang.reflect.Method.invokeNative(Native Method)
&gt;  at java.lang.reflect.Method.invoke(Method.java:511)
&gt;  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
&gt;  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
&gt;  at dalvik.system.NativeStart.main(Native Method)
&gt; Caused by: java.lang.IndexOutOfBoundsException: Invalid index 24, size is 24
&gt;  at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
&gt;  at java.util.ArrayList.remove(ArrayList.java:399)
&gt;  at jogamp.opengl.egl.EGLGraphicsConfigurationFactory.eglChooseConfig(SourceFile:421)
&gt;  at jogamp.opengl.egl.EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(SourceFile:251)
&gt;  at jogamp.newt.driver.android.WindowDriver.createNativeImpl(SourceFile:345)
&gt;  at jogamp.newt.v.createNative(SourceFile:313)
&gt;  at jogamp.newt.v.setVisibleActionImpl(SourceFile:776)
&gt;  at jogamp.newt.J.run(SourceFile:826)
&gt;  at com.jogamp.common.util.M.run(SourceFile:112)
&gt;  at jogamp.newt.e.run(SourceFile:331)

If you look at the code in jogamp.opengl.egl.EGLGraphicsConfigurationFactory.eglChooseConfig, you&apos;ll find this:

&gt;            List&lt;GLCapabilitiesImmutable&gt; removedCaps = new ArrayList&lt;GLCapabilitiesImmutable&gt;();
&gt;            for(int i=0; i&lt;availableCaps.size(); ) {
&gt;                final GLCapabilitiesImmutable aCap = availableCaps.get(i);
&gt;                if(aCap.getVisualID(VIDType.NATIVE) != nativeVisualID) {
&gt;                    if(DEBUG) { System.err.println(&quot;Remove[&quot;+i+&quot;] (mismatch VisualID): &quot;+aCap); }
&gt;                    removedCaps.add(availableCaps.remove(i));
&gt;                } if( 0 == aCap.getDepthBits() &amp;&amp; 0 &lt; capsChosen.getDepthBits() ) {
&gt;                    // Hack for HiSilicon/Vivante/Immersion.16 Renderer ..
&gt;                    if(DEBUG) { System.err.println(&quot;Remove[&quot;+i+&quot;] (mismatch depth-bits): &quot;+aCap); }
&gt;                    removedCaps.add(availableCaps.remove(i));
&gt;                } else {
&gt;                    i++;
&gt;                }
&gt;            }


Notice that there is no &quot;else&quot; before the second if statement, which means that it is possible to remove twice the same element from the array leading to this exception.

Unfortunately this happens a lot of time on some devices, when the application is paused/resumed. We weren&apos;t able to reproduce the issue on our own devices, but our crash reporter logged this one (or a variant) quite a lot.

We probably can send a Pull Request since this is a trivial fix.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3164</commentid>
    <comment_count>1</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2013-10-23 16:58:53 +0200</bug_when>
    <thetext>Add missing &apos;else&apos; in branch

Thank you!</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>