Crash with javascript when saving file while script is running.

Dec 5, 2006 at 8:21am

Crash with javascript when saving file while script is running.

Hi,
I have an intermittent problem when i edit a javascript file MaxMSP crashes.
I have tried to remove all the code on the file until it stopped crashing. then I added only comments. after a few comments it start crashing again.
The crashes are unpredictable but happens quite often.
I am using MaxMSP/jitter 4.6.2 on a MacBook Pro (intel-mac).
If anyone as experience this same problem or knows the reason
for it, I would greatly appreciate your help.

thanks.
yaku

Here is the code scavenged from a tutorial47 as a starting point
to test this crashing problem:

// 47jMarbles.js
//
// Demonstrates how to set up a JitterListener object to listen
// to the output of a Jitter object instantiated within [js].
//
// rld, 7.05
//

// allows for the dynamic updating of script revisions
autowatch = 1;

var OBJECT_COUNT = 1; // number of little spheres

// create a [jit.window] object for our display
// (this is the object we’ll “listen” to):
var mywindow = new JitterObject(“jit.window”,”ListenWindow”);

// turn off depth testing… we’re using blending instead:
mywindow.depthbuffer = 0;

// turn ON idlemousing… we want to listen for it:
mywindow.idlemouse = 1;

// turn ON Fullscreen anti-aliasing flag:
//mywindow.fsaa = 1;

// set windows size
mywindow.size = [320,240];
mywindow.grow = 1;

// create a [jit.gl.render] object for drawing into our window:
var myrender = new JitterObject(“jit.gl.render”,”ListenWindow”);

// use a 2-dimensional projection:
myrender.ortho = 0;

// set background to black with full erase opacity (no trails):
myrender.erase_color = [0,0,0,1];

var Deg = Math.PI/360;

// create a [jit.gl.gridshape] object for use to control with the mouse
var mywidget = new JitterObject(“jit.gl.gridshape”,”ListenWindow”);
mywidget.shape = “sphere”;
mywidget.lighting_enable = 1;
mywidget.smooth_shading = 1;
mywidget.shininess = 255;
mywidget.scale = [0.05,0.05,0.05];
mywidget.color = [1,1,1,0.5];
mywidget.blend_enable = 1;
// no z necessary in orthographic projection:
mywidget.position = [0,0];

// create an array of [jit.gl.gridshape] objects randomly arrayed across the window
var mysphere = new Array(OBJECT_COUNT);
// initialize our little spheres with random colors and positions (x,y)
var tempRandom;
for(var i=0;i
mysphere[i] = new JitterObject(“jit.gl.gridshape”,”ListenWindow”);
mysphere[i].shape = “sphere”;
mysphere[i].lighting_enable = 1;
mysphere[i].smooth_shading = 1;
tempRandom = Math.random() * .075 + .025;
//mysphere[i].scale = [tempRandom,tempRandom,tempRandom];
mysphere[i].scale = [0.025,0.025,0.025];
mysphere[i].color = [Math.random(), Math.random(), Math.random(), Math.random()];
mysphere[i].radius = Math.random()+0.05;
mysphere[i].angle = Math.random()*Math.PI*2.0;
mysphere[i].increment = Math.random()*(18*Deg)-(8*Deg);
mysphere[i].position = [Math.random()*2.-1, Math.random()*2.-1];
mysphere[i].blend_enable = 1;
mysphere[i].numout = 0.0;
// the position in the previous time frame:
mysphere[i].posAgo = mysphere[i].position;
mysphere[i].cage = [-1, 1, .75, -.75, 1, -1];
mysphere.colortemp = mysphere.color;
}

function randomize() {
// reorient the little spheres
var temp2;
for(var i=0;i
temp2 = Math.random() * .075 + .025;
//mysphere[i].scale = [temp2,temp2,temp2];
mysphere[i].scale = [0.025,0.025,0.025];
//mysphere[i].scale = [Math.random() * .075 + .025,Math.random() * .075 + .025,Math.random() * .075 + .025];
mysphere[i].color = [Math.random(), Math.random(),Math.random(), Math.random()];
// keep it from getting too close to the sun:
mysphere[i].radius = Math.random()+0.05;
mysphere[i].angle = Math.random()*Math.PI*2.0;
mysphere[i].position = [Math.sin(mysphere[i].angle)*mysphere[i].radius, Math.cos(mysphere[i].angle)*mysphere[i].radius];
mysphere.colortemp = mysphere.color;
} // end of for.
} // end of randomize().

// create a JitterListener for our [jit.window] object:
var mylistener = new JitterListener(mywindow.getregisteredname(), thecallback);

function thecallback(event) {
// callback function to handle events triggered by mousing
// in our [jit.window]:
var x,y,button; // some local variables
var tRadius,tAngle, wRadius;
var xoft, yoft;

if (event.eventname==”mouse”) {
x = event.args[0];
y = event.args[1];

post(“[x,y] = [", x,", ",y,"]“);
post();

xoft = mywindow.size[0]/2.0 – x;
yoft = mywindow.size[1]/2.0 – y;

// *******************************************************
// If I add or remove comments or any other code
// from this point in the code soon or later
// the MaxMSP program will crash!
// *******************************************************

post();

} // end if event.

} // end of thecallback().

// don’t allow this function to be called from Max
thecallback.local = 1;

function bang() {
// main drawing loop… figure out which little spheres to move
// and drive the renderer.

} // end of the bang()

function fullscreen(v) {
// function to send the [jit.window] into fullscreen mode

mywindow.fullscreen = v;
} // end of the fullscreen.

#29047
Dec 5, 2006 at 8:27am

This is a known problem when there are JS scripts with jit.windows and
jit.gl.renders in them. What’s happening is that the JS garbage
collector is freeing the opengl context, invalidating it but another
Jitter object is trying to use it. The best way to avoid this is by
calling freepeer() on all Jitter objects when the script is reloaded
to explicitly remove the jitter objects bound to the JS variables.
It’s kind of a pain in the arse but it will keep things from crashing.

wes

On 12/5/06, yves klein wrote:
>
> Hi,
> I have an intermittent problem when i edit a javascript file MaxMSP crashes.
> I have tried to remove all the code on the file until it stopped crashing. then I added only comments. after a few comments it start crashing again.
> The crashes are unpredictable but happens quite often.
> I am using MaxMSP/jitter 4.6.2 on a MacBook Pro (intel-mac).
> If anyone as experience this same problem or knows the reason
> for it, I would greatly appreciate your help.
>
> thanks.
> yaku
>
> Here is the code scavenged from a tutorial47 as a starting point
> to test this crashing problem:
>
> // 47jMarbles.js
> //
> // Demonstrates how to set up a JitterListener object to listen
> // to the output of a Jitter object instantiated within [js].
> //
> // rld, 7.05
> //
>
> // allows for the dynamic updating of script revisions
> autowatch = 1;
>
> var OBJECT_COUNT = 1; // number of little spheres
>
> // create a [jit.window] object for our display
> // (this is the object we’ll “listen” to):
> var mywindow = new JitterObject(“jit.window”,”ListenWindow”);
>
> // turn off depth testing… we’re using blending instead:
> mywindow.depthbuffer = 0;
>
> // turn ON idlemousing… we want to listen for it:
> mywindow.idlemouse = 1;
>
> // turn ON Fullscreen anti-aliasing flag:
> //mywindow.fsaa = 1;
>
> // set windows size
> mywindow.size = [320,240];
> mywindow.grow = 1;
>
> // create a [jit.gl.render] object for drawing into our window:
> var myrender = new JitterObject(“jit.gl.render”,”ListenWindow”);
>
> // use a 2-dimensional projection:
> myrender.ortho = 0;
>
> // set background to black with full erase opacity (no trails):
> myrender.erase_color = [0,0,0,1];
>
> var Deg = Math.PI/360;
>
>
> // create a [jit.gl.gridshape] object for use to control with the mouse
> var mywidget = new JitterObject(“jit.gl.gridshape”,”ListenWindow”);
> mywidget.shape = “sphere”;
> mywidget.lighting_enable = 1;
> mywidget.smooth_shading = 1;
> mywidget.shininess = 255;
> mywidget.scale = [0.05,0.05,0.05];
> mywidget.color = [1,1,1,0.5];
> mywidget.blend_enable = 1;
> // no z necessary in orthographic projection:
> mywidget.position = [0,0];
>
>
> // create an array of [jit.gl.gridshape] objects randomly arrayed across the window
> var mysphere = new Array(OBJECT_COUNT);
> // initialize our little spheres with random colors and positions (x,y)
> var tempRandom;
> for(var i=0;i
> mysphere[i] = new JitterObject(“jit.gl.gridshape”,”ListenWindow”);
> mysphere[i].shape = “sphere”;
> mysphere[i].lighting_enable = 1;
> mysphere[i].smooth_shading = 1;
> tempRandom = Math.random() * .075 + .025;
> //mysphere[i].scale = [tempRandom,tempRandom,tempRandom];
> mysphere[i].scale = [0.025,0.025,0.025];
> mysphere[i].color = [Math.random(), Math.random(), Math.random(), Math.random()];
> mysphere[i].radius = Math.random()+0.05;
> mysphere[i].angle = Math.random()*Math.PI*2.0;
> mysphere[i].increment = Math.random()*(18*Deg)-(8*Deg);
> mysphere[i].position = [Math.random()*2.-1, Math.random()*2.-1];
> mysphere[i].blend_enable = 1;
> mysphere[i].numout = 0.0;
> // the position in the previous time frame:
> mysphere[i].posAgo = mysphere[i].position;
> mysphere[i].cage = [-1, 1, .75, -.75, 1, -1];
> mysphere.colortemp = mysphere.color;
> }
>
> function randomize() {
> // reorient the little spheres
> var temp2;
> for(var i=0;i
> temp2 = Math.random() * .075 + .025;
> //mysphere[i].scale = [temp2,temp2,temp2];
> mysphere[i].scale = [0.025,0.025,0.025];
> //mysphere[i].scale = [Math.random() * .075 + .025,Math.random() * .075 + .025,Math.random() * .075 + .025];
> mysphere[i].color = [Math.random(), Math.random(),Math.random(), Math.random()];
> // keep it from getting too close to the sun:
> mysphere[i].radius = Math.random()+0.05;
> mysphere[i].angle = Math.random()*Math.PI*2.0;
> mysphere[i].position = [Math.sin(mysphere[i].angle)*mysphere[i].radius, Math.cos(mysphere[i].angle)*mysphere[i].radius];
> mysphere.colortemp = mysphere.color;
> } // end of for.
> } // end of randomize().
>
>
> // create a JitterListener for our [jit.window] object:
> var mylistener = new JitterListener(mywindow.getregisteredname(), thecallback);
>
> function thecallback(event) {
> // callback function to handle events triggered by mousing
> // in our [jit.window]:
> var x,y,button; // some local variables
> var tRadius,tAngle, wRadius;
> var xoft, yoft;
>
> if (event.eventname==”mouse”) {
> x = event.args[0];
> y = event.args[1];
>
> post(“[x,y] = [", x,", ",y,"]“);
> post();
>
>
> xoft = mywindow.size[0]/2.0 – x;
> yoft = mywindow.size[1]/2.0 – y;
>
> // *******************************************************
> // If I add or remove comments or any other code
> // from this point in the code soon or later
> // the MaxMSP program will crash!
> // *******************************************************
>
> post();
>
> } // end if event.
>
> } // end of thecallback().
>
> // don’t allow this function to be called from Max
> thecallback.local = 1;
>
>
> function bang() {
> // main drawing loop… figure out which little spheres to move
> // and drive the renderer.
>
>
> } // end of the bang()
>
>
> function fullscreen(v) {
> // function to send the [jit.window] into fullscreen mode
>
> mywindow.fullscreen = v;
> } // end of the fullscreen.
>
>

#89862

You must be logged in to reply to this topic.