Hi all,
I'm testing the lifecycle of jme2 SimpleApplet class, and it seems to me it is broken (similar problems occur with StandardApplet class, too).
Two use cases with the TestSimpleApplet class loaded by Sun appletViewer:
a) Restart
if the user selects the appletViewer "Restart" menu item, the jvm process hangs.
No logs, no stack traces.
Restart calls the following applet methods:
- destroy
- init
- start
b) Reload
if the user selects the appletViewer "Reload" menu item, this breaks the application.
This is the log:
INFO: display_parent.isDisplayable() = false
org.lwjgl.LWJGLException: Parent.isDisplayable() must be true
at org.lwjgl.opengl.Display.createWindow(Display.java:303)
at org.lwjgl.opengl.Display.create(Display.java:840)
at org.lwjgl.opengl.Display.create(Display.java:768)
at com.jmex.awt.applet.BaseApplet$1.run(BaseApplet.java:122)
28-dic-2009 2.18.22 com.jme.renderer.lwjgl.LWJGLRenderer <init>
INFO: LWJGLRenderer created. W: 640 H: 480 Version: 2.2.1
28-dic-2009 2.18.22 class jmetest.awt.applet.TestSimpleApplet start()
GRAVE: Exception in game loop
java.lang.NullPointerException
at com.jme.renderer.lwjgl.LWJGLRenderer.<init>(LWJGLRenderer.java:200)
at com.jme.system.lwjgl.LWJGLDisplaySystem.initForApplet(LWJGLDisplaySystem.java:708)
at com.jmex.awt.applet.BaseApplet.gameLoop(BaseApplet.java:152)
at com.jmex.awt.applet.BaseApplet$1.run(BaseApplet.java:128)
28-dic-2009 2.18.22 com.jmex.awt.applet.BaseSimpleApplet cleanup
INFO: Cleaning up resources.
28-dic-2009 2.18.22 com.jmex.awt.applet.BaseApplet$1 run
INFO: Application ending.
Reload calls the following applet methods:
* destroy
* new applet instance (constructor, if any)
* init
* start
I tried to fix the BaseApplet class (used by SimpleApplet)... initial patch in attachment.
The same use cases:
a) Restart
"Restart" seems to work now.
The unique problem with TestSimpleApplet class is that the "F4 - toggle stats" text object is not correctly rendered when the applet restarts.
b) Reload
still doesn't work. The log contains:
Exception in thread "Thread-8" java.lang.RuntimeException: org.lwjgl.LWJGLException: Parent.isDisplayable() must be true
at com.jmex.awt.applet.BaseApplet$1.run(BaseApplet.java:133)
Caused by: org.lwjgl.LWJGLException: Parent.isDisplayable() must be true
at org.lwjgl.opengl.Display.createWindow(Display.java:303)
at org.lwjgl.opengl.Display.create(Display.java:840)
at org.lwjgl.opengl.Display.create(Display.java:768)
at com.jmex.awt.applet.BaseApplet$1.run(BaseApplet.java:130)
BaseApplet init() method adds the new created "displayParent" canvas to the applet container and then calls thsi.setVisible(true).
So I don't understand why the "displayParent" canvas object, when the applet is reloaded, is NOT displayable (that is, not attached to any parent container or not visible, is it correct ?).
Any idea ???
Thank you,
Luca