Execution order with [js] mixed up / depending on if manual or metro bang
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 ...
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."
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.
Seems to behave differently on Windows and OSX.
According to different posts on this forum.
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
Still on Max 5.1.4 (on Windows 7).
@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
I'm very sorry to ask for clarification, but when something is stated as 'deprecated' it usually means it still works for now, but there will be a better substitution for the functionality in the future. Does this in fact mean to say that high-priority javascript execution has been *dropped*, and it will not be supported by other means in the future?
Also, please could it be clarified, what is the implication of this for the 'jstrigger' object? The documentation states it works like trigger, which is high-priority, so it would seem from prior documentation that single javascript statements could be executed at high priority via jstrigger. But maybe thats wrong.