Ableton 11 appears to break the functionality of the Task Object
This is fun one. I wrote some code for a device that uses the Task Object. Everything works as expected when I use my device in Ableton 10. However, in Ableton 11 on both Windows and Mac it appears to stop functioning.
For context, here's the quick breakdown of how the code works...
The user triggers an initialization function that sets all the global variables to a starting value and then kicks off the desired process function.
The desired processing function searches for a desired condition to be true within a data set using a loop to process each piece of data. Each iteration increments the necessary global variables.
When the desired condition is found, the task function is called for a given number of repetitions.
A flag is set that allows the process function to pause using break or return commands nested in if statements checking for that flag
The Task function runs. When it reaches it's final repetition, it calls the process function again.
This repeats until certain global variable conditions are met.
Now after debugging for a while, this what I found. The Task function runs successfully "once". More specifically, it's called to repeat x number of times and on the last repetition it triggers the process function again as expected. However, the second time it's called to repeat, it stops just before the last repetition. It fails to call the process function again and everything grinds to a halt. As far as I can tell, this is not an error on my part because the works just fine on Ableton 10 (Windows and Mac). I've been looking through the release notes and documentation looking for a clue, but I have not had any luck. Hence, once again I am asking for your help. Maybe I should change my name to Trevor being Bernie. Anyway, this forum is full of heroes without capes as far as I can tell, thanks for any insight in advance!
i use task often in Live 11. Impossible to diagnose without code sample which reproduces the problem.
Well let me ask more generally then, how did Ableton 11 affect the JavaScript implementation in Max compared to Ableton 10? Based on what I described, how may that be relevant to my situation? This is the kind of insight I am looking for so I can diagnose the problem. I will work on an isolated code sample. In the meantime, these release note links may be helpful now or for someone in the future...
On my machine
Ableton 10 Max Version: 8.1.11
Ableton 11 Max Version: 8.3.3
Max Release Notes After 8.1.11 up to 8.3.3
http://cycling74.s3.amazonaws.com/support/version_8_2_0.html
http://cycling74.s3.amazonaws.com/support/version_8_2_1.html
http://cycling74.s3.amazonaws.com/support/version_8_2_2.html
http://cycling74.s3.amazonaws.com/support/version_8_3_0.html
http://cycling74.s3.amazonaws.com/support/version_8_3_1.html
http://cycling74.s3.amazonaws.com/support/version_8_3_2.html
https://cycling74.s3.amazonaws.com/support/version_8_3_3.html
Possibly Related Excerpts from Links Above
8.2.0
jsliveapi: eliminate crash when there's no 'this' for operations (the task object uses 'this')
8.2.2
JS Task: fixed issue with creating JS object with task
Kudos for digging up the history. If you are trying to prove a regression caused by a Max update among those builds the next step would be a binary regression through the builds.
So maybe you'd start with Live 10 but linking Max install of 8.2.1 and see if it happens. Then move newer to newer or older builds based on those results to isolate where the behavior change was introduced. This is truly tedious and potentially very unrewarding, but it can also be super helpful to the devs to have that kind of information.
Truly tedious and potentially very unrewarding, but it can also be super helpful.
I feel like this captures some of the struggles of troubleshooting haha. I may have to do that to get the bottom of it. However, I just got it working by creating a fresh Task object right before I call the repeat function. Not sure why this works, but this is the only change I made...
In Live 10
//global declaration
var myTask = new Task(taskFunction, this);
//Then when the process function needs to call it for x number of repeats
myTask.repeat(x);
In Live 11
//global declaration
var myTask = newTask(taskFunction, this);
//Then when the process function needs to call it for x number of repeats
myTask = new Task(taskFunction, this);
myTask.repeat(x);
nice you found a workaround. If you’re going to do it that way you probably want to call Task.freepeer() before you re-assign myTask to the new Task. I think that will allow the previous task to be garbage collected.
Thanks, I went back to Live 10 and had new issues. However, adding arguments.callee.task.freepeer(); at the end of the last iteration of the task fixed those issues so good call!
Now I am noticing that the Live theme is overriding some of my colors in Live 11 causing my UI to look off. It looks like there is precedent for this in the release notes...
8.3.0
Dynamic Colors: new default 'Text / Icon' color follows Live themes
(I wonder if this means the newobject method will ignore Live themes, but this seems to be outdated and doesn't respond for objects like "textbutton")
8.3.2
Color Selector: theme-aware
Dynamic Colors: preserved for object box borders
Dynamic Colors: restored when loaded in a different Live theme
Currently my only solution is to comment out any custom color choices I made such as...
//dynamicallyCreatedMaxObject.setattr("textcolor", [1,1,1,1]);
//dynamicallyCreatedMaxObject.setattr("bgcolor", [0.259, 0.259, 0.259, 0.722]);
I need one of my objects to ignore Live colors, but I don't see an obvious way to set this via JavaScript. I feel like we need a useLiveColors attribute added. Posting mainly to point out more differences between Live 11 and 10. Also, I may have a workaround I will follow up on.
Related Thread
https://cycling74.com/forums/themes-messes-up-colours
Okay here was my strategy to deal with Live changing my dynamically created object's colors.
Set up a live.colors object to bang a message that calls a function within your Javascript object. It didn't seem to matter, but I put a small 10ms delay on mine.
Use the setattr method to re-establish the color attributes of the dynamically created objects. You can essentially copy and paste the color settings you set before. However, through testing, you may need to add some more. For example, for a textbutton object, "textcolor", "textovercolor" and "textoncolor" seem to be the combination that kept things consistent across ableton 10 and 11.
Once things are working as expected, build some kind of protection to ignore the function call when the dynamic objects have not been generated. I used a gate on live.colors that doesn't open until the device is fully loaded. I also have an if statement within the function to check if certain variables exist.
It would be nice to simply have an attribute we could set to ignore color updates, but this got the job done for now.