BelaPlatform / Bela

Bela: core code, IDE and lots of fun!
Other
491 stars 139 forks source link

Saving Code #243

Closed EdJames94 closed 6 years ago

EdJames94 commented 7 years ago

The Bela user guide indicates that code saves automatically but since I started trying to type code up on the IDE, it has not been saving and when I leave the project and come back to it, all the code that I have entered is gone. I have tried saving the project as, and the same thing is happening.

LBDonovan commented 7 years ago

Hi Ed, sorry to hear you lost your code, I hope you didn't lose too much work.

Could you first tell me what browser and operating system you are using (including version numbers), and then if you haven't already, just try rebooting Bela and closing and re-opening the IDE to see if that fixes the problem?

giuliomoro commented 7 years ago

If you open an example project and edit the code and then you switch to another example project, you should get a warning that you are going to lose your changes. If you continue, your changes are lost. This is expected behaviour.

If you save the project with name, then the code should be saved on the board as you type. If this is not the case, try hitting the "Run" button: are your changes to the code reflected on the running program? This would show that the file is saved correctly to disk.

If you confirm the issue and have already tried what has been suggested above, could you try to run the following in the IDE's console?

df -h

This should tell us whether you have run out of space.

EdJames94 commented 7 years ago

I've only been playing with it so haven't lost anything important but I'm using Firefox on windows 10. I have had this saving warning when moving from one example project but saving on a named project seems to be the issue. I have also just updated bela but this didn't make any difference.

giuliomoro commented 7 years ago

do the changes you make to the code get compiled and executed correctly ?

If they do, can you please run the following in the console ?

ls -l projects/PROJECTNAME/

while you have PROJECTNAME open. Then open one of the examples and run the same command again (using the same PROJECTNAME as before). Please post here the output produced by the above commands (and df -h as requested above).

giuliomoro commented 7 years ago

ok, please follow the following steps:

It would be helpful if you could make a video of you doing this (either a screen grab or a video with your phone, then e.g.: upload it as unlisted on youtube and send the link here or at info@bela.io ).

Thanks

EdJames94 commented 7 years ago

test

Screenshot for first instruction

EDIT: Using this command on another project is outputting the same info.

LBDonovan commented 7 years ago

Hi Ed

Sorry again that you are having this problem, it is not one we have seen before and its quite tricky to work out how to fix it. Just to clarify, could you follow these steps:

Thanks!

giuliomoro commented 7 years ago

@EdJames94 I close this as we did not hear back from you for a while. I assume you sorted it out, but do let us know if there is something you want to share with us or feel free to re-open if it is not solved.

7mon commented 7 years ago

Hello, I'm starting this thread again, because I might have run into the same problem: basicaly, the Bela doesn't seem to save anymore (it worked well before and suddenly not). Except that, everything seems to work fine, but as it doesn't automatically save the work, it also compiles the "previous" version, not the new one. I updated the Bela, no change; I wiped clean the SD card and reinstalled everything, no change; I tried to trick it by saving a new project (which also works) but no change so far. I'm a bit hopeless and would appreciate any help! I work on macOS 10.12.4, and firefox 53.0

Thanks.

giuliomoro commented 7 years ago

Hi, could you try with a different browser perhaps?

7mon commented 7 years ago

I've tried with Safari, no luck so far...

giuliomoro commented 7 years ago

Actually can you run mount in the IDE's console and post here the result please?

7mon commented 7 years ago

Sure:

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=63252,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=50868k,mode=755)
/dev/mmcblk0p2 on / type ext4 (rw,noatime,errors=remount-ro,data=ordered)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=101720k)
/dev/mmcblk0p1 on /boot/uboot type vfat ro,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,nosuid,nodev,noexec,relatime)
giuliomoro commented 7 years ago

that looks almost fine, except that /boot/uboot is mounted as ro (read only) while it should be rw (read write). We are not actually using that partition for the data, but perhaps the fact that is mounted as ro (as consequence of an error) may suggest maybe a faulty SD card.

Could you try to reboot a few times and run mount after every reboot and see if you see any difference? We are interested in these lines:

/dev/mmcblk0p2 on / type ext4 (rw,noatime,errors=remount-ro,data=ordered)
/dev/mmcblk0p1 on /boot/uboot type vfat ro,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
7mon commented 7 years ago

Ok, after the first reset (hard reset, with the button onboard of the BBB and no unmounting of the SD card partition that appears on my mac), it gave this:

/dev/mmcblk0p2 on / type ext4 (rw,noatime,errors=remount-ro,data=ordered)
/dev/mmcblk0p1 on /boot/uboot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)

The ro became rw

After the second reset:

/dev/mmcblk0p2 on / type ext4 (rw,noatime,errors=remount-ro,data=ordered)
/dev/mmcblk0p1 on /boot/uboot type vfat (ro,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)

It went back to ro...

Third reset:

/dev/mmcblk0p2 on / type ext4 (rw,noatime,errors=remount-ro,data=ordered)
/dev/mmcblk0p1 on /boot/uboot type vfat (ro,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)

Stays to ro.

It seems to alternate between ro and rw, but this has no effect on the "autosave process"

giuliomoro commented 7 years ago

Could you please run the steps we outlined above, here and here and report back?

Also, do you have another SD card available (4GB or larger) that you could try to flash?

7mon commented 7 years ago

Ok, sorry for the big post. Here are the results of the first set of steps: I created a test project as instructed. Here is what was on my screen:

#include <Bela.h>

bool setup(BelaContext *context, void *userData)
{
        rt_printf("hello!\n");
        return true;
}

void render(BelaContext *context, void *userData)
{

}

void cleanup(BelaContext *context, void *userData)
{

}

Here is the render.cpp file after the first download (which is absolutely not what was on screen, but the basic exemple instead, which is the project that loads automatically on sartup)

/*
 ____  _____ _        _    
| __ )| ____| |      / \   
|  _ \|  _| | |     / _ \  
| |_) | |___| |___ / ___ \ 
|____/|_____|_____/_/   \_\

The platform for ultra-low latency audio and sensor processing

http://bela.io

A project of the Augmented Instruments Laboratory within the
Centre for Digital Music at Queen Mary University of London.
http://www.eecs.qmul.ac.uk/~andrewm

(c) 2016 Augmented Instruments Laboratory: Andrew McPherson,
  Astrid Bin, Liam Donovan, Christian Heinrichs, Robert Jack,
  Giulio Moro, Laurel Pardue, Victor Zappi. All rights reserved.

The Bela software is distributed under the GNU Lesser General Public License
(LGPL 3.0), available here: https://www.gnu.org/licenses/lgpl-3.0.txt
*/

#include <Bela.h>
#include <cmath>
#include <SampleStream.h>

#define NUM_CHANNELS 2    // NUMBER OF CHANNELS IN THE FILE
#define BUFFER_LEN 44100   // BUFFER LENGTH
#define NUM_STREAMS 20

SampleStream *sampleStream[NUM_STREAMS];
AuxiliaryTask gFillBuffersTask;
int gStopThreads = 0;
int gTaskStopped = 0;
int gCount = 0;

void fillBuffers() {
    for(int i=0;i<NUM_STREAMS;i++) {
        if(sampleStream[i]->bufferNeedsFilled())
            sampleStream[i]->fillBuffer();
    }
}

bool setup(BelaContext *context, void *userData)
{

    for(int i=0;i<NUM_STREAMS;i++) {
        sampleStream[i] = new SampleStream("waves.wav",NUM_CHANNELS,BUFFER_LEN);
    }

    // Initialise auxiliary tasks
    if((gFillBuffersTask = Bela_createAuxiliaryTask(&fillBuffers, 90, "fill-buffer")) == 0)
        return false;

    return true;
}

void render(BelaContext *context, void *userData)
{

    // check if buffers need filling
    Bela_scheduleAuxiliaryTask(gFillBuffersTask);

    // ***** remove this -- it's just a demonstration
    // random playback toggling
    for(int i=0;i<NUM_STREAMS;i++) {
        // randomly pauses/unpauses + fades in/out streams
        if((rand() / (float)RAND_MAX)>0.9999)
            sampleStream[i]->togglePlaybackWithFade(0.1);
            // the above function can also be overloaded specifying the state
            // of playback to toggle - i.e. togglePlaybackWithFade(1,0.1)
            // same applies to togglePlayback()
        /*
         * demonstrates dynamically reloading samples
         * (TODO: this should really be done in a separate thread)
         */
        // if((rand() / (float)RAND_MAX)>0.9999) {
        //     // only change sample if sampleStream isn't playing
        //     if(!sampleStream[i]->isPlaying())
        //         sampleStream[i]->openFile("chimes_stereo.wav",NUM_CHANNELS,BUFFER_LEN);
        // }
    }
    // *****

    for(unsigned int n = 0; n < context->audioFrames; n++) {

        for(int i=0;i<NUM_STREAMS;i++) {
            // process frames for each sampleStream objects (get samples per channel below)
            sampleStream[i]->processFrame();
        }

        for(unsigned int channel = 0; channel < context->audioOutChannels; channel++) {

            float out = 0;
            for(int i=0;i<NUM_STREAMS;i++) {
                // get samples for each channel from each sampleStream object
                out += sampleStream[i]->getSample(channel);
            }
            // you may need to attenuate the output depending on the amount of streams playing back
            audioWrite(context, n, channel, out);

        }

    }
}

void cleanup(BelaContext *context, void *userData)
{
    for(int i=0;i<NUM_STREAMS;i++) {
        delete sampleStream[i];
    }
}

/**
\example sample-streamer-multi/render.cpp

Multiple playback of large wav files
---------------------------

This is an extension of the sampleStreamer example. Functionality of opening
files, managing buffers, retrieving samples etc. is built into the `sampleStream`
class, making it easier to have multiple playback streams at the same time.
Streams can be paused/unpaused with the option of fading in/out the playback.

*/

When I ran the project, "Hello" never appeared in the console.

Then, after opening the basic example, and reopening my test project, The line printf was gone, and the second download of render.cpp gave the same as above:

/*
 ____  _____ _        _    
| __ )| ____| |      / \   
|  _ \|  _| | |     / _ \  
| |_) | |___| |___ / ___ \ 
|____/|_____|_____/_/   \_\

The platform for ultra-low latency audio and sensor processing

http://bela.io

A project of the Augmented Instruments Laboratory within the
Centre for Digital Music at Queen Mary University of London.
http://www.eecs.qmul.ac.uk/~andrewm

(c) 2016 Augmented Instruments Laboratory: Andrew McPherson,
  Astrid Bin, Liam Donovan, Christian Heinrichs, Robert Jack,
  Giulio Moro, Laurel Pardue, Victor Zappi. All rights reserved.

The Bela software is distributed under the GNU Lesser General Public License
(LGPL 3.0), available here: https://www.gnu.org/licenses/lgpl-3.0.txt
*/

#include <Bela.h>
#include <cmath>
#include <SampleStream.h>

#define NUM_CHANNELS 2    // NUMBER OF CHANNELS IN THE FILE
#define BUFFER_LEN 44100   // BUFFER LENGTH
#define NUM_STREAMS 20

SampleStream *sampleStream[NUM_STREAMS];
AuxiliaryTask gFillBuffersTask;
int gStopThreads = 0;
int gTaskStopped = 0;
int gCount = 0;

void fillBuffers() {
    for(int i=0;i<NUM_STREAMS;i++) {
        if(sampleStream[i]->bufferNeedsFilled())
            sampleStream[i]->fillBuffer();
    }
}

bool setup(BelaContext *context, void *userData)
{

    for(int i=0;i<NUM_STREAMS;i++) {
        sampleStream[i] = new SampleStream("waves.wav",NUM_CHANNELS,BUFFER_LEN);
    }

    // Initialise auxiliary tasks
    if((gFillBuffersTask = Bela_createAuxiliaryTask(&fillBuffers, 90, "fill-buffer")) == 0)
        return false;

    return true;
}

void render(BelaContext *context, void *userData)
{

    // check if buffers need filling
    Bela_scheduleAuxiliaryTask(gFillBuffersTask);

    // ***** remove this -- it's just a demonstration
    // random playback toggling
    for(int i=0;i<NUM_STREAMS;i++) {
        // randomly pauses/unpauses + fades in/out streams
        if((rand() / (float)RAND_MAX)>0.9999)
            sampleStream[i]->togglePlaybackWithFade(0.1);
            // the above function can also be overloaded specifying the state
            // of playback to toggle - i.e. togglePlaybackWithFade(1,0.1)
            // same applies to togglePlayback()
        /*
         * demonstrates dynamically reloading samples
         * (TODO: this should really be done in a separate thread)
         */
        // if((rand() / (float)RAND_MAX)>0.9999) {
        //     // only change sample if sampleStream isn't playing
        //     if(!sampleStream[i]->isPlaying())
        //         sampleStream[i]->openFile("chimes_stereo.wav",NUM_CHANNELS,BUFFER_LEN);
        // }
    }
    // *****

    for(unsigned int n = 0; n < context->audioFrames; n++) {

        for(int i=0;i<NUM_STREAMS;i++) {
            // process frames for each sampleStream objects (get samples per channel below)
            sampleStream[i]->processFrame();
        }

        for(unsigned int channel = 0; channel < context->audioOutChannels; channel++) {

            float out = 0;
            for(int i=0;i<NUM_STREAMS;i++) {
                // get samples for each channel from each sampleStream object
                out += sampleStream[i]->getSample(channel);
            }
            // you may need to attenuate the output depending on the amount of streams playing back
            audioWrite(context, n, channel, out);

        }

    }
}

void cleanup(BelaContext *context, void *userData)
{
    for(int i=0;i<NUM_STREAMS;i++) {
        delete sampleStream[i];
    }
}

/**
\example sample-streamer-multi/render.cpp

Multiple playback of large wav files
---------------------------

This is an extension of the sampleStreamer example. Functionality of opening
files, managing buffers, retrieving samples etc. is built into the `sampleStream`
class, making it easier to have multiple playback streams at the same time.
Streams can be paused/unpaused with the option of fading in/out the playback.

*/

And of course, the "Hello" also never appeared.

I've flashed a new SDcard and my problem is the same. I've then ran the test above with the new SD card. Same results.

Afterwards, I did the other steps you mentionned: I used the test project (with the "hello world" line) and it doesn't really run: instead, it's the previously loaded project that runs (the basic example in my case, like before). With the first command, I had this:

total 240
drwxr-xr-x 2 root root   4096 May  5 08:53 build
-rw-r--r-- 1 root root    198 May  5 08:53 render.cpp
-rw-r--r-- 1 root root    347 May  5 08:54 settings.json
-rwxr-xr-x 1 root root 230752 May  5 08:53 test

After opening the Sample streamer example, I ran the same command and got the exact same thing:

total 240
drwxr-xr-x 2 root root   4096 May  5 08:53 build
-rw-r--r-- 1 root root    198 May  5 08:53 render.cpp
-rw-r--r-- 1 root root    347 May  5 08:54 settings.json
-rwxr-xr-x 1 root root 230752 May  5 08:53 test

I haven't made a video yet.

This looks curiouser and curiouser...

giuliomoro commented 7 years ago

ok. Could you please do the following in the console at the bottom of the IDE?

echo 123 > test
ls -l test
cat test

thanks

7mon commented 7 years ago

Thanks to you! Here is the console:

root@bela ~/Bela# echo 123 > test
root@bela ~/Bela# ls -l test
-rw-r--r-- 1 root root 4 May  5 12:23 test
root@bela ~/Bela# cat test
123
giuliomoro commented 7 years ago

Right, so writing to disk actually works.

Could you run this in a terminal app (NOT from the console in the Bela IDE)?

ssh root@192.168.7.2 screen -r Bela-IDE

this will show you the real-time log of the IDE. Try to edit a file in the IDE and see if any errors pop up in the log. (use ctrl-a ctrl-d to detach without stopping the IDE)

Then try this from the terminal app (NOT from the console in the Bela IDE)

ssh root@192.168.7.2 make -C Bela idestart

this will restart the IDE. Check if now edit /saving files works

7mon commented 7 years ago

Well, it becomes a bit cryptic for me, but with the first command the terminal says "Must be connected to a terminal." But the second command works and restarts the IDE... what am I missing?

giuliomoro commented 7 years ago

... that the first command I gave you is wrong as you actually need to force tty allocation with -t(also I had the name of the screen wrong):

 ssh -t root@192.168.7.2 screen -r IDE-Bela

Does autosave work after you restarted the IDE with the command above?

7mon commented 7 years ago

Ok, after running the command, I got this:

Plaf:~ Simon$  ssh -t root@192.168.7.2 screen -r IDE-Bela

opening file with extension cpp
opened render.cpp
spawning make "--no-print-directory" "-C" "/root/Bela/" "syntax" "PROJECT=test"
error calculating cpu undefined
spawning make "--no-print-directory" "-C" "/root/Bela/" "syntax" "PROJECT=test"
could not find settings.json in project folder, creating default project settings
spawning make "--no-print-directory" "-C" "/root/Bela/" "syntax"
opening file with extension cpp
opened render.cpp
spawning make "--no-print-directory" "-C" "/root/Bela/" "syntax" "PROJECT=GC_v06"
opening file with extension cpp
opened render.cpp
spawning make "--no-print-directory" "-C" "/root/Bela/" "syntax" "PROJECT=test"
opening file with extension cpp
opened render.cpp
spawning make "--no-print-directory" "-C" "/root/Bela/" "syntax" "PROJECT=GC_v06"
spawning make "--no-print-directory" "-C" "/root/Bela/" "syntax" "PROJECT=GC_v06"
opening file with extension cpp
opened render.cpp
spawning make "--no-print-directory" "-C" "/root/Bela/" "syntax" "PROJECT=test"
opening file with extension cpp
opened render.cpp
spawning make "--no-print-directory" "-C" "/root/Bela/" "syntax" "PROJECT=GC_v06"

And after restarting the IDE, the autosave works "one time" i.e. if I make changes just after the reboot of the IDE, and switch to another project, and come back to the first one, the changes have been saved. But any further changes aren't saved.

giuliomoro commented 7 years ago

@LBDonovan that log looks alright, right?

@7mon, would you mind dropping us an email at info@bela.io ?

7mon commented 7 years ago

sure

giuliomoro commented 7 years ago

So @7mon shipped his board to us and we could not reproduce the issue: it worked out of the box for us. We shipped him a replacement (which was tested working for us) but showed the exact same issue on his machine, so this could be a machine-specific but cross-browser issue. ???? Probably a subtle bug in the IDE code that is only highlighted in particular circumstances and after 10pm on a full moon.

@7mon seems to have fixed it eventually by:

I did:

  • open the SampleStream-multi example.
  • Save as a new project with a new name
  • select all the code in render.cpp and then delete it
  • Select all « my code » of « my » render.cpp saved in a text file, copy, and paste it in the bela IDE.
  • doing the same for SampleStream.h and SampleStream.cpp because those are the 3 files I’ve modified from the sampleStream-Multi example, for my project.
  • And it doesn’t work. The original files of the example come back when I display them.

So, I’ve tried another way, which is to delete those 3 files and than upload « my versions » with the « upload file » button in the IDE.

  • The new files were ok
  • and now it seems I can modify those files and the modification are saved...

Anyone encountering this problem, please help us debugging it: download this file https://github.com/giuliomoro/Bela/raw/dev-simon/IDE/public/js/bundle.js and copy it to the board in /root/Bela/IDE/public/js/bundle.js?

You will have to scp the file over with:

 scp bundle.js root@192.168.7.2:Bela/IDE/public/js/

then restart the IDE :

 ssh root@192.168.7.2 make -C Bela idestart

This will enable some additional logging. Once the IDE comes back to life, you would then open the developer console (in Firefox something like "cmd+alt i" and then "cmd+alt k", in Chrome is "cmd+alt+j")

then in the console you would get something the following every time you make a change:

Uploade is being emitted  bundle.js:476:2
upload true  bundle.js:1817:4
upload was not blocked  bundle.js:1819:5
firing tokenizer  bundle.js:1822:6

do you see that? Do you see something different?

WRodewald commented 7 years ago

Hi,

some info's on my occurrence of the issue: I'm running Win10, tried Chrome, Firefox and IE to change the file that seems to have the issue. Then switched to a Win7 machine, installed the driver (first use of bela on that machine) and run into the same issue using Chrome. (Didn't test other browsers)

Following the guidelines above yields following log:

upload false
bundle.js:1817 upload true
bundle.js:1819 upload was not blocked
bundle.js:1822 firing tokenizer
bundle.js:476 Uploade is being emitted
bundle.js:1817 upload false

EDIT 1

Also can confirm this behaviour every once in a while:

And after restarting the IDE, the autosave works "one time" i.e. if I make changes just after the reboot of the IDE, and switch to another project, and come back to the first one, the changes have been saved. But any further changes aren't saved.

EDIT 2

What was that about the full moon? I called

 ssh -t root@192.168.7.2 screen -r IDE-Bela

and then restarted the IDE just for the fun of it via

ssh root@192.168.7.2 make -C Bela idestart

and now it seems to work.

giuliomoro commented 7 years ago

It seems to be triggered when pasting a few lines of code into the editor. This also prevents you from uploading a file from the web interface.

Sometimes restarting the IDE AND refreshing the web page fixes it. So it seems a "lock" in the client-side javascript.