Forums > Javascript

Max 6.0.5; autowatch not working, javascript sometimes doesn't find the JS file.

August 2, 2012 | 2:46 pm

Hello, Max Javascripters.

I moved to Max 6 recently in an effort to prevent my M4L/Ableton crashes (which didn’t abate so I just gave up on that for now).

I’m trying to do some simpler things now but there still seem to be issues with Javascript and Max or Max For Live.

First, neither autowatch nor the compile message seem to re-read the Javascript when it’s been changed in an external editor. The only think that reliably works for me is to edit the JS box itself so Max believes I’ve changed the filename.

Second, Max sometimes loses track of where that Javascript file is. Everything’s in my Max path, but if I try to look at the file I’ve changed, I see only the old file, and if I re-edit the box, the js box can no longer find the file again.

It seems I can avoid that issue if I save the Javascript file in Max, close the patch, and then re-open it.


August 2, 2012 | 2:58 pm

It’s working fine for me. We’ll need more details.

-A


August 2, 2012 | 3:31 pm

To demonstrate "autowatch not working".

1. Load the patch below with watcher.js as attached:

autowatch = 1;
post(‘loading 3n’);

2. I see "loading 3" in the Max window.
3. Now change the post message in the JS file to "loading autowatch".
4. I see nothing new in the Max Window.
5. Clicking on the "compile" button, I see "loading autowatch" in the Max Window.
6. Sending the messages autowatch 1 or autowatch 0 into the patch has no effect.

In this setup, the compile button does work. In my more complex setup, the compile button does not appear to work. If needed, I can distill that down later into a more complete test.

– Pasted Max Patch, click to expand. –
Attachments:
  1. watcher.js

August 2, 2012 | 3:35 pm

[deleted]


August 2, 2012 | 3:40 pm

Here’s what I did.

- saved your js file to a folder on my desktop
- made a new patch with your code and saved it in to the same folder as the js.
- added a js object to the patch to load the js, verify that is loaded ok.
- opened the js in a text editor and changed the post arg
- saved the js file i the external editor and saw it updating in the Max window as expected.


August 2, 2012 | 3:55 pm

This is how my workflow used to go before I got Max 6. Once I got Max 6, this workflow ceased to happen for me.

Sorry, this must be frustrating for you if you can’t repro.

Um. I can make you a quicktime screen movie showing me going through these steps, if that would help – it’d be a bit large but probably clear enough, I could put it on YouTube?

Could it be some setting in Max that I could re-initialize?

I’m loathe to restart the machine as I have a lot of work in process, but that could be done I suppose?

I have of course quit and restarted M4L a few times.


August 2, 2012 | 3:57 pm

Oh, I should add that I do all my work, for both Max and Max for Live in ~/Library/Application Support/Ableton/Library/Presets/MIDI Effects/Max MIDI Effect, perhaps that’s somehow the issue?


August 2, 2012 | 4:10 pm

All right. I made a screen movie which appears to demonstrate this bug from scratch, and also to show an anomalous error in the Max window that might well be related.

It’s uploading as we speak, it’ll take about 20 mins, and it’ll be here. I’ll update this post when it’s finished uploading.


August 2, 2012 | 4:36 pm

And it’s up, 3 minutes and 11 seconds of thrills!

I start by opening Max from scratch and creating a test patch named watch-me.maxpat with Javascript watch-me.js.

I save the Javascript, and then the Max patch – but then I look at the Max window and there’s the first anomaly at 1:22 – an error js: can’t find file watch-me.js.

This must be anomalous, because you can see in the next line that it does, in fact, execute the Javascript and print the statement "watch this drive".

I click compile a few more times, and each time I get the error, and the message.

I close Max and restart it by double-clicking on the Max patch. Now everything’s OK. I demonstrate this by opening the Max editor and changing the JS – you can see the message print correctly in the Max window.

Now I fire up my external editor and change the file.

No new message appears in the Max window!

Then I open the JS file from inside Max, and it appears to have not changed…

BUT if I click the compile button, then it does re-read the Javascript code, and you can see the changes I made in the external file.

I go through this procedure one more time to check, and that’s it.


August 2, 2012 | 4:56 pm

Is your Max MIDI effect folder in your search path? If it is not then this looks right to me.

You save the js into that folder before you have saved the patch there, so the search path for the file does not exist.

I think the compile message forces a re-read, at which point the patch is in the search path and it works.

Yeah? Or maybe I’m missing something.

-A


August 2, 2012 | 5:14 pm

Max MIDI Effect was not in my search path. I put it in my search path and reran the experiment from scratch, and got exactly the same results.


August 2, 2012 | 5:16 pm

So clearly somehow my system is different from yours. Under no circumstances does autowatch do anything for me, whether or not the .js and the .maxpat are in my search path, and it always seems to work for you.

How could our systems be different and cause this? I’m running 10.6, on a vanilla MacBook…. my Max 6 is a fairly fresh install and I’ve installed no other software…


August 2, 2012 | 5:33 pm

Ah ok. Yeah seems like we aren’t doing very well with the newly created files from the js object.

Thanks for persevering with this and sorry for the trouble. We’ll have a look at it for sure.

Cheers

-A


August 2, 2012 | 6:56 pm

Thanks!

Particularly, I don’t care about the initial errors. What I care about is autowatch not working. The other issue is irrelevant, really – it just came up during my demo…


August 2, 2012 | 7:00 pm

In the meantime, I think you can workaround this by creating the js file before loading the js object. Autowatch should then work fine.

-A


August 2, 2012 | 7:42 pm

Thanks!

Debugging is hard — too hard.


August 3, 2012 | 12:35 am

Maybe…
any javascript source file that have autowatch set to 1 (and also set to 0) and that js file is in the max search path (and not in)
if "you got error msg about js object (most is syntax error) that show up in max window" then the js object will stop working until you fix that problem that max tell in the max window by edit the jssource via max internal javascript editor but….you need to save it (that was we don’t want to do that)….. If I expected that problem I just fix it via external editor (I use textmate) then delete and undo the js object … just that


August 7, 2012 | 11:38 am

Interesting idea, but I get the issue even when there are no syntax errors. :-(


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