Forums > MaxMSP

Execution order with [js] mixed up / depending on if manual or metro bang

March 30, 2012 | 8:51 pm

I am observing a weird delay issue involving a javascript object. I wonder if its due to a setting on my computer / some maxmsp settings, or if its a bug in the system. I would be grateful if someone could copy the code below and verify if it behaves the same way for them.

I use a js-object, and for some reason the execution of the javascript seems to be delayed depending on if i trigger the execution with a manual bang or a bang coming from a metro object. And i can’t explain why …

– Pasted Max Patch, click to expand. –
Attachments:
  1. jsweird.maxpat

March 31, 2012 | 2:03 am

This is probably relevant:
Controlling a Function’s Thread of Execution
…most notably the line that reads,
"By default, the js object executes all Javascript code in the low-priority thread. In particular, if it finds itself running in the high-priority thread, it will defer execution of whatever it was supposed to do to the low-priority thread."


March 31, 2012 | 2:39 pm

This sounds like it should be the solution!

Sadly, including

msg_int.immediate = 1;

into the javascript keeps crashing Max. When i hit the bang manually, all is fine. But it crashes when i try to activate the toggle button of the metro object.


March 31, 2012 | 4:04 pm

Seems to behave differently on Windows and OSX.
According to different posts on this forum.


March 31, 2012 | 4:04 pm

The immediate method is deprecated in Max6.

Calls to it in JS code will be ignored. Sorry about the confusion, we’ll tidy up the docs.

It shouldn’t crash either, we’ll have a look.

-A


March 31, 2012 | 4:07 pm

Still on Max 5.1.4 (on Windows 7).


March 31, 2012 | 4:25 pm

@evsc

Yes, unfortunately you may be looking at one of the reasons why we deprecated it.
JS in Max5 had a multi threaded implementation which had problems, and when we upgraded JS for Max6 it was deemed more trouble than it was worth.JS in Max 6 is single threaded.

Your patch behaves exactly as it should, both with Overdrive on and off. JS always executes in the low priority thread. Ui interactions also always occur in the low priority thread, which is why you see a difference between the button press and the metro with Overdrive on.

Cheers

Andrew


Viewing 7 posts - 1 through 7 (of 7 total)