Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

J. Gutow's update to Jmol in the notebook... #9238

Closed
gutow opened this issue Jun 14, 2010 · 205 comments
Closed

J. Gutow's update to Jmol in the notebook... #9238

gutow opened this issue Jun 14, 2010 · 205 comments

Comments

@gutow
Copy link

gutow commented Jun 14, 2010

NOTE: This ticket has been replaced by #12299

Ready for testing.

For inclusion in new Flask notebook see enhanced Jmol in Flask. Note that all fixes and enhancements to the Jmol interface from SageDays 31 are in the Flask version and not this ticket. The Jmol changes for the Flask notebook should be included in the Flask spkg soon. See #11080.

Setting this up on your own copy of Sage requires two steps. Starting with a clean Sage 4.6.2 (for 4.7+ skip step 1):

  1. Patch for Jmol at the command line (not for 4.7+). See #9232.
  2. Apply the .spkg to get the new Jmol ./sage -f "http://www.uwosh.edu/faculty_staff/gutow/Jmol_for_SageNoteBook-1.1.6.spkg"
  3. Apply the following patches in order (not necessary for Flask): attachment: trac_9238_interactive_js.patch, attachment: trac_9238-add-help.patch , attachment: trac_9238_jmol_lib_async.patch, attachment: trac_9238_memory_IE.patch and attachment: trac_9238_nice_IE_warnings.patch. These are best applied using the hg_sagenb.apply(...) command within sage.
  4. Apply the patch (not necessary for 4.7+) attachment: Trac_9238_script_extension.patch using the hg_sage.apply(...) command within sage. Exit sage and run a ./sage -b.

I have addressed the following issues (let me know if I've missed anything):

  • Addition of the ability to hide the "advanced controls".
  • Fix so that the advanced controls are hidden when the applet is asleep (no accidental calls to nonexistent applets).
  • Fix to issue of not properly loading all applets when a worksheet with a lot of applets is reopened (please check this one carefully).
  • Fixes to vocabulary and labels to make things clearer.
  • Hidden the div with the State in it. (Still there b/c I hope to be able to recreate the way the user left it on close, rather than starting fresh each time.)
  • Fix to loading pages with many Jmols hanging. (FF on MacOS just doesn't work reliably or reproducibly so I put up a warning and suggest they switch to Chrome).
  • Workaround for bug in MacOS Safari that causes hang when trying to get a static image to sleep an applet if more than 9 applets in a worksheet (I believe this is a memory leak problem).
  • Tested extensively on Linux with FF and Chromium and on MacOS with Safari, Chrome and FF. Works well with both linux browsers and with Chrome on MacOS. MacOS/Safari is usable, MacOS FF is not.
  • Lowered memory requirements for Jmol. This improves performance in Safari for many applets.
  • Many advanced controls do not work with IE/win. Provide warning and suggest using Chrome, which does work. Those that fail do so quietly. Sleeping and controlling function color do work.

Happy testing and thank you to those who do test!

Note: This ticket has been replaced by #12299.

CC: @TimDumol @kcrisman @rkirov

Component: notebook

Keywords: sd31, sd32

Reviewer: Jason Grout, Karl-Dieter Crisman, William Stein, Jonathan Gutow

Issue created by migration from https://trac.sagemath.org/ticket/9238

@gutow
Copy link
Author

gutow commented Jun 14, 2010

Attachment: Jmol javascript updates.zip

jmol notebook javascript updates

@jasongrout
Copy link
Member

comment:1

Did you update the version of jmol in Sage as well?

@gutow
Copy link
Author

gutow commented Jun 14, 2010

comment:2

Replying to @jasongrout:

Did you update the version of jmol in Sage as well?

Jason,

Thanks!!! I forgot about that. Yes, for all of this to work you need to use Jmol 11.8. The latest release. Should I add a .zip of the necessary applet files to the trac?

Jonathan

@gutow

This comment has been minimized.

@jasongrout
Copy link
Member

comment:4

We should make a new spkg. Is that what you did? If not, then I can try to update the spkg to include the newest jmol if it's just a drop-in replacement for the old java files.

@jasongrout
Copy link
Member

comment:5

On the other hand, I didn't realize that jmol was just included in the sagenb spkg, so it'll probably be easier to update. I'm CCing Tim, who has done some of the recent sagenb releases.

Yes, can you attach the updated jmol files as well, then (or if they're more than a megabyte or so, can you post a link to them?)

Thanks for all of this work!

Jason

@gutow
Copy link
Author

gutow commented Jun 14, 2010

comment:6

OK, I've posted a .zip archive with all the necessary Jmol stuff. The link is now included in the trac ticket. Sorry I forgot about that.

Jonathan

@gutow

This comment has been minimized.

@jasongrout
Copy link
Member

comment:7

That zip file has a lot of __MACOSX and .DS_Store files...

@gutow
Copy link
Author

gutow commented Jun 14, 2010

comment:8

Replying to @jasongrout:

That zip file has a lot of __MACOSX and .DS_Store files...

Oops...It will still work, but I will clean it up and post an update later today. People can try it with this, but look for a clean file tomorrow.

Jonathan

@jasongrout
Copy link
Member

comment:9

If you replace the existing jmol directory with the above zip, then you delete the "jmol" file inside that directory, which is necessary for the spkg to work. The jmol file is:

#!/bin/sh
#JMOL_HOME=`dirname "$0"`
JMOL_HOME="`"$SAGE_LOCAL"/bin/sage-pypkg-location sagenb`""/sagenb/data/jmol"

# Collect -D & -m options as java arguments
command=java
while [ `echo $1 | egrep '^-D|^-m' | wc -l` != 0 ]; do
        command="$command $1"
        shift
done

if [ -f ./Jmol.jar ] ; then
  jarpath=./Jmol.jar
elif [ -f $JMOL_HOME/Jmol.jar ] ; then
  jarpath=$JMOL_HOME/Jmol.jar
elif [ -f /usr/share/jmol/Jmol.jar ] ; then
  jarpath=/usr/share/jmol/Jmol.jar
else
  echo Jmol.jar not found
  exit
fi
$command -Xmx512m -jar $jarpath $@


Is that file still needed? I think it probably makes jmol work from the command line for us.

@gutow
Copy link
Author

gutow commented Jun 14, 2010

comment:10

Hmmm...good eye! I think you are correct. I have never used Jmol from the command line. It does look like the application is used. I can certainly include that in the package as well as the shell script. I thought that was the old Jmol linux shell script...I didn't even look inside....My bad. When I clean things up I will get the necessary files for command line back in there. I will do that this evening. Let me know if you notice anything else.

Jonathan
Replying to @jasongrout:

If you replace the existing jmol directory with the above zip, then you delete the "jmol" file inside that directory, which is necessary for the spkg to work. The jmol file is:

#!/bin/sh
#JMOL_HOME=`dirname "$0"`
JMOL_HOME="`"$SAGE_LOCAL"/bin/sage-pypkg-location sagenb`""/sagenb/data/jmol"

# Collect -D & -m options as java arguments
command=java
while [ `echo $1 | egrep '^-D|^-m' | wc -l` != 0 ]; do
        command="$command $1"
        shift
done

if [ -f ./Jmol.jar ] ; then
  jarpath=./Jmol.jar
elif [ -f $JMOL_HOME/Jmol.jar ] ; then
  jarpath=$JMOL_HOME/Jmol.jar
elif [ -f /usr/share/jmol/Jmol.jar ] ; then
  jarpath=/usr/share/jmol/Jmol.jar
else
  echo Jmol.jar not found
  exit
fi
$command -Xmx512m -jar $jarpath $@


Is that file still needed? I think it probably makes jmol work from the command line for us.

@jasongrout
Copy link
Member

comment:11

I've make a new sagenb-0.8.p3.spkg file that includes Jonathan's changes above (as an applied mercurial patch), plus the new jmol. So to test this, all a person should have to do is:

sage -f http://sage.math.washington.edu/home/jason/sagenb-0.8.p3.spkg

It seems to work pretty well for me. I wish the default was Medium Size instead of "small"

@gutow
Copy link
Author

gutow commented Jun 14, 2010

comment:12

Let's take some votes on the default size. The problem with medium is that some people are still using screens as small as 800 x 600. A 400 x 400 applet is likely to use more screen space than the user has allotted to the browser. Maybe we should add a place where the user can set the default Jmol size in their notebook preferences? At present it is just a variable set when jmol_lib.js is loaded. We could certainly set it somewhere else in the web page.

Jonathan
Replying to @jasongrout:

It seems to work pretty well for me. I wish the default was Medium Size instead of "small"

@jasongrout
Copy link
Member

comment:13

Replying to @gutow:

Let's take some votes on the default size.

I agree.

@gutow
Copy link
Author

gutow commented Jun 14, 2010

comment:14

The link to jmol.zip now leads to a clean zip archive (no .DS_Store files), with the jmol file (shell script) and the Jmol.jar application file.

Jason, I also wonder about your spkg name. Wasn't the .py2.6 indicative of the python version?

Jonathan

@jasongrout
Copy link
Member

comment:15

Where is there a missing .py2.6? I don't think I deleted anything with that name.

It's possible that whatever you are seeing happens at install time, rather in the source of the spkg, but I'm not sure what file you're talking about.

@gutow
Copy link
Author

gutow commented Jun 14, 2010

comment:16

I'm talking about this:
sagenb-0.8.p3.spkg
^^
In the download of sage 4.4.3 that I was looking at the notebook is included as an .egg in the directory structure. I think I am confused by the .egg name versus the naming of the .spkg. The .egg name is:

sagenb-0.8-py2.6.egg
^^^
Since I've never built an egg or an spkg, I'm not sure of the significance.

Jonathan

Replying to @jasongrout:

Where is there a missing .py2.6? I don't think I deleted anything with that name.

It's possible that whatever you are seeing happens at install time, rather in the source of the spkg, but I'm not sure what file you're talking about.

@jasongrout
Copy link
Member

comment:17

Ah. What I did is create a new spkg, like in sage/spkg/standard/sagenb-0.8.p2.spkg. When it installs into the python directory (using the "sage -f" command), the py2.6 egg stuff will be taken care of.

@gutow
Copy link
Author

gutow commented Jun 14, 2010

comment:18

Jason,

Once you've incorporated the new jmol.zip file, I suggest you update the description to include instructions on using your .spkg to test right near the top. Or are your and I the only two who are going to look at this?

Jonathan

@kcrisman
Copy link
Member

comment:19

No, you won't - pesky "someone else has already edited this page"!!!

Jonathan,

Sweet. Great work!

Some comments upon a very small amount of testing (which is all I have time for right now). I apologize for their telegraphic nature.

Popup 3dviewer is great.

Functions tab did not immediately have something in it, I had to click "request...", which is nonintuitive. I understand if that step is necessary, but the message could be better; as it is, the person using it wouldn't necessarily realize that this would give mesh etc. info for each object (nice to do it separately, so so so nice).

Colorpicker in Functions tab: awesome.

Initial size Small might be good for iPhone (if Jmol even works there?) but is a little on the small side for normal laptop/PC web browsing. Can the browsing thing be detected for this?

There is an awful lot of space given to the info, not so much to the actual graphic. Would it be possible to put that stuff below the image as opposed to on the right? In fact, that stuff should not necessarily resize with the graphic...

State is cool for those of us who might want to access it, but it should default (when clicked upon) to creating a slider or something, or "click here for full" or something like that. Otherwise the potential for really upsetting work flow is there, it changes the window size so much.

Sleep/Wake works great, might be nice to CSS those words into something less \texttt{}-ish. Note that "Arbitrarily resizable in own window Get static image to save" looks like one command; maybe some

    useful here?

    Didn't break any old worksheets, though they all have this new little Jmol double window now, which makes sense.

    This may be unrelated, but the axes seem to be in the wrong spots, at least in

    var('y')
    P=plot3d(x^2+y^2,(x,-3,3),(y,-3,3))
    Q=plot3d(sin(x^2+y^2),(x,-3,3),(y,-3,3))
    show(P+Q)
    

    I did not get to test having billions of applets open at the same time, unfortunately, but will be happy to do so if no one else can over the next week or two.

    One really interesting thing is this. We had complaints about the snappiness of 3D interacts recently, but now I get almost instantaneous recomputation with 'small', which is great. However

    TypeError: Result of expression '(stateStr.match(re_modelinline))' [null] is not an object.
    

    occurs if I change the size in an interact, and then move the slider. Obviously, other things don't stay the same with an interact - say if I change one function to green, it goes back to blue after moving the slider, but there shouldn't be the error message (ideally).

    But thank you! This would be a big improvement. Looking forward to being able to evaluate it properly - clearly a big change needs big testing.

    @jasongrout

    This comment has been minimized.

    @jasongrout

    This comment has been minimized.

    @gutow
    Copy link
    Author

    gutow commented Jun 14, 2010

    comment:22

    Replying to @kcrisman:

    Sweet. Great work!

    Glad you like it.

    Some comments upon a very small amount of testing (which is all I have time for right now). I apologize for their telegraphic nature.

    Popup 3dviewer is great.

    Functions tab did not immediately have something in it, I had to click "request...", which is nonintuitive. I understand if that step is necessary, but the message could be better; as it is, the person using it wouldn't necessarily realize that this would give mesh etc. info for each object (nice to do it separately, so so so nice).

    You are correct that I could not originally get the information from Jmol on load because of timing issues. I have an idea about this and will work on it a little. In the meantime, I think you are correct that we need better instructions in this tab.

    Colorpicker in Functions tab: awesome.

    We use it for other Jmol stuff, but it was originally inspired by the needs of SAGE.

    Initial size Small might be good for iPhone (if Jmol even works there?) but is a little on the small side for normal laptop/PC web browsing. Can the browsing thing be detected for this?

    I believe we can get the surrounding window size. I will look into that. Maybe it should default to no more than 405 of width or height, whichever is higher?

    There is an awful lot of space given to the info, not so much to the actual graphic. Would it be possible to put that stuff below the image as opposed to on the right? In fact, that stuff should not necessarily resize with the graphic...

    I can play with the table formatting a little. I don't see any problems off the top of my head with it not resizing. I think underneath is a problem as the applet can be big enough that the controls will be off screen.

    State is cool for those of us who might want to access it, but it should default (when clicked upon) to creating a slider or something, or "click here for full" or something like that. Otherwise the potential for really upsetting work flow is there, it changes the window size so much.

    Eventually I want it hidden. But I think I can set it up to be scrolling....

    Sleep/Wake works great, might be nice to CSS those words into something less \texttt{}-ish. Note that "Arbitrarily resizable in own window Get static image to save" looks like one command; maybe some

      useful here?

      These are formatting issues that I can deal with easily.

      Didn't break any old worksheets, though they all have this new little Jmol double window now, which makes sense.

      Good!

      This may be unrelated, but the axes seem to be in the wrong spots, at least in

      var('y')
      P=plot3d(x^2+y^2,(x,-3,3),(y,-3,3))
      Q=plot3d(sin(x^2+y^2),(x,-3,3),(y,-3,3))
      show(P+Q)
      

      That is likely to be a SAGE python bug as Jmol just draws lines where SAGE tells it to. I will double check the parsing, but since the axes look correct for everything I've tried, I'm guessing something funny is passed to Jmol.

      I did not get to test having billions of applets open at the same time, unfortunately, but will be happy to do so if no one else can over the next week or two.

      One really interesting thing is this. We had complaints about the snappiness of 3D interacts recently, but now I get almost instantaneous recomputation with 'small', which is great.

      This is because I switched to using the incrementally loaded applet. Thus only the parts needed are loaded. This significantly reduces load time.

      However

      TypeError: Result of expression '(stateStr.match(re_modelinline))' [null] is not an object.
      

      occurs if I change the size in an interact, and then move the slider. Obviously, other things don't stay the same with an interact - say if I change one function to green, it goes back to blue after moving the slider, but there shouldn't be the error message (ideally).

      Is that completely reproducible? I've seen it occasionally when javascript gets executed before the applets are completely loaded. However, I've never seen any ill effects since things get reset later. If it causes problems and you can pin it down, let me know.

      Thanks for the initial testing.

      Jonathan

      @gutow

      This comment has been minimized.

      @kcrisman
      Copy link
      Member

      comment:165

      Sorry to be dense, but what is the relation between this and #11503? (I mean does one depend on the other?)

      @gutow
      Copy link
      Author

      gutow commented Aug 19, 2011

      comment:166

      I don't think that's dense.  It is confusing.  This ticket reflects the development before the Flask notebook.  As I was told we were switching over to Flask ASAP, I stopped working on things in the old version of the notebook.  However, I think this ticket belongs for people who want to incorporate an updated Jmol into pre-Flask versions of Sage.  Plus, I think it is good to lead people to the Flask version.

      The .spkgs here would not install Jmol properly for setups that have made modifications as per #11503.  Should we say something about that?

      Replying to @kcrisman:

      Sorry to be dense, but what is the relation between this and #11503? (I mean does one depend on the other?)

      @kcrisman
      Copy link
      Member

      comment:167

      Well, in the meantime we aren't switching to Flask asap, so I might actually have time to test this over the next week or two and finally get it in. Or are we just going to say we won't update Jmol and your nice changes until then?

      I think that having instructions (for instance, that #11503 can be done after this, but not the other way around) would be appropriate...

      @gutow
      Copy link
      Author

      gutow commented Aug 19, 2011

      comment:168

      In about 1.5 weeks I'll have time to look at this again.  I should be able to put together an spkg and the appropriate patches to make everything work without moving to Flask.  As we are ramping up for the semester, I don't think I will get to it before then.  Can we sit tight until then?  We've already missed 4.7.1 haven't we?

      @gutow

      This comment has been minimized.

      @jasongrout
      Copy link
      Member

      comment:170

      I talked with Rado the other day, and it seems like he's making a big push to get a lot of new stuff in and the bugs worked out while he has time before October. My guess is that we'll see the flask notebook stabilize in mid- to late-September.

      @williamstein
      Copy link
      Contributor

      Changed keywords from sd31 to sd31, sd32

      @strogdon
      Copy link

      strogdon commented Sep 4, 2011

      comment:172

      I've tested some of the features of this ticket on vanilla sage-4.7.2.alpha2 and I have some questions. I installed Jmol_for_SageNoteBook-1.1.6.spkg and applied the patches

      trac_9238_interactive_js.patch
      trac_9238-add-help.patch
      trac_9238_jmol_lib_async.patch
      

      The add-help patch would not apply with the response that a JmolHelp.html file already existed. I did not attempt to apply the IE patches. After applying the patches I issued "sage -b" and started sage and the notebook. Now when I load a worksheet that has Jmol applets I get pop-ups. If there are numerous applets, I get numerous pop-ups. These pop-ups seem to be triggered by the follow alerts in trac_9238_jmol_lib_async.patch

      +    if(loading>=0){//we found a loading applet
      +        jmolStatus.attempts[loading]+=1; //update number of checks for load completion.
      +        if(jmolStatus.defaultdirectory[loading]=="done"){//Applet is ready.
      +            jmolAppletLive(loading);
      +            }else{ //Applet not ready. How many checks have we done?
      +            if(jmolStatus.attempts[loading]==10){
      +                alert("Jmol Applet #"+loading+" is having trouble loading.  Will retry once.");
      +                var scriptStr = 'x=defaultdirectory; data "directory @x";';
      +                scriptStr += 'set MessageCallback "jmolMessageHandler"; show defaultdirectory;';
      +                jmolScript(scriptStr);
      +                }
      +            if(jmolStatus.attempts[loading]==20){
      +                alert("Second attempt to finish launch of Jmol Applet #"+loading+" failed.  Recommend reevaluating the cell manually.");
      +                jmolStatus.jmolArray[loading]=-2; //launch failed.
      +                }
      +            }
      +        }else{//no loading applets. Search for queued applet.
      

      since the quoted expressions in the alerts appear in the pop-ups. Loading the applets is extremely slow and the pop-ups have to be "clicked" before loading continues. Now if I do not install trac_9238_jmol_lib_async.patch then I do not get the pop-ups and the loading of the applets is much faster. I have used Firefox 3 and Firefox 6 with the same result. Are the pop-ups a feature or is the jmol_lib_async only intended for safari browsers?

      @gutow
      Copy link
      Author

      gutow commented Sep 6, 2011

      comment:173

      First, take note of the first paragraph of this ticket.  Because this involves working with the notebook interface all development since June 2011 has been on the Flask notebook version.  That means the package and patches here have not been updated since about 4.7.1.  They are up primarily so that people using 4.7.1 and older can get the controls that allow changing the display of surfaces.  Development has been limited to the Flask version of the notebook.  I have very limited time to work on this (I'm a chemistry professor), but if the Flask notebook is going to be severely delayed could try to package a version to work with the older notebook.  If you really want to test this you should test it in a Flask install (see the appropriate tickets).

      That said your concerns about the patch warnings are valid.  I did not know that any of it had been folded into 4.7.2.  This is odd.

      The pop-up warnings are because your server connection is relatively slow.  The notebook now allows about 15 seconds for an applet to load.  If it hasn't loaded by that time, one of these warnings pops up.  The idea is to provide some feedback when it takes a long time to load.  The reason for the async load code is that worksheets with lots of applets in them can overwhelm the browsers if too many applets try to load simultaneously.  This code requires them to load sequentially and limits worksheets to 4 running Jmol applets at a time.  Those that are not running are replaced with a picture and a button to wake them.  The primary reason for this is constraints on the memory available for applets within browsers.  The async code is for all browsers.  There are warnings associated with specific browsers that we have had difficulty with (e.g. MS IE and certain versions of FF and Safari).

      If your worksheets worked without the async code, that suggests you were: 1) lucky; 2) had only one or very few applets in your worksheet.  If your worksheet did not work at all with the async code could you package it up so that we could test it in the latest code? Thanks.

      Does this answer your questions?  I think the key message is that without more work on my part the enhanced Jmol interface may be tied to the Flask notebook.

      Replying to @strogdon:

      I've tested some of the features of this ticket on vanilla sage-4.7.2.alpha2 and I have some questions. I installed Jmol_for_SageNoteBook-1.1.6.spkg and applied the patches trac_9238_interactive_js.patch trac_9238-add-help.patch trac_9238_jmol_lib_async.patch The add-help patch would not apply with the response that a JmolHelp.html file already existed. I did not attempt to apply the IE patches. After applying the patches I issued "sage -b" and started sage and the notebook. Now when I load a worksheet that has Jmol applets I get pop-ups. If there are numerous applets, I get numerous pop-ups. These pop-ups seem to be triggered by the follow alerts in trac_9238_jmol_lib_async.patch + if(loading>=0){//we found a loading applet + jmolStatus.attempts[loading]+=1; *update number of checks for load completion. + if(jmolStatus.defaultdirectory[loading]=="done"){*Applet is ready. + jmolAppletLive(loading); + }else{ *Applet not ready. How many checks have we done? + if(jmolStatus.attempts[loading]==10){ + alert("Jmol Applet #"+loading+" is having trouble loading. Will retry once."); + var scriptStr = 'x=defaultdirectory; data "directory @x";'; + scriptStr += 'set MessageCallback "jmolMessageHandler"; show defaultdirectory;'; + jmolScript(scriptStr); + } + if(jmolStatus.attempts[loading]==20){ + alert("Second attempt to finish launch of Jmol Applet #"+loading+" failed. Recommend reevaluating the cell manually."); + jmolStatus.jmolArray[loading]=-2; *launch failed. + } + } + }else{//no loading applets. Search for queued applet. since the quoted expressions in the alerts appear in the pop-ups. Loading the applets is extremely slow and the pop-ups have to be "clicked" before loading continues. Now if I do not install trac_9238_jmol_lib_async.patch then I do not get the pop-ups and the loading of the applets is much faster. I have used Firefox 3 and Firefox 6 with the same result. Are the pop-ups a feature or is the jmol_lib_async only intended for safari browsers?

      @strogdon
      Copy link

      strogdon commented Sep 7, 2011

      comment:174

      Replying to @gutow:

      First, take note of the first paragraph of this ticket. Because this involves working with the notebook interface all development since June 2011 has been on the Flask notebook version. That means the package and patches here have not been updated since about 4.7.1. They are up primarily so that people using 4.7.1 and older can get the controls that allow changing the display of surfaces. Development has been limited to the Flask version of the notebook. I have very limited time to work on this (I'm a chemistry professor), but if the Flask notebook is going to be severely delayed could try to package a version to work with the older notebook.

      No problem relative to time since things are rather busy here now too.

      If you really want to test this you should test it in a Flask install (see the appropriate tickets). That said your concerns about the patch warnings are valid. I did not know that any of it had been folded into 4.7.2. This is odd. The pop-up warnings are because your server connection is relatively slow.

      I believe the server (desktop) is fast enough. The pop-ups seem to be associated with an inability to put certain applets in a sleep state. This code

      x,y=var('x y'); plot3d( 4*x*exp(-x^2-y^2), (x,-2,2), (y,-2,2) )
      

      generates an applet that can be put in a sleep state. If I replicate the code, say ten times, in a worksheet then I have no problem loading the saved worksheet with and without the async patch. I get four active applets and six that are sleeping. However, things are faster without the patch. The following code

      x, y = var('x y');W = plot3d(sin(pi*((x)^2+(y)^2))/2,(x,-1,1),(y,-1,1), frame=False,color='purple', opacity=0.8);S = sphere((0,0,0),size=0.3, color='red', aspect_ratio=[1,1,1]);show(W + S, figsize=8)
      

      generates an applet that cannot put in a sleep state, at least here it can't. The 'frame=False' option seems to be controlling the inability to do this. I get pop-ups with just one applet in a worksheet, even though the applet appears to have loaded within a second or two. Of course there are no pop-ups without the async patch. If I replicate the code, say six times, in a worksheet then loading the worksheet is extremely tedious with the async patch since for each applet I eventually get two pop-ups. As I mentioned, I don't believe the desktop is slow. Without the patch the applets load immediately, particularly when 'Action -> Evaluate All' is used; but only four or so of them can be re-evaluated if done individually. Then, I get a pop-up with

      TypeError: stateStr.match(re_modelinline) is null
      

      The notebook now allows about 15 seconds for an applet to load. If it hasn't loaded by that time, one of these warnings pops up. The idea is to provide some feedback when it takes a long time to load. The reason for the async load code is that worksheets with lots of applets in them can overwhelm the browsers if too many applets try to load simultaneously. This code requires them to load sequentially and limits worksheets to 4 running Jmol applets at a time. Those that are not running are replaced with a picture and a button to wake them. The primary reason for this is constraints on the memory available for applets within browsers. The async code is for all browsers. There are warnings associated with specific browsers that we have had difficulty with (e.g. MS IE and certain versions of FF and Safari). If your worksheets worked without the async code, that suggests you were: 1) lucky; 2) had only one or very few applets in your worksheet.

      Lucky, perhaps but I certainly have more than a few applets. I can't see where the second chunk of code would be associated with slowness. Perhaps the 'frame=False' option is triggering something it shouldn't?

      If your worksheet did not work at all with the async code could you package it up so that we could test it in the latest code? Thanks.

      I would be nice to know if the same behavior is present in the flask-notebook. I could do this but it would take some time. Hopefully, the code I've provided can be easily tested by someone that has the flask stuff in place.

      Does this answer your questions? I think the key message is that without more work on my part the enhanced Jmol interface may be tied to the Flask notebook.

      Thanks for your feedback. It has caused me to look more carefully at what I've been doing. FWIW, the jmol issue surfaced in using the sage-on-gentoo port of Sage. There jmol has been outside the notebook for some time. But only recently, with jmol-12.0.45 and the patches of this ticket, have things started to act up. There is, not yet, a flask-notebook in sage-on-gentoo. And I'm guessing it won't be in sage-on-gentoo until it appears in Sage first. Therefore my ramblings here have been an attempt to determine whether vanilla Sage with the present notebook has the same issues as I have with sage-on-gentoo. It seems it does.

      @gutow
      Copy link
      Author

      gutow commented Sep 7, 2011

      comment:175

      Replying to @strogdon:

      Thanks for the code snippets.  I have run them through a system with most of our latest patches in the flask version.  They do not seem to be problematic.  I had no trouble with a worksheet using your second (no-frame) example with 12 duplicates in a worksheet.  It does take a while to work its way back to the top from the 12th applet (about 25 seconds using my slow home connection).  This was a relatively severe test as the whole connection is encrypted as well, which slows things down further.  I did get a warning pop-up while the system was waiting for me to OK trusting the applet over the encrypted connection when I evaluated the first cell.  Once this was done things worked rapidly each time I evaluated an additional cell, because the applet was cached.

      Does that sound like I checked everything?

      Based on this test, I think I need to try to create a version of the patches that match the latest changes incorporated into the flask notebook, but can be applied to 4.7.2. I may have time this weekend.

      @gutow
      Copy link
      Author

      gutow commented Sep 7, 2011

      comment:176

      Replying to @strogdon:

      I just found something.  Is this what you are describing?  I don't see it all the time, but I did manage to make it happen once, so should be able to trace it.  

      1. Make a worksheet with lots of cells that evaluate to produce a jmol plot.

      2. Do either of the following:

          a) select "delete all output", then select "evaluate all"

          b) select "evaluate all" without first deleting the output

      1. What I see sometimes is that one of the applets does not load and then many of the cells do not evaluate to a jmol applet.  They can be recovered by manually clicking the evaluate button.

      @strogdon
      Copy link

      strogdon commented Sep 8, 2011

      comment:177

      Replying to @gutow:

      Replying to @strogdon: Thanks for the code snippets. I have run them through a system with most of our latest patches in the flask version. They do not seem to be problematic. I had no trouble with a worksheet using your second (no-frame) example with 12 duplicates in a worksheet. It does take a while to work its way back to the top from the 12th applet (about 25 seconds using my slow home connection). This was a relatively severe test as the whole connection is encrypted as well, which slows things down further. I did get a warning pop-up while the system was waiting for me to OK trusting the applet over the encrypted connection when I evaluated the first cell. Once this was done things worked rapidly each time I evaluated an additional cell, because the applet was cached. Does that sound like I checked everything?

      This sounds good. If you get 12 applets to load in 25 seconds with the (no-frame) option then the flask implementation is definitely an improvement. With the async patch I'm able to load 12 applets, with frames, over nfs in about 40 seconds. I get one sequence of pop-ups after everything has loaded relative to trouble loading jmol Applet #0. However, with the (no-frame) option I get a sequence of pop-ups for each loading Applet. 

      The odd behavior with "TypeError" in a pop-up seems to occur only if the async patch isn't applied. With the async patch and with frames doing either of

      a) select "delete all output", then select "evaluate all" 
      b) select "evaluate all" without first deleting the output

      gives the above behavior of one sequence of pop-ups relative to loading jmol Applet #0. For the several times I've tried, all Applets do load.

      @gutow

      This comment has been minimized.

      @kcrisman
      Copy link
      Member

      kcrisman commented Jun 2, 2012

      comment:179

      Hi Jonathan,

      I've managed to get the Flask notebook installed in one of my development Sage installs, apparently, and it's summer, so I'd like to review #12299 so that it's ready to go in with the new notebook (likely in Sage 5.2, says jdemeyer). Can you go through all the things here and maybe pick out any obvious things that should be hyper-tested, and put them on #12299? I can't be sure, but reading through the comments it seems like most of the issues (including the command-line and Safari issues) were already resolved before this ticket became superseded by the new one?

      @gutow
      Copy link
      Author

      gutow commented Jun 4, 2012

      comment:180

      I think everything that was discussed above has been resolved. The issues that are left are to get some tests from people other than me to find what else I've missed. I've been running these modifications on the server I use for classes since last year, so I'm cautiously optimistic. For all practical purposes, I think this ticket is closed and completely superseded by #12299.

      @kcrisman
      Copy link
      Member

      kcrisman commented Jun 4, 2012

      Changed author from Jonathan Gutow to none

      @kcrisman
      Copy link
      Member

      kcrisman commented Jun 4, 2012

      comment:181

      Okay, that sounds good.

      @kcrisman
      Copy link
      Member

      kcrisman commented Jun 4, 2012

      Changed reviewer from Jason Grout, Karl-Dieter Crisman, William Stein to Jason Grout, Karl-Dieter Crisman, William Stein, Jonathan Gutow

      Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
      Projects
      None yet
      Development

      No branches or pull requests

      6 participants