Hi,
almost every time when I close my browser window running my JM3 applet the java process hangs and i have to kill it. Looking at the java console the problem occurs between the “applet:destroyRemoved” and “applet:destroyDone”" messages.
AppletHarness destroy method:
[java]
@Override
public void destroy(){
System.out.println(“applet:destroyStart”);
SwingUtilities.invokeLater(new Runnable(){
public void run(){
removeAll();
System.out.println(“applet:destroyRemoved”);
}
});
app.stop(true);
System.out.println(“applet:destroyDone”);
appToApplet.remove(app);
}
[/java]
Console screenshot:
http://i.imgur.com/vwozs.png
Anyone have any tips? I need send my applet to production but I cant because it hangs every time…
Thanks,
It seems that the canvas is getting removed & destroyed at the same time so the OGL thread doesn’t have a chance to shut itself down and thus hangs since there’s nowhere to draw to …
Can you put a small wait before app.stop(true) to ensure the removal is detected prior to the destruction of the canvas?
1 Like
@Momoko_Fan said:
It seems that the canvas is getting removed & destroyed at the same time so the OGL thread doesn't have a chance to shut itself down and thus hangs since there's nowhere to draw to ...
Can you put a small wait before app.stop(true) to ensure the removal is detected prior to the destruction of the canvas?
Works like a charm :), modified code (AppletHarness.java):
[java]
@Override
public void destroy() {
System.out.println("applet:destroyStart");
SwingUtilities.invokeLater(new Runnable() {
public void run() {
removeAll();
System.out.println("applet:destroyRemoved");
}
});
try {
wait(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
app.stop(true);
System.out.println("applet:destroyDone");
appToApplet.remove(app);
}
[/java]
Is that correct? If it is can you commit this change on svn?
Thank you for the fast answer.
Maybe change invokeLater to invokeAndWait is a better option…
[java]
@Override
public void destroy() {
System.out.println("applet:destroyStart");
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
removeAll();
System.out.println("applet:destroyRemoved");
}
});
} catch (Exception e) {
e.printStackTrace();
}
app.stop(true);
System.out.println("applet:destroyDone");
appToApplet.remove(app);
}
[/java]
Thanks,