thread death with marvin sketch

User fa1369adab

06-12-2005 20:56:09

When I close a Firefox window containing an instance of the MarvinSketch applet, I get an error: could not load MolFile for the following reason: java.lang.ThreadDeath (I might have the spelling wrong; this error makes the browser unusable, and I have to kill it.)





I used to get this error occasionally when I reloaded a single frame of a multiframe web page. But now I am getting it all the time.





I am using Marvin4.0.3 (same problem with 4.0.1), Firefox 1.5, Linux 2.6.n.

ChemAxon 7c2d26e5cf

07-12-2005 16:22:48

Can you send us an html example where this problem is reproducable?


A thread dump will be also very useful to debug the thread death problem.


You can generate a thread dump in the Java Console by pressing "v".


By the way, we have fixed a dead lock since Marvin 4.0.3. This bug fix will be available in the next release. Probably, it will solve the problem.

User fa1369adab

07-12-2005 19:31:09

I notice that the cursor in MarvinSketch is the "in progress" symbol (the


stopwatch in Linux), not the ordinary cursor.





It is hard (in general, impossible) to get a stack dump, because the browser becomes completely unresponsive, not even responding to the "show stack trace"


button. I have tested with jdk1.5.0_06, and the problem remains.





Here is HTML.
Code:





















<html>


    <head>


    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">


    <META HTTP-EQUIV="Expires" CONTENT="Mon, 01 Jan 2001 12:00:00 GMT">


   <link rel=stylesheet href="../../includes/epoch.css" type="text/css">


   <title>Preview</title>





   <script src="../js/openwindows.js"></script>


   


      <script src="/nosession/marvin/marvin.js"></script>


   


   <script src="../js/functions.js"></script>


   <script>


   function submitIt(form) {


// REMOVE CHECK FOR VALID STRUCTURE


// There is an incompatibility with some versions of IE


         //var molcheck = document.ans_Applet.getMol("smiles");


         //if (molcheck=="") {


         //     alert('No valid structure drawn');


         //     return;


         //}


         


      var molstruct = document.ans_Applet.getMol("mol");


      // alert(molstruct);


      form.molstruct.value=molstruct;


      form.submit();


   }


   function invokeCallBack() {


      document.ans_Applet.setMol("\n  Marvin  10240510352D\n\n  6  5  0  0  0  0            999 V2000\n   -3.4062    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -2.6918   -0.4125    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.9773    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.2628   -0.4125    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.2628   -1.2375    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.9773    0.8250    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n  1  2  1  0  0  0  0\n  2  3  1  0  0  0  0\n  3  6  2  0  0  0  0\n  3  4  1  0  0  0  0\n  4  5  1  0  0  0  0\nM  END\n");


   }


   function loadMolMySelf() {


      //alert('Applet Loaded');


      setTimeout('invokeCallBack()',500);


   }


   </script>


</head>





<body onload="loadMolMySelf();" class="light" style="margin:0px; margin-top:5px; background-color:#f6f7ed; text-align:center;">


<table style="margin-right:auto; margin-left:auto; width:90%;">


<!--


<tr><td> <b>Preview</b></td>


   <td align="right">


      <form name="dummy">


      <input type="button" value=" Close preview " onclick="self.close()">


      </form>


   </td>


-->





<tr>


   <td style="vertical-align:top;">


      <table style="vertical-align:top;"><tr>


      <td class="boldtext" style="padding-bottom:10px; font-size:14px;">Question</td>


      </tr>


<!-- RBG added regtext style to question statement -->


      <tr><td class="regtext" style="padding-top:10px; padding-left:10px; padding-right:10px; padding-bottom:10px;">


      





         Label the most acidic atom in the following compound with map number 1.  To do so, right-click (Safari and Netscape for Mac users: control- or option-click) on the atom that needs to be labelled (or unlabelled), and choose Map &rarr; M1 (or Off). 





      





             


      </td></tr>





      <tr>


         <td style="vertical-align:top;">


       


      


         <script>


            var mol;


            function showMol_lbsxxdsamehbiop () {


               //mol = molstruct;


               //alert(mol);


               openMolShowWindow('../showmol.jsp?randstr=lbsxxdsamehbiop');


               //openMolShowWindow('showmol.jsp?molstruct='+escape(molstruct));


            }


            function getMol_lbsxxdsamehbiop () {


               return '\n  Marvin  10240510352D\n\n  6  5  0  0  0  0            999 V2000\n   -3.4062    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -2.6918   -0.4125    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.9773    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.2628   -0.4125    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.2628   -1.2375    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.9773    0.8250    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n  1  2  1  0  0  0  0\n  2  3  1  0  0  0  0\n  3  6  2  0  0  0  0\n  3  4  1  0  0  0  0\n  4  5  1  0  0  0  0\nM  END\n';


            }


         </script>


         


            <div class="boldtext" style="white-space:nowrap;">Click image to launch MarvinView&trade;</div>


              <a href="javascript:showMol_lbsxxdsamehbiop()"><img class="whiteTable" src="../tempfiles/hqnppwbvfvoolpp.jpeg" style="width:expression(this.width > 250 ? '250px' : 'inherit'); max-width:250px;" /></a>


      


         


         <P />


       


<!-- RBG changed br to P in preceding line -->


         </td>





      </tr>


      <tr><td class="boldtext">  </td></tr>


       <tr><td class="boldtext">  </td></tr>


      </table>


</td>


<td>


   <table style="margin-left:auto; margin-right:auto; width:445px;">


   <form name="answerform" action="preview.jsp" method="post">


        <input type="hidden" name="molstruct" >





    <tr><td class="boldtext" style="text-align:right; padding-left:10px; padding-right:10px; padding-top:10px; font-style:italic;">


   MarvinSketch&trade;


   </td></tr>


   <tr><td style="text-align:center; padding-left:10px; padding-right:10px;">


       <table class="whiteTable"><tr><td>


      


         <script LANGUAGE="JavaScript1.1">


            <!--


            //marvin_jvm="builtin"; // "builtin" or "plugin"


            //marvin_gui="awt"; // "awt" or "swing"


            msketch_name="ans_Applet";


            //marvin_signed="false";


            msketch_begin("/nosession/marvin", 410, 320);


            // arguments: CODEBASE, WIDTH, HEIGHT


            msketch_param("preload","SmilesExport,MolExport,Parity");


            msketch_param("mol","\n  Marvin  10240510352D\n\n  6  5  0  0  0  0            999 V2000\n   -3.4062    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -2.6918   -0.4125    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.9773    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.2628   -0.4125    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.2628   -1.2375    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n   -1.9773    0.8250    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n  1  2  1  0  0  0  0\n  2  3  1  0  0  0  0\n  3  6  2  0  0  0  0\n  3  4  1  0  0  0  0\n  4  5  1  0  0  0  0\nM  END\n");


            msketch_param("implicitH","heteroterm");


            msketch_param("tmpls0", ":Generic:chemaxon/marvin/templates/generic.t");


            msketch_param("tmpls1", ":Rings:chemaxon/marvin/templates/rings.t");


            msketch_param("tmpls2", ":Polycyclics:chemaxon/marvin/templates/polycyclics.t");


            msketch_param("tmpls3", ":Conformers:chemaxon/marvin/templates/conformers.t");


            msketch_param("atomMappingVisible",


               "true");


            msketch_end();


            //-->


         </script>


      


      </td></tr></table>


</td></tr>





<tr><td>


   <table style="margin-right:auto; margin-left:auto;"><tr>


   <td><div class="boldtext" style="position:relative; cursor:pointer; cursor:hand; width:121px;" onmouseover="changeButtonImg(Submit_Response,'../../images/buttonOver.jpg');" onmouseout="changeButtonImg(Submit_Response,'../../images/buttonOff.jpg');" onmousedown="changeButtonImg(Submit_Response,'../../images/buttonClick.jpg');" onmouseup="changeButtonImg(Submit_Response,'../../images/buttonOver.jpg'); submitIt(document.answerform)"><img id="Submit_Response" src="../../images/buttonOff.jpg"/><div style="position:absolute; left:15px; top:4px;">Submit Response</div></div></td>


   <td><div class="boldtext" style="position:relative; cursor:pointer; cursor:hand; width:121px;" onmouseover="changeButtonImg(Close_Preview,'../../images/buttonOver.jpg');" onmouseout="changeButtonImg(Close_Preview,'../../images/buttonOff.jpg');" onmousedown="changeButtonImg(Close_Preview,'../../images/buttonClick.jpg');" onmouseup="changeButtonImg(Close_Preview,'../../images/buttonOver.jpg'); self.close()"><img id="Close_Preview" src="../../images/buttonOff.jpg"/><div style="position:absolute; left:15px; top:4px;">Close Preview</div></div></td>


   </tr></table>


</td></tr>


</table>


</form>


</td>


</tr></table>


</body>





</html>





ChemAxon 7c2d26e5cf

08-12-2005 15:01:22

I could not run your example because it is not a self-contained html example.


But I have found a strange part in your code:
Quote:
function invokeCallBack() {


document.ans_Applet.setMol("\n Marvin 10240510352D\n\n 6 5 0 0 0 0 999 V2000\n -3.4062 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -2.6918 -0.4125 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.9773 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.2628 -0.4125 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.2628 -1.2375 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.9773 0.8250 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n 1 2 1 0 0 0 0\n 2 3 1 0 0 0 0\n 3 6 2 0 0 0 0\n 3 4 1 0 0 0 0\n 4 5 1 0 0 0 0\nM END\n");


}


function loadMolMySelf() {


//alert('Applet Loaded');


setTimeout('invokeCallBack()',500);


}


</script>


...


<body onload="loadMolMySelf();" ...>
You try to load the molecule too early. The body onload method is called when the html page is loaded. But the applet initalization starts only after that. If the (J)MSketch.setMol()


method had be called from JavaScript before the applet was started, it can lead to a serious error (e.g.: browser crash).


Instead of "body onload", I suggest you the molLoaderFinishedEvent applet parameter. By adding this applet parameter, you can control the finishing of molecule loading into the applet.
Quote:
msketch_param("molLoaderFinishedEvent","js:invokeCallBack()");

User fa1369adab

08-12-2005 16:53:18

Tamas,





Thanks. Your suggestion works fine.





Raphael

User fa1369adab

08-12-2005 18:02:57

Actually, all is not yet perfect.





1. Since I am using
Code:
msketch_param("mol")
, I don't really need to use
Code:
msketch_param("molLoaderFinishedEvent","js:whatever")
to load another Mol structure. I put in that code, but I have commented it out.





2. On Firefox 1.5 (but not 1.0.4), it takes a long time (tens of seconds) for the cursor in a newly loaded MarvinSketch window to become normal; until then, I see the "busy" cursor, which looks like a watch. If I close the pane before the cursor is normal, I suffer a Java thread death. This may be a Java problem, or it may be a Firefox 1.5 problem, or it might be a strange interaction but a Marvin problem. I doubt it is a Java problem; I saw normal behavior (about 2 seconds delay until normal cursor) using the same Java plugin (1.5.0_6), using Firefox 1.0.4.





Raphael

ChemAxon 7c2d26e5cf

09-12-2005 21:08:34

It's a good question.I also use Firefox 1.5 with Java 1.5.0_06. But I had no problem with applet loading. Does this problem occur with a proper molecule or a proper html example?


Have you managed to reproduce this problem with any example from the ChemAxon site?


http://www.chemaxon.com/marvin


http://www.chemaxon.com/jchem/examples.html

User fa1369adab

11-12-2005 02:10:27

One more piece of information: I had a background process trying to run javaws unsuccessfully, just using cpu, during the time I had this problem. When I killed that javaws process, wait time to start MarvinSketch went down to about 3 seconds, which is acceptible. There might be some connection between these two Java instances.

ChemAxon 7c2d26e5cf

12-12-2005 12:22:22

Probably, the launching the Java Web start application slows down your network connection (while the browser is downloading its resources).


If the network connection is slow, the starting of the applet requires more time than in normal case because the browser has to download the applet's resources before starts it.


Furthermore, if Java Web start reserves the most of the capacity of the CPU, the running of other process may slow down.

User fa1369adab

12-12-2005 13:41:05

It was a long-running, broken javaws. My network connection is very high speed. Well, let's consider the problem resolved for now; I'll let you know if the problem returns. Thanks.





Raphael