sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.44k stars 480 forks source link

Upgrade Jmol to 12.3.27, Advance Jmol Interactive Features in Flask Notebook #12299

Closed gutow closed 12 years ago

gutow commented 12 years ago

This ticket provides the following advanced interactive features to Jmol in the notebook:

  1. Initial display is a static image created by Jmol (if a javaVM is available on the server) or Tachyon. This means all browsers and devices will at least be able to see a 3-D image.
  2. The live applet can be loaded by clicking on a "Make Interactive..." button.
  3. Colors can be changed without recalculating
  4. spin on checkbox
  5. high quality checkbox
  6. Meshes can be displayed without recalculating (no sparkles either :))
  7. Transparency can be adjusted without recalculating
  8. Applet size can be adjusted
  9. Applet can be displayed in its own window
  10. Can download a file that the Jmol application can open to recreate the exact view shown on the web page. This allows for more sophisticated manipulation and the semi-automatic creation of web pages that include this live 3-D image.
  11. Solves memory problems associated with opening too many Jmols at once, by automatically putting Jmols that are not being used to sleep.

Explicit Installation Instructions for <=sage-5.1:

  1. Install the flask notebook by following the instructions at #11080.
  2. Then do the following to apply the patches and install an updated version of Jmol.
./sage --hg -R devel/sage qimport -P https://github.com/sagemath/sage-prod/files/10654503/trac_12299-all-in-one.patch.gz
./sage --hg -R devel/sage qimport -P https://github.com/sagemath/sage-prod/files/10654504/trac_12299_headless_java.patch.gz
./sage --hg -R devel/sage qimport -P https://github.com/sagemath/sage-prod/files/10654505/trac-12299_java_doctest_opt.patch.gz

./sage --hg -R devel/sagenb qimport -P https://github.com/sagemath/sage-prod/files/10654494/trac_12299_adv_jmol_nb.patch.gz
./sage --hg -R devel/sagenb qimport -P https://github.com/sagemath/sage-prod/files/10654495/trac_12299_old_wksht.patch.gz
./sage --hg -R devel/sagenb qimport -P https://github.com/sagemath/sage-prod/files/10654497/trac_12299_server_sync_and_UI.2.patch.gz

./sage -f  "http://www.uwosh.edu/faculty_staff/gutow/jmol-12.3.27.p2.spkg"

./sage -b

Explicit Installation Instructions for >sage-5.1:

  1. Install sagenb 0.10.x by following the instructions at #13121 - those instructions include everything necessary to test this ticket.

Notes:

If you are doing this in a different way you need to:

Depends on #11080 Depends on #11078 Depends on #11503 Depends on #13121

Upstream: Fixed upstream, in a later stable release.

CC: @novoselt @strogdon @ppurka @kini

Component: notebook

Keywords: Jmol, 3D, notebook

Author: Jonathan Gutow

Reviewer: Karl-Dieter Crisman, Steven Trogdon, Punarbasu Purkayastha, John Palmieri, Dan Drake

Merged: sage-5.4.beta0

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

gutow commented 12 years ago

Description changed:

--- 
+++ 
@@ -17,3 +17,5 @@
 A patch to plot3d in Sage:

 A patch to a number of files in sagenb:
+
+This ticket includes all the changes in !#9238.
gutow commented 12 years ago

Description changed:

--- 
+++ 
@@ -18,4 +18,4 @@

 A patch to a number of files in sagenb:

-This ticket includes all the changes in !#9238.
+This ticket includes all the changes in #9238.
gutow commented 12 years ago

Description changed:

--- 
+++ 
@@ -14,8 +14,8 @@

 Two patches are necessary:

-A patch to plot3d in Sage:
+A patch to plot3d in Sage: [attachment: trac_12299_plot_3D_static_img.patch](https://github.com/sagemath/sage-prod/files/10654493/trac_12299_plot_3D_static_img.patch.gz)

-A patch to a number of files in sagenb:
+A patch to a number of files in sagenb: [attachment: trac_12299_adv_jmol_nb.patch](https://github.com/sagemath/sage-prod/files/10654494/trac_12299_adv_jmol_nb.patch.gz)

-This ticket includes all the changes in #9238.
+These patches include all the changes in #9238 plus.
gutow commented 12 years ago
comment:3

The second patch is very big, but I think it is best to do it as a patch to make sure that I haven't somehow rebased against the wrong versions of the files.

gutow commented 12 years ago
comment:6

Rebasing the patches to 5.0.beta6 and fixing issue of p0 versus p1 level patches.

strogdon commented 12 years ago
comment:7

I've tried these patches on top 5.0.beta6 and #11080. I believe the patch to jmol_lib.js in trac_12299_adv_jmol_nb.patch appears twice. If I delete the first occurrence everything applies and the png images generated by Tachyon appear in the notebook. If I click the "Make Interactive" button then the 3-D jmol images appear. I noticed that the first image to always appear, even if a cell is reevaluated, is the png generated image. "Make Interactive" must be clicked to get the jmol image. If a jmol image is present in a cell, reevaluating that cell will display a png image. "Make Interactive" must be clicked again to recover the jmol image. If after clicking "Download this view" from the "Advanced Controls" and saving the jmol image there then appears in the lower right corner of the applet a "Jmol_S" the wasn't present initially. When clicked this gives a jmol menu. I believe this is part of jmol. I've seen it on sage-on-gentoo where jmol-12.0.45 is used. I'm not sure why it suddenly appears after the indicated action. This all looks very interesting.

gutow commented 12 years ago
comment:8

Replying to @strogdon: You are correct about the error in the adv_jmol_nb.patch. I have manually deleted the extra patch to jmol_lib.js and uploaded a correct version. I've been having trouble patching on top of #11080 patches. I believe I ran afoul of unfinished queues. Anyway, I think this correction is the last fix related to that.

Comments:

1) The red "Jmol_S" logo in the bottom right corner indicates that the signed applet has been loaded and has access to the user's directory tree. I believe I can turn it off, but think it is a bad idea. I want to be reminded that I am using an applet that can send stuff from my disk to the server. The menu is the same as the right-click menu that is always available with Jmol.

2) If we want to have an image as the default so that all devices will see something, users will have to deal with requesting it become interactive each time the cell is recalculated. The notebook+sage presently insists on reloading Jmol each time a recalculation is done. In order to do this properly we would need to have a separate div in the notebook for applets and not kill the applet unless it is not being used. Then Jmol would not revert to the starting over state each time a recalculation is done. I think that is another ticket for after these changes go in.

3) Would reloading with a static image be less of an issue if the .png was the same quality as the Jmol image? I'm working on generating static images using Jmol on the server if a Java Virtual Machine is installed on the server. Many details like graceful fallback, probably to Tachyon, are still being worked out.

Does this answer your questions or generate in suggestions for what needs work?

strogdon commented 12 years ago
comment:9

Replying to @gutow:

Comments:

1) The red "Jmol_S" logo in the bottom right corner indicates that the signed applet has been loaded and has access to the user's directory tree. I believe I can turn it off, but think it is a bad idea. I want to be reminded that I am using an applet that can send stuff from my disk to the server. The menu is the same as the right-click menu that is always available with Jmol.

That explains things. For a sage-on-gentoo (s-o-g) build I had noticed from the jmol menu that the applet was signed but didn't associate this with the "_S". From the s-o-g install it would appear that the applets are always signed. I'm not sure it's possible for it to be otherwise. But that's a minor thing and not Sage related.

2) If we want to have an image as the default so that all devices will see something, users will have to deal with requesting it become interactive each time the cell is recalculated. The notebook+sage presently insists on reloading Jmol each time a recalculation is done. In order to do this properly we would need to have a separate div in the notebook for applets and not kill the applet unless it is not being used. Then Jmol would not revert to the starting over state each time a recalculation is done. I think that is another ticket for after these changes go in.

I suspected another layer of action was necessary to accomplish this or else it would have been done. My main interest was in getting it to work as intended.

3) Would reloading with a static image be less of an issue if the .png was the same quality as the Jmol image? I'm working on generating static images using Jmol on the server if a Java Virtual Machine is installed on the server. Many details like graceful fallback, probably to Tachyon, are still being worked out. Does this answer your questions or generate in suggestions for what needs work?

I think a high quality static image would be nice. It's true that if a notebook has a lot of applets then reloading that notebook can consume significant resources. Any attempt to mitigate this is desirable. FWIW, as far as I can determine, the s-o-g install of the new notebook functions exactly like the vanilla install. I have been using it here on top of Sage-4.8.

gutow commented 12 years ago

Description changed:

--- 
+++ 
@@ -1,6 +1,6 @@
 This ticket provides the following advanced interactive features to Jmol in the notebook:

-1. Initial display is a static image created by Tachyon (This means all browsers and devices will at least be able to see a 3-D image)
+1. Initial display is a static image created by Jmol (if a javaVM is available on the server) or Tachyon. This means all browsers and devices will at least be able to see a 3-D image.
 2. The live applet can be loaded by clicking on a "Make Interactive..." button.
 3. Colors can be changed without recalculating
 4. spin on checkbox
@@ -12,6 +12,9 @@
 10. Can download a file that the Jmol application can open to recreate the exact view shown on the web page.  This allows for more sophisticated manipulation and the semi-automatic creation of web pages that include this live 3-D image.
 11. Solves memory problems associated with opening too many Jmols at once, by automatically putting Jmols that are not being used to sleep.

+The development version of Jmol is necessary.  Install this .spkg:
+http://www.uwosh.edu/faculty_staff/gutow/jmol-12.3.21.p4.spkg
+
 Two patches are necessary:

 A patch to plot3d in Sage: [attachment: trac_12299_plot_3D_static_img.patch](https://github.com/sagemath/sage-prod/files/10654493/trac_12299_plot_3D_static_img.patch.gz)
gutow commented 12 years ago

Description changed:

--- 
+++ 
@@ -13,7 +13,7 @@
 11. Solves memory problems associated with opening too many Jmols at once, by automatically putting Jmols that are not being used to sleep.

 The development version of Jmol is necessary.  Install this .spkg:
-http://www.uwosh.edu/faculty_staff/gutow/jmol-12.3.21.p4.spkg
+http://www.uwosh.edu/faculty_staff/gutow/jmol-12.3.27.p0.spkg

 Two patches are necessary:

@@ -22,3 +22,5 @@
 A patch to a number of files in sagenb: [attachment: trac_12299_adv_jmol_nb.patch](https://github.com/sagemath/sage-prod/files/10654494/trac_12299_adv_jmol_nb.patch.gz)

 These patches include all the changes in #9238 plus.
+
+NOTE TO REVIEWERS: Please check that things work for the notebook running in secure mode.
gutow commented 12 years ago
comment:12

This rebases everything to sage-5.0, updates Jmol,refactors the static imaging code to be more object oriented, and adds some doctesting of static image creation. Now that the flask notebook has been positively reviewed it is time to get this reviewed.

kcrisman commented 12 years ago
comment:13

Adding someone who has been using the new notebook and Jmol stuff for a while, as far as I know.

I personally won't be able to test this until the changes ahead are merged in Sage, as I'm too lazy to follow the instructions to get the Flask notebook in. But #9238 worked pretty well the last time I tried it a year ago!

kcrisman commented 12 years ago
comment:14

Scarily, I managed to actually get the new notebook installed. Apparently.

Some comments:

kcrisman commented 12 years ago
comment:15

My first attempt at getting this to work showed that

gutow commented 12 years ago
comment:16

Can you add some more information as I'm not sure I understand what you are seeing?

Replying to @kcrisman:

My first attempt at getting this to work showed that * the Tachyon "placeholder" evaluates fine, though I agree with strogdon from #9238 that it's annoying to always have to make it interactive, though I understand the reasoning

1) Are you running locally or from a server? 2) Is this a tachyon image or a Jmol image (Jmol looks just like what you would see in Jmol, the Tachyon image has no axis ticks/numbers)? This is important, because your problems may relate to how I am handling the case where the server does not have a JVM installed.

  • Nothing else worked - lots of messages about restarting Jmol and so forth. At one point I even got a JmolData java applet starting outside the browser window.

If you are running locally you should see the JmolData application launch to generate the static image. So I think that answers my question about your test environment (local with a JVM available, right?). What browser are you running and did you run the notebook in secure mode? I assume you are getting the "Trying to launch JmolApplet#X..." dialogs? This means your browser is not getting the applets from the server or is taking a very long time to load them. Any more details you have would be useful (OS, flask notebook version, etc...).

Thanks for the report.

gutow commented 12 years ago
comment:17

Replying to @kcrisman:

Scarily, I managed to actually get the new notebook installed. Apparently.

Some comments:

  • I think you have to update attachment: trac_12299_plot_3D_static_img.patch. I see three different changesets to plot/plot3d/base.pyx, all of which seem to do something similar (namely, ask plot3d to make a Tachyon picture if Jmol fails). My guess is that you just exported the patches on top of each other; that's happened to me in the past too.
  • In fact, I think the same thing has happened (again!) with the sagenb patch as strogdon indicates happened before.

This is odd. I only see one patch in the file...I'll check it again. I also don't understand how you can get multiple patches if you only make one commit. Is something finicky about hg within sage?

  • Sadly, even the __init__ method needs at least a minimal docstring and test in your new interface class. There are also some extremely minor formatting issues in that file, but clearly no need to work on that until the rest has been reviewed.

I will work on the doctest. That's not a big deal. Thanks for pointing it out. I missed that one.

gutow commented 12 years ago

Attachment: trac_12299_plot_3D_static_img.patch.gz

update to remove duplicate patches

gutow commented 12 years ago

Description changed:

--- 
+++ 
@@ -12,6 +12,23 @@
 10. Can download a file that the Jmol application can open to recreate the exact view shown on the web page.  This allows for more sophisticated manipulation and the semi-automatic creation of web pages that include this live 3-D image.
 11. Solves memory problems associated with opening too many Jmols at once, by automatically putting Jmols that are not being used to sleep.

+**Explicit Installation Instructions:** (tested agains 5.0)
+
+1) Install the flask notebook by following the instructions in #11080. I recommend installing the optional OpenSSL package.  I have not been getting consistent behavior using the system install on all my different machines (probably a path issue).
+
+2) Then do the following to apply the patches and install an updated version of Jmol.  The first two commands close any Hg cues left open by the flask install (doesn't hurt to do that even if all the queues are closed).
+
+```
+./sage
+sage: hg_sage("qfinish -a")
+sage: hg_sagenb("qfinish -a")
+sage: hg_sage.apply("https://github.com/sagemath/sage-prod/files/10654493/trac_12299_plot_3D_static_img.patch.gz")
+sage: hg_sagenb.apply("https://github.com/sagemath/sage-prod/files/10654494/trac_12299_adv_jmol_nb.patch.gz")
+sage: exit
+./sage -f  "http://www.uwosh.edu/faculty_staff/gutow/jmol-12.3.27.p0.spkg"
+./sage -b
+```
+
 The development version of Jmol is necessary.  Install this .spkg:
 http://www.uwosh.edu/faculty_staff/gutow/jmol-12.3.27.p0.spkg

@@ -23,4 +40,4 @@

 These patches include all the changes in #9238 plus.

-NOTE TO REVIEWERS: Please check that things work for the notebook running in secure mode.
+NOTE TO REVIEWERS: Please check that things work for the notebook running in secure mode as well as the default insecure launched by the generic "notebook()" command.
gutow commented 12 years ago

Description changed:

--- 
+++ 
@@ -29,6 +29,7 @@
 ./sage -b

+Notes: The development version of Jmol is necessary. Install this .spkg: http://www.uwosh.edu/faculty_staff/gutow/jmol-12.3.27.p0.spkg

gutow commented 12 years ago

Description changed:

--- 
+++ 
@@ -12,7 +12,7 @@
 10. Can download a file that the Jmol application can open to recreate the exact view shown on the web page.  This allows for more sophisticated manipulation and the semi-automatic creation of web pages that include this live 3-D image.
 11. Solves memory problems associated with opening too many Jmols at once, by automatically putting Jmols that are not being used to sleep.

-**Explicit Installation Instructions:** (tested agains 5.0)
+**Explicit Installation Instructions:** (tested against 5.0)

 1) Install the flask notebook by following the instructions in #11080. I recommend installing the optional OpenSSL package.  I have not been getting consistent behavior using the system install on all my different machines (probably a path issue).

@@ -30,6 +30,9 @@

Notes: + +If you are doing this in a different way you need to know: + The development version of Jmol is necessary. Install this .spkg: http://www.uwosh.edu/faculty_staff/gutow/jmol-12.3.27.p0.spkg

gutow commented 12 years ago

Description changed:

--- 
+++ 
@@ -16,7 +16,7 @@

 1) Install the flask notebook by following the instructions in #11080. I recommend installing the optional OpenSSL package.  I have not been getting consistent behavior using the system install on all my different machines (probably a path issue).

-2) Then do the following to apply the patches and install an updated version of Jmol.  The first two commands close any Hg cues left open by the flask install (doesn't hurt to do that even if all the queues are closed).
+2) Then do the following to apply the patches and install an updated version of Jmol.  The first two commands close any Hg queues left open by the flask install (doesn't hurt to do that even if all the queues are closed).

./sage

kcrisman commented 12 years ago
comment:22

Okay, I will still have to look at what happens if "old" Jmols live in a directory, but at least it does, in fact, work.

I have to say that it is already, even after limited testing:

Other minor things noticed thus far:

Okay, this is all based on pretty much just testing ONE applet. I have not tested worksheets with hundreds, or even twos, of applets. But the basic functionality is fine as before, so hopefully we can get this in for Sage 5.2 along with the new notebook - let's keep our fingers crossed. strogdon, if you're out there, this would be great to test.

Finally, I will put this as "needs work" for two reasons:

kcrisman commented 12 years ago

Changed author from gutow to Jonathan Gutow

kcrisman commented 12 years ago

Work Issues: create upstream pull request

kcrisman commented 12 years ago

Reviewer: Karl-Dieter Crisman

kcrisman commented 12 years ago

Upstream: Not yet reported upstream; Will do shortly.

kcrisman commented 12 years ago

Changed work issues from create upstream pull request to create upstream pull request, double patch

gutow commented 12 years ago
comment:24

Replying to @kcrisman: OK, I see the double patch in the notebook patch...I'll fix it. I've also opened an issue on git, but I don't think that is what you meant by a pull request. Do I need to make a branch?

ppurka commented 12 years ago
comment:25

Replying to @gutow:

Replying to @kcrisman: OK, I see the double patch in the notebook patch...I'll fix it. I've also opened an issue on git, but I don't think that is what you meant by a pull request. Do I need to make a branch?

These are the steps you can follow:

  1. If you don't have a fork of the sagemath/sagenb github, then go to this page and click on "fork" on the top right. This will create a fork of this git repository inside your account.
  2. In your own machine, clone your fork using
git clone git://github.com/<your username>/sagenb sagenb-github

In particular, you can follow the directions here if you don't have a git repo.

  1. Next, make the changes to the files you want (for instance you may apply your patch manually) and then commit your changes using
git add <filenames> # In case you have introduced new files
git commit -a -m "commit message"
  1. Then push your changes to your own github repo using
git push -u origin
  1. Finally go to your github page and click on "Pull Request" on the top. This will create the pull request to sagemath/sagenb repository.

You can commit and push changes to the github page and the pull request will be updated automatically with your new changes. Because of this feature you can also decide to create a separate git branch and put a pull request only from that branch, so that other changes that you are working on don't get affected or included in the pull request.

If you are unclear about anything, just ask. I, kini, ohanar, are available on #sagemath too and will be glad to help. If you already know how to use git and github, then sorry for wasting your time. :)

kcrisman commented 12 years ago
comment:26

OK, I see the double patch in the notebook patch...I'll fix it. I've also opened an issue on git, but I don't think that is what you meant by a pull request. Do I need to make a branch?

Well, in principle as long as you have a patch based on that sagenb, someone like kini or ppurka can do the rest :)

This is issue 54 at the sagenb github.

kcrisman commented 12 years ago

Changed work issues from create upstream pull request, double patch to double patch

kcrisman commented 12 years ago

Changed upstream from Not yet reported upstream; Will do shortly. to Reported upstream. No feedback yet.

gutow commented 12 years ago

update to remove duplicate patches

gutow commented 12 years ago

Changed work issues from double patch to pop-up menu?

gutow commented 12 years ago
comment:27

Attachment: trac_12299_adv_jmol_nb.patch.gz

strogdon commented 12 years ago
comment:28

I've finally installed the flask notebook and the patches from this ticket on top of Sage-5.0. At one point things were changing too quickly for me to keep up but the situation now seems to be fairly stable. I have the following observations:

  1. The png images I see when a worksheet is first loaded are of much higher quality than what I observed with previous versions. This is nice.
  2. Occasionally, when an applet is made Interactive and the controls are toggled to "Download this view", if the download is cancelled then the Advanced controls disappear. The cell has to be re-evaluated to recover the controls. This usually happens after a first "Make Interactive" request for any one applet. Subsequent requests to Download do not seem to cause the Advanced controls to disappear.
  3. When a download is requested I get two requests to save when I cancel saving the jmol file.
  4. Is anyone able to get the grid to appear on the small red sphere for
x, y = var('x y');W = plot3d(sin(pi*((x)^2+(y)^2))/2,(x,-1,1),(y,-1,1), color='purple', opacity=0.8);S = sphere((0,0,0),size=0.3, color='red', aspect_ratio=[1,1,1]);show(W + S, figsize=4)

If no objections, I'll set myself as a reviewer also (provided I can figure out how to do that) since I've spent some time understanding and implementing items from the ticket.

strogdon commented 12 years ago

Changed reviewer from Karl-Dieter Crisman to Karl-Dieter Crisman, Steven Trogdon

gutow commented 12 years ago
comment:30

Replying to @strogdon:

  1. Occasionally, when an applet is made Interactive and the controls are toggled to "Download this view", if the download is cancelled then the Advanced controls disappear. The cell has to be re-evaluated to recover the controls. This usually happens after a first "Make Interactive" request for any one applet. Subsequent requests to Download do not seem to cause the Advanced controls to disappear.

This is some kind of communication issue. Probably associated with switching from unsigned to signed applets. What do you think about always using the signed applet? This will generate that warning about access to your computer the first time it is launched.

  1. When a download is requested I get two requests to save when I cancel saving the jmol file.

Yeah, that is annoying. It's something about the Java use of the save dialog. If I can catch Bob Hanson not working on something interesting, maybe we can fix that. We do know about it.

  1. Is anyone able to get the grid to appear on the small red sphere for
x, y = var('x y');W = plot3d(sin(pi*((x)^2+(y)^2))/2,(x,-1,1),(y,-1,1), color='purple', opacity=0.8);S = sphere((0,0,0),size=0.3, color='red', aspect_ratio=[1,1,1]);show(W + S, figsize=4)

I believe the sphere is a sphere object, which is not a surface defined by a bunch of vertices and triangles, thus there is no mesh to display. If Sage were to calculate it as a pmesh surface rather than use the Jmol builtin, then there would be a mesh.

kcrisman commented 12 years ago
comment:31

strogdon - you have totally been reviewing this, quite a bit, in fact!

  1. Occasionally, when an applet is made Interactive and the controls are toggled to "Download this view", if the download is cancelled then the Advanced controls disappear. The cell has to be re-evaluated to recover the controls. This usually happens after a first "Make Interactive" request for any one applet. Subsequent requests to Download do not seem to cause the Advanced controls to disappear.

This is some kind of communication issue. Probably associated with switching from unsigned to signed applets. What do you think about always using the signed applet? This will generate that warning about access to your computer the first time it is launched.

I really like not having to deal with that. Given that most people will not be downloading the view, the current behavior seems ok.

I believe the sphere is a sphere object, which is not a surface defined by a bunch of vertices and triangles, thus there is no mesh to display. If Sage were to calculate it as a pmesh surface rather than use the Jmol builtin, then there would be a mesh.

I don't know how Jmol does it, but you are right that we have primitives for things like spheres.

kcrisman commented 12 years ago
comment:32

My first attempt at getting this to work showed that

  • the Tachyon "placeholder" evaluates fine, though I agree with strogdon from #9238 that it's annoying to always have to make it interactive, though I understand the reasoning

You were right, it was the Jmol placeholder. I really find that annoying.

  • Nothing else worked - lots of messages about restarting Jmol and so forth. At one point I even got a JmolData java applet starting outside the browser window. Too late now to see what I did wrong, but wanted to let you know all was not flawless :( sorry.

I had the same problems on the same worksheet. This worksheet had only five Jmols, but took a million years to load (well, over a minute) and then I get the following.

Jmol Applet #0 is having trouble loading.  Will retry once.

Second attempt to finish launch of Jmol Applet #0 failed.  Recommend reevaluating the cell manually.

Same for all Jmols. Some didn't even make the static images. Even re-evaluating doesn't help at all - it does create the image, but as soon as I make it "live" I get the same horrible messages.

Note that in the new worksheet, I am just fine, and the little Jmol logo shows up properly in the upper left corner - not ever in this old worksheet, or only with the briefest of appearances. Notice that in old interacts everything works fine, presumably because these are indeed newly generated!


Question about implementation. How much work does Jmol have to do to generate all those static images every time that one opens a worksheet? In theory, once there is an image (png, I guess) generated, it should just stay in the cell's folder and be displayed; we certainly don't want to create a new one each time, any more than we do this for 2D plots. Though even with a largish sheet it doesn't seem to take super long, a little delay.

Have you tried using this on "old" worksheets with Jmols? This seems to be the problem I have, consistently; any Jmols from the old notebook (by which old Jmol is presumably meant) don't work.


More minor issues.

implicit_plot3d(x^2+y^2+z^2==16,(x,-5,5),(y,-5,5),(z,-5,5),color='green',plot_points=200)

I got

viewer handling error condition: java.lang.OutOfMemoryError: Java heap space

Maybe I'm being overoptimistic; the docs don't even have any with 100 plot_points.


I have to say that I'm by far the most concerned about the "old worksheets" issue. Second is the "automatically every image is static" - couldn't at least the first one be "live"? - but nearly everything else could be considered an enhancement request. Let me know what stuff I've mentioned is worth discussing here.

kcrisman commented 12 years ago

Changed work issues from pop-up menu? to old worksheets don't work

kcrisman commented 12 years ago
comment:34

Update: at least sometimes re-evaluating seems to remove the problem. But it isn't consistent, needs more testing.

gutow commented 12 years ago
comment:35

Replying to @kcrisman:

My first attempt at getting this to work showed that

  • the Tachyon "placeholder" evaluates fine, though I agree with strogdon from #9238 that it's annoying to always have to make it interactive, though I understand the reasoning

You were right, it was the Jmol placeholder. I really find that annoying.

We potentially could get rid of this with significant browser detection and a complete reworking of how Jmol is called for when a cell is recalculated. The problem is related to the fact that the applet is completely reloaded each time a cell is recalculated, rather than just passing it new data. This means it is very easy to get out of sync with what the server is sending to the applet. Many of the problems with the old Jmol relate to this. One of the problems I consistently have using the old format where Jmol loads live in interacts is that the interact starts calling for a new applet before the previous one is finished loading. I have had some discussions about putting the applet in a special div that does not get zapped each time a recalculation is done. That's probably the correct thing to do, but not high on people's list when the notebook was undergoing major revisions. I would prefer to put this off as an additional enhancement.

  • Nothing else worked - lots of messages about restarting Jmol and so forth. At one point I even got a JmolData java applet starting outside the browser window.

As your comments below suggest this appears to be a problem with old worksheets that have not been reevaluated. We might be able to put something into the notebook code that puts up a message suggesting the worksheet be re-evaluated if it does not have the data necessary for static images. I tried to put a message in the "alt" field for the images, but most browser now seem to ignore that. I think I can put a check into the cell code that would deal with this. I even have some ideas for generating images without reevaluation...I'll look into this.

Question about implementation. How much work does Jmol have to do to generate all those static images every time that one opens a worksheet?

Jmol only generates the image when a cell is evaluated. When you open a worksheet that was previously evaluated using these enhancements the images are already there.

More minor issues.

  • When I sleep an image, it doesn't come back with the advanced controls if I had them up. Is there any way to "save" that state, or is it too hard?

Hadn't thought about this. I will look into it.

  • Although it's pretty clear by the content, it's a little hard to see which tab you are on in the advanced controls sometimes. Maybe the shading could be slightly different.

I'm using Sage default CSS. I suppose we could define something custom.

  • In interacts, I think there is no point to having the initial static image. I have no idea if there is a way to detect this, but presumably one wouldn't have asked for this to be evaluated if one wasn't going to use it.

As I explained above, only simple interacts where the user does not call for lots of recalculations work reliably with the present model of loading Jmol live. Things with sliders are really bad.

  • The opening of the "JmolData" app each time is a little annoying.
  • When doing
implicit_plot3d(x^2+y^2+z^2==16,(x,-5,5),(y,-5,5),(z,-5,5),color='green',plot_points=200)

I got

viewer handling error condition: java.lang.OutOfMemoryError: Java heap space

Maybe I'm being overoptimistic; the docs don't even have any with 100 plot_points.

The application can certainly handle more. I'll see if I can change the memory allocation to allow for larger images...That is a little odd as we use Jmol in web pages to look at things with many more points, atoms and surfaces...

  • On the plus side, the thing where only four Jmols are active at a time is working fine. I notice that it deactivates the one furthest down or something, not the oldest one.

Actually it picks the one farthest from the cell you most recently evaluated that includes a Jmol. It can be above or below the cell you are working on.


I have to say that I'm by far the most concerned about the "old worksheets" issue. Second is the "automatically every image is static" - couldn't at least the first one be "live"? - but nearly everything else could be considered an enhancement request. Let me know what stuff I've mentioned is worth discussing here.

I agree that this should be a priority. I think there are solutions. What behavior would be best: 1) A pop-up suggestion to reevaluate old worksheets to update 3-D plots; 2) Attempt to update plots without reevaluation; 3) Automatically reevaluate worksheets with 3-D plots in them?

kcrisman commented 12 years ago
comment:36

We potentially could get rid of this with significant browser detection and a complete reworking of how Jmol is called for when a cell is recalculated. The problem is related to the fact that the applet is completely reloaded each time a cell is recalculated, rather than just passing it new data. This means it is very easy to get out of sync with what the server is sending to the applet. Many of the problems with the old Jmol relate to this.

Right, and I assume that passing it new info would be a pretty sizable change in how we use it.

I would prefer to put this off as an additional enhancement.

Now that I understand the technical issue better, I guess I would agree in some sense, but I figure it's buyer beware on the @interact cells. Having to do an extra click every time would get really old really fast with them. Maybe we could ask on sage-devel about the tradeoff, though perhaps (as usual with polls on sage-devel) we wouldn't get many takers...

As your comments below suggest this appears to be a problem with old worksheets that have not been reevaluated. We might be able to put something into the notebook code that puts up a message suggesting the worksheet be re-evaluated if it does not have the data necessary for static images. I tried to put a message in the "alt" field for the images, but most browser now seem to ignore that. I think I can put a check into the cell code that would deal with this. I even have some ideas for generating images without reevaluation...I'll look into this.

We definitely need to fix this. Again, I even had trouble with some worksheets even after re-evaluation.

It should be pretty easy for you to test this. Just open an old Sage, make a new worksheet with Jmols, close it, stop Sage, restart your new Jmol Sage, and see what happens. I figure you have more diagnostic tools than I will.

Jmol only generates the image when a cell is evaluated. When you open a worksheet that was previously evaluated using these enhancements the images are already there.

Great.

The application can certainly handle more. I'll see if I can change the memory allocation to allow for larger images...That is a little odd as we use Jmol in web pages to look at things with many more points, atoms and surfaces...

No, it's 100 points per axis, so one million points are evaluated and the presumably however many of them are on the sphere must be plotted. I think that's why we don't even have it in the docs, because it would take a long time. But it does seem to work in the old Jmol in Sage (just tried it in vanilla 5.0).

I agree that this should be a priority. I think there are solutions. What behavior would be best: 1) A pop-up suggestion to reevaluate old worksheets to update 3-D plots; 2) Attempt to update plots without reevaluation; 3) Automatically reevaluate worksheets with 3-D plots in them?

Definitely not 3. 1 also seems less than desirable unless it was only when there had been a Jmol before, and one could reliably detect it was from an earlier version of Jmol. How would 2 work?


Some dumb generic review questions.

gutow commented 12 years ago

Description changed:

--- 
+++ 
@@ -11,6 +11,8 @@
 9. Applet can be displayed in its own window
 10. Can download a file that the Jmol application can open to recreate the exact view shown on the web page.  This allows for more sophisticated manipulation and the semi-automatic creation of web pages that include this live 3-D image.
 11. Solves memory problems associated with opening too many Jmols at once, by automatically putting Jmols that are not being used to sleep.
+
+**If you just want to try:** Go to [TestServer](http://gutow.no-ip.org:8080) and create yourself an account.  I will try to keep it up-to-date and running, but it may be down when I am coding.

 **Explicit Installation Instructions:** (tested against 5.0)
gutow commented 12 years ago
comment:38

Replying to @kcrisman:

Some dumb generic review questions.

  • So far I've not been able to use this except on Safari on OS X because of some default I can't get around and logins. What have you tested this on? In the past you had done some pretty extensive testing. I figure we should at least test on Safari, FF, Chrome on Mac, FF and Chrome on Linux, IE and FF on Windows. I don't know how easy that will be for me unless you set up a remote server again, which I figure would be quite a pain.

I will keep a server up as best I can for the time being. Go to TestServer and create yourself an account. I will try to keep it up-to-date and running, but it may be down when I am coding. Linux and MacOS, I can test pretty well, but I really need feedback on Windows as I do not have a recent version.

  • What problems should one be looking for with secure=True? It sounds like you are thinking that there could be different issues in that case, maybe because of the applets being applets?

The major issue I am worried about is reliability of the applets when an unsigned applet is used in a secure environment. Browsers and Java are getting much more finicky about mixed modes. I've seen some cases where the applet will not launch under https if it is not signed. I need to know whether this is enough of a problem to spend some time on.

kcrisman commented 12 years ago
comment:39
  • So far I've not been able to use this except on Safari on OS X because of some default I can't get around and logins. What have you tested this on? In the past you had done some pretty extensive testing. I figure we should at least test on Safari, FF, Chrome on Mac, FF and Chrome on Linux, IE and FF on Windows. I don't know how easy that will be for me unless you set up a remote server again, which I figure would be quite a pain.

I will keep a server up as best I can for the time being. Go to TestServer and create yourself an account. I will try to keep it up-to-date and running, but it may be down when I am coding. Linux and MacOS, I can test pretty well, but I really need feedback on Windows as I do not have a recent version.

  • What problems should one be looking for with secure=True? It sounds like you are thinking that there could be different issues in that case, maybe because of the applets being applets?

The major issue I am worried about is reliability of the applets when an unsigned applet is used in a secure environment. Browsers and Java are getting much more finicky about mixed modes. I've seen some cases where the applet will not launch under https if it is not signed. I need to know whether this is enough of a problem to spend some time on.

Is the test server you link to with secure=True or False? I guess since it's http, not https, it's False?

gutow commented 12 years ago
comment:40

Replying to @kcrisman:

Is the test server you link to with secure=True or False? I guess since it's http, not https, it's False?

Correct. Let's get other issues dealt with before the signed issue.

strogdon commented 12 years ago
comment:41

So I have a situation here that I hadn't notice previously. I have 12 applets in a worksheet. I'm not sure if the number is important but probably at least 4 are needed. If I start the notebook and load the worksheet things seem normal; I can "Make Interactive" applets throughout the worksheet with 4 interactive ones. So applets are put to sleep as new ones are made interactive. Now if I "Toggle Advanced Controls" on one of the applets, proceed to "Download this view" and cancel the request; I'm left with 3 interactive applets. As I toggle the advanced controls now to make applets interactive there are never more than 3 interactive applets. At some point in the clicking process to make applets interactive I get a pop-up with

Could not find jmolApplet#

where # is some number. After the pop-up is closed, things get frozen. I'm unable to make applets interactive unless I put to sleep an already interactive applet. I've tried this, at leas 4 times with the same result. Now I'm doing this over nfs. I wouldn't think that nfs would cause this. What seems to recover things is the sequence; Actions -> Delete All Output and then Actions -> Evaluate All. I can then get 4 interactive applets again, all of which are now signed. If repeat the procedure to "Download this view" and cancel the request with these signed applets the worksheet doesn't freeze.

strogdon commented 12 years ago
comment:42

In trying to isolate exactly what triggers the above I found that if I don't try to recover the Advanced Controls on the applet that was used to download the view as a jmol file (Download this view) then the worksheet doesn't seem to freeze as I make other applets interactive. And eventually this applet that was used to download the view as a jmol will be put in a sleep state that can then be made interactive. So, it seems that if an applet is unsigned and one wishes to save the view in a jmol file, to avoid freezes the best thing to do is to not re-evaluate its cell.