gama-platform / gama.old

Main repository for developing the 1.x versions of GAMA
GNU General Public License v3.0
304 stars 99 forks source link

Exception while drawing layers: Index: 0 #608

Closed pcaillou closed 9 years ago

pcaillou commented 9 years ago
What steps will reproduce the problem?
1. Open model PDE_diffusion_models/anisotropic_diffusion_various_methods.gaml
2. Click on button Exp. diffusion
3. Wait for simulation ready
4. Click on button Exp. diffusion

What is the expected output? What do you see instead?
Status bar shown "Closing prvious displays". In eclipse console, it appear exception:
Exception while drawing layers: Index: 0
Exception while drawing layers: Index: 0
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at msi.gama.jogl.scene.ModelScene.drawEnvironmentBounds(ModelScene.java:201)
    at msi.gama.jogl.scene.ModelScene.draw(ModelScene.java:85)
    at msi.gama.jogl.utils.JOGLAWTGLRenderer.drawModel(JOGLAWTGLRenderer.java:324)
    at msi.gama.jogl.utils.JOGLAWTGLRenderer.drawScene(JOGLAWTGLRenderer.java:336)
    at msi.gama.jogl.utils.JOGLAWTGLRenderer.display(JOGLAWTGLRenderer.java:257)
    at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78)
    at javax.media.opengl.GLCanvas$DisplayAction.run(GLCanvas.java:435)
    at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194)
    at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:412)
    at javax.media.opengl.GLCanvas.display(GLCanvas.java:244)
    at javax.media.opengl.GLCanvas.paint(GLCanvas.java:277)
    at sun.awt.RepaintArea.paintComponent(Unknown Source)
    at sun.awt.RepaintArea.paint(Unknown Source)
    at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$000(Unknown Source)
    at java.awt.EventQueue$1.run(Unknown Source)
    at java.awt.EventQueue$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$2.run(Unknown Source)
    at java.awt.EventQueue$2.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

Please use labels and text to provide additional information.
Windows 8 64 bit, GAMA r7578
This issue appear in this morning. Yesterday afternoon, it didnt have this exception

Original issue reported on code.google.com by hqnghi88 on 2013-09-10 03:29:42

pcaillou commented 9 years ago
Oh oh. It seems that this one is a good candidate for Arnaud, then… :)

Original issue reported on code.google.com by alexis.drogoul on 2013-09-10 03:37:48

pcaillou commented 9 years ago
I'd like to have a look but I cannot make run the Model with diffusion.

I still have an error in the ummisco.gaml.extension.maths/ in GamlAdditions.java where
I need to remove all the genrerated code.

So this is in the drawing of the environment

It seems that it seg fault here:
addGeometry(g, GAMA.getSimulation().getAgent(), 0, 0, c, false, c, false, 0, 0, offset,
scale, false,"env", false, 1d, "environment");

Is it possible that in this case GAMA.getSimulation().getAgent() is null?

Original issue reported on code.google.com by agrignard on 2013-09-10 03:55:08

pcaillou commented 9 years ago
It would be a good idea to try to remove the compilation errors first… Have you tried
completely removing the plug-in and checking it out again ? 

Original issue reported on code.google.com by alexis.drogoul on 2013-09-10 04:09:58

pcaillou commented 9 years ago
Hi,
This block solve the issue

            IAgent a=null;
            try{
                a =GAMA.getSimulation().getAgent();
            }
            catch(Exception e) {}
            if(a==null) {return;}
            addGeometry(g, a , 0, 0, c, false, c, false, 0, 0, offset, scale, false,
                "env", false, 1d, "environment");

Original issue reported on code.google.com by hqnghi88 on 2013-09-10 04:12:40

pcaillou commented 9 years ago
Of course it solves it :) But never, never use empty catch blocks, please (I hope you
haven't in your plugins :) ).

However, the problem is to understand why it is there in the first place. And especially
since yesterday. Are you sure you never had this problem before ?

My guess is that something has changed in the drawing of layers, etc. that makes OpenGL
try to draw the display after the first simulation has been nullified. I will try to
review the code committed yesterday to understand this.

Original issue reported on code.google.com by alexis.drogoul on 2013-09-10 04:20:12

pcaillou commented 9 years ago
Ok, I have 2 empty catch blocks in ummisco.maths, but it followed by 2 finally blocks.
Thanks.

The whole history is that i didn't test with this diffusion model yesterday (actually,
this diffusion model with 2 display, i've test with diffusion model 01 display). I've
take a look at ModelScene.java which has some bit change in r7529. Is there the cause?

Original issue reported on code.google.com by hqnghi88 on 2013-09-10 04:31:14

pcaillou commented 9 years ago
I change the way to draw the environment but something like one week ago.

So it will be hard to analyse all the commit.

In most of the model I did not see any problem like that.

So the drawEnvironmentBounds() simply adds a geometry in the list of geometry (or an
empty geometry if the draw_env:  false) and it need to have the Simualtion Agent to
make the link between the geometry drawn and the agent (for the picking), but maybe
if the world is always display in the picking we can remove this agent and simply give
a null agent (it means the geomtry will not be attached to any agent)

Original issue reported on code.google.com by agrignard on 2013-09-10 04:32:31

pcaillou commented 9 years ago
The change in ModelScene in revision 7529 has no impact on this I think.

Original issue reported on code.google.com by agrignard on 2013-09-10 04:34:27

pcaillou commented 9 years ago
It seems to work on mine

I've jsut commited this two lines (because I cannot compile those operator) but I don't
think it has an effet:
//diffusion var: phero on: cells_dot mat_diffu: math_diff method: "dot_product";    
//diffusion var: phero on: cells_convol mat_diffu: math_diff method: "convolution";

So does it means it's a windows problem?

Original issue reported on code.google.com by agrignard on 2013-09-10 08:58:11

pcaillou commented 9 years ago
I can't reproduce the bug on MacOS X. Everything seems fine with reloading, relaunching,
etc. As I understand it regarding the logs you have provided, it seems that the error
comes from the fact that previous displays are not closed (and thus try to display
themselves, probably causing this error). 

Can you make further tests with other models using two OpenGL displays (like this one)
? It may be the case it is a bit more general than what we thought before. 

Thanks !

Original issue reported on code.google.com by alexis.drogoul on 2013-09-10 10:17:33

pcaillou commented 9 years ago
Hi Alexis,
I've test with other 02 displays model and also its old version (Benoit's version).
Issue didn't appeared. The only change is in "display" block, I encounter this issue
when i use "grid", instead of "species".

        display "dot" type: opengl {
            grid cells_dot triangulation: true;
        }

Original issue reported on code.google.com by hqnghi88 on 2013-09-10 12:02:20

pcaillou commented 9 years ago
I've been able to reproduce it under Windows 7, but as a non-blocking exception. The
exception is thrown and displayed in the console, but the displays run fine afterwards.
Can you confirm this ?

Original issue reported on code.google.com by alexis.drogoul on 2013-09-10 16:17:50

pcaillou commented 9 years ago
Hi, I've waite for 2 mins but status is always Closing previous displays.

Original issue reported on code.google.com by hqnghi88 on 2013-09-10 16:27:32

pcaillou commented 9 years ago
So it means it's blocking ? You can't run the simulation again, is that how it manifests
itself on Windows 8 ? 

And you can only observe it when you use "grid" (neither "species" nor "agents") ?

Original issue reported on code.google.com by alexis.drogoul on 2013-09-10 16:45:31

pcaillou commented 9 years ago
Yah it's blocking till now. It appear only when i use 02 display  which have "grid"

Original issue reported on code.google.com by hqnghi88 on 2013-09-10 17:10:50

pcaillou commented 9 years ago
Can you send a simple "test_model.gaml" with the 2 displays?

Original issue reported on code.google.com by agrignard on 2013-09-10 17:48:05

pcaillou commented 9 years ago
It is exactly the diffu model which is commented 2 diffu statements, you have done this
before

Original issue reported on code.google.com by hqnghi88 on 2013-09-10 17:52:42

pcaillou commented 9 years ago
I have tried to understand what was causing this exception here, but I really don't
know. So I am about to release a very simple patch, which makes sure that no OpenGL
operations are allowed when there is no simulation defined (or no more simulation defined).
However, it is clearly a workaround and not a fix. 

Original issue reported on code.google.com by alexis.drogoul on 2013-09-10 19:09:35

pcaillou commented 9 years ago
This issue was closed by revision r7585.

Original issue reported on code.google.com by alexis.drogoul on 2013-09-10 19:12:27