-
Notifications
You must be signed in to change notification settings - Fork 39
Description
The following is for code pulled from GitHub, version:
3D [dev] 1.6.0-pre1-1304191823-experimental 19 Apr 2013 18:23:21 EDT
Windows 7 operating system 64-bit (but issue can also be reproduced on Linux for older versions of Java3D), Oracle JDK 6
I've run into a pretty serious bug which freezes the GUI. The context is: I have two active Canvas3D objects in JPanels as components in a parent JPanel. When the parent's removeAll() method is called, this in turn calls removeNotify() on the two Canvas3D objects.
From removeNotify() I note the following block (lines 1384-1396):
if (isRunning && (screen != null)) {
// If there is other Canvas3D in the same screen
// rendering, stop it before JDK create new Canvas
rdr = screen.renderer;
if (rdr != null) {
VirtualUniverse.mc.postRequest(MasterControl.STOP_RENDERER, rdr);
// Bug: Canvas blocks on this when another canvas3d is active... (my comment)
while (!rdr.userStop) {
MasterControl.threadYield();
}
}
}
The freeze appears to occur in the threadYield loop. If I put debug print-outs in the postRequest() and handlePendingRequest() methods of MasterControl (lines 3006-3021):
} else if (type == START_RENDERER) {
// My comment
System.out.println("J3D Master Control: Request handled: START RENDERER");
if (o instanceof Canvas3D) {
Canvas3D c3d = (Canvas3D) o;
if (!c3d.isFatalError()) {
c3d.isRunningStatus = true;
}
} else {
((Renderer) o).userStop = false;
}
threadListsChanged = true;
} else if (type == STOP_RENDERER) {
// My comment
System.out.println("J3D Master Control: Request handled: STOP RENDERER");
if (o instanceof Canvas3D) {
((Canvas3D) o).isRunningStatus = false;
} else {
((Renderer) o).userStop = true;
}
...and initiate a removeAll() call, the following is printed to the console:
J3D Master Control: STOP RENDERER REQUEST
J3D Master Control: Request handled: STOP RENDERER
J3D Master Control: START RENDERER REQUEST
J3D Master Control: Request handled: START RENDERER
J3D Master Control: STOP RENDERER REQUEST
Clearly, the second request to stop the renderer is not being handled; the doWork() method of MasterControl is no longer being called, which suggests a deadlock somewhere..? My expertise is still lacking for Swing threading; hoping this might be clearer to someone better versed in threads/Java3D. Not sure if this is a known issue.