[Grace-core] AAARRRRGGGGHHHHH!

Kim Bruce kim at cs.pomona.edu
Fri Jun 29 16:14:45 PDT 2012


I've been struggling to get concurrency to work properly in the Javascript version of Grace, using Tim's implementation of the Processing capabilities ported to Javascript.  I've been very frustrated with erratic behavior that did not correspond to my code and sent me off into wild tangents.

Finally at 1:30 this morning, an inkling of what was going on hit me.  I'm still not sure what the issue really is, but I can get some repeatability.  The issue seems to be running a program more than once.  If I haven't run anything in the browser (usually because I've quit and restarted -- though sometimes I have to let it sit as well) then the first time I run a program it works fine.  However, at some point in running the same program again (or a different program) things go bad.  (It's not always the second time, sometimes it takes three, four or more times).  At that point the program runs, including responding to mouse clicks, but it refuses to execute the block associated with processing.onDraw.  (interestingly, sometimes it lock up in mid-run.  That is it works fine for a while and then stops the animation.)

From this point on, no program will run (including Tim's demo).

[One thing I just discovered is that the easiest way to trigger this semi-freeze is to click twice in rapid succession.  This makes me suspicious that this might be a concurrency issue.  That might explain why Tim's demo doesn't have problems, but mine does -- I'm updating a list with each click, while he is just changing colors.]

I should note that if I have a drawing program that goes bad, then it draws items one click after they were supposed to have been drawn and refuses to animated them at all (and not even running the onDraw code at all).  However, if I restart the browser, all is well.

While I can now reliably reproduce the problem, I don't have a solution.  Any ideas?

Of course aside from the freezing in a single program, I have the issue that once it occurs I have to restart the browser to get anything to run.  This suggests that there something is getting wedged and not restarted correctly -- I've also seen cases where a setting in one program impacts the next to run.  I do have one suggestion that may help with that problem -- and might also help some other annoyances with the current system.

What if the user interface was designed so that instead of pasting code into the window and clicking "Run", it instead popped up a file selection dialog that let you choose your file.  That has the advantage of not having to worry about changing both your original version of the program as well as the version in the window (something that I seem to have issues with, alas).  It also allows the opportunity to shut down any existing processing programs before starting a new one.  (Admittedly, reprogramming the current "Run" button could do the same thing.)  Another advantage is that the current system reports error messages with line numbers, but the line numbers are not available on the window.  Given that my programs are close to 1000 lines, I end up having to go back to the original file to figure out where errors are.

Finally, while writing this I've been trying various experiments.  Unfortunately, they do not always give the same results.  Sometimes I can run a program (unchanged) in Firefox several times before it starts misbehaving.  Other times, restarting Firefox doesn't help at all.  I suspect this may depend on something timing out along the way.  With Safari, sometimes killing the "Safari web content" process is sufficient.  However, at other times it seems to require quitting all of Safari.  I wish I knew the solution.

So, I'm happy to hear suggestions on how to better cope with this.  In the hopes of encouraging others of you to experiment with this, I am attaching my program file.  It is worth noting that these issues seem to arise more frequently when I use graphics (though the attached program just uses mouse clicks to generate prints).

Kim

-------------- next part --------------
A non-text attachment was scrubbed...
Name: AnimatorTest3.grace
Type: application/octet-stream
Size: 15311 bytes
Desc: not available
URL: <https://mailhost.cecs.pdx.edu/mailman/private/grace-core/attachments/20120629/d6168af5/attachment.obj>
-------------- next part --------------



More information about the Grace-core mailing list