Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Losing code, Editor quirks

edited October 25 in Bugs Posts: 46

Hello all,

1)With Codea 3.0, and with my project file stored in the Working Copy directory, I am experiencing issues where I will run the project, then return back to the code, then maybe try to run it again and return to code, and it seems to have lost recent changes that I had made. This isn’t a proper bug report, as I haven’t yet put a finger on exactly how to reproduce it. I just know I’ve lost some code this way a handful of times today, and I’m wondering if this is a known issue. I will try to pin down a sequence to reproduce the issue.

With the previous version, I never had an issue like this. Code I wrote was code that stayed.

2) The editor isn’t consistently ‘behaving’ properly - for example, I’ll tap return after entering function foo() and Codea doesn’t always auto add the end keyword. It also is not always auto-indenting lines within a code block.

Tagged:

Comments

  • dave1707dave1707 Mod
    Posts: 7,866

    @brianolive What level of 3.0 code are you running. I mentioned the missing end keyword and left justification problem in the Codea version 184 discussion. As far as I know it was fixed and I haven’t seen it since. As for the missing code, I think I remember that happening but I’m not sure what version that was in and if that was also fixed. I’m not sure if it has happened recently. I’m currently running Codea 3.0.1 version 187.

  • Posts: 46

    Version showing as 3.0 (187).

    Project being in working copy doesn’t seem to have anything to do with it. It just happened with a project stored in the Codea folder.

    I’m not doing a good job tonight of tracking what leads up to the problem! Each time it happens, I don’t clearly recall what I did right before it happens...to be continued...

  • Posts: 1,366
    All,
    I wonder if this is tied in with the disappearing keyboard. Recently found the keyboard not being launched after tapping an input or the screen in the editor. Seemed to happen when I had left the editor for a while. Closing project and re-opening needed to resume normal editing.
  • SimeonSimeon Admin Mod
    Posts: 5,054

    @brianolive are you using the feature where you can drag-and-drop sprites or shaders into code? Because there appears to be a bug with that where changes are lost

  • Posts: 46

    @Simeon No, I am not using that feature (but sweet feature, btw!). I'm sorry to make you have to guess what I'm doing. I'll figure out exactly what I'm doing that causes this to happen - hopefully later this evening.

  • Posts: 13

    I’m losing code also, just by tapping code, run it, and Codea crash.
    When I reopen the project, it has returned to it’s preview save. My solution is to close and reopen the project before each run. -_-

  • edited October 3 Posts: 1,366
    Hi All,
    Could you all post your iOS and Codea versions when you post (like @dave1707), it helps narrow down the problems and helps @Simeon et al focus on the right code. Or, you could fill those details in your profile and update when necessary.

    I'm on iOS 13.1 and Codea 3.0.1 (187).
  • Posts: 46

    @Simeon , what is happening to @moechofe2 is what I am experiencing. I thought it happened in another case too, but at least once I definitely had the same sequence of events he had. 3.0 (187)

  • SimeonSimeon Admin Mod
    Posts: 5,054

    @brianolive @moechofe2

    So the process is
    1. Run code
    2. Codea crashes (code doesn't run)
    3. Re-open Codea and notice that last edits are not saved in the file

    But I'm guessing (2) doesn't happen consistently?

    There is a hidden feature that might help you work around this while I debug the issue:

    1. Long press the play button in the top right corner
    2. A dialog will pop up asking to save your project prior to running it
    3. Choose "Save & Run"
  • Posts: 46

    Long press play - nice! Great to know.

    Step 2 is not a problem on your end - it is not consistent. That (usually) only happens when something is wrong with my code that makes Codea/Lua unhappy...

    The loss of state after that crash is the issue.

    I have also seen this code loss happen though without an app crash. I’ll return to the code editor, maybe make some code changes, run my code again, and then notice that the program is still executing from the previous version of my code (i.e. how the code was before my most recent edits). I’ll think to myself (for example), “How can that be? I just commented those lines out”, or something like that...then return to the editor, only to see that the changes I made (commenting out lines, adding new lines, etc.) are gone. Codea was running the code from a state before my last changes.

  • Posts: 13

    IOS 12.4.1
    Codea 3.0 (187)
    I’m using iCloud as document storage from the setting app.

    @Simeon the steps are exactly as you describes.

    I will be aware the next it crash and trying to explain more precisely.

  • SimeonSimeon Admin Mod
    Posts: 5,054

    Thanks for the details! I'll keep looking into this, for now please try using the long-press option

    (The reason this isn't the default behaviour is in case you are editing documents over a network, where the save could take a long time)

  • Posts: 1,366

    @Simeon - may be related. Firstly I have had a few crashes recently with a project that I have been putting together. It involves multiple print() commands and I think memory requirements were probably exceeded.

    The issue I would like to raise was after running Codea, I opened the Codea root folder up in the files app. Whilst playing around in the files app looking for a file Codea bombed out. I will try to reproduce - have you altered the file system within Codea in the latest version?

  • Posts: 447

    I'd like to add a data point. I'm on the latest published version of Codea on iPadOS. I've experienced it where Codea seems to have cached an old version of the code and it runs that rather than any changes. If I exit the editor, run another Codea program, and then return to the original one then the code is the old version and my changes are lost. It is intermittent, but there are no crashes involved.

    The long press to reveal a "save" option is fantastic - I was going to request a "force save" option to avoid this issue.

  • SimeonSimeon Admin Mod
    Posts: 5,054

    @Bri_G what issue did you find in the file system? I haven't altered it, inside the Codea folder there is your documents, and any folders with projects are treated as collections in the UI

    @LoopSpace thank you for the extra report. Would you say it happens often? I'll try to track this down

  • edited October 5 Posts: 1,366
    @Simeon - No issue with the file system, Codea was running in the background whilst I was using file app on the Codea folder. A shrinking window.popped up over the file window - an alert to say Codea had bombed. The alert was very brief, so I missed the detail but got the message.

    Oh, by the way - thanks for the save then run option, I may use that by default.
  • Posts: 1,366

    @Simeon - just found another issue. After using search and replace, on returning to the editor window, I found several instances of the highlighted search term dotted round my code - in some cases in free space in others overlapping my code.

  • Just an update: long press save (see @Simeon ‘s comment above, is not fixing my problem...

    I just spent a few cycles of tweaking a function, then long-press saving and running, and not seeing results I would expect. Once I added some obvious print statements and didn’t see them, I decided to exit the project and reopen. Sure enough, there was an older version of my code, and that was the version that had been running each time. The code shown in the editor was not what was getting executed. After each run attempt and return to the editor, I would see my changes in the editor, but none of it would affect program behavior.

  • The issue is elusive, so still no guaranteed way to reproduce it that I’ve found yet, but - in hopes of this hitting @Simeon ’s radar, I wanted to add one more way that this manifests: Today I made a small change (arg value in rect() call), changed Codea tabs, returned to the first tab, and the arg was the older value. My change went away. No code execution between the tab changes.

    And also, as an example, here’s an unfortunately typical situation for me since Codea 3.0:
    Today I added some logic when a touch is in the BEGAN state. I test by tapping, and nothing. I’ve done this a million times, so I check my code to see if I’ve done anything dumb. Same behavior. Then I add a print statement. Nothing! Then I realize, ok, it’s happening again. I close the project, sometimes close Codea too, and return to my project to find that my tap logic isn’t even there. I have to enter it again.

    I don’t believe that long tap saving solves this. I’ll be more consistent with its usage, and see. But - I don’t want to have to do that.

  • dave1707dave1707 Mod
    edited October 26 Posts: 7,866

    Everyone, if you go into Settings and scroll down and tap on Codea, what do you have set for Document Storage. Don’t know if that might be a cause, but it might help track things down. Mine is On My IPad and I haven’t noticed any issues. I haven’t been doing the Save and Run option either.

    PS. I’m also not doing anything with the Files app with Codea.

  • I didn’t know about that. Mine was set to iCloud Drive (which I don’t even use). I switched it to On My Ipad. Feeling optimistic! I’ll let you know how it goes.

  • Posts: 447

    Thanks @dave1707 for the tip. Mine was also set to iCloud Drive and I know that my iCloud was getting full up so that might have been contributory. I've set mine to On My iPad and will monitor its behaviour.

  • Posts: 742
    Likewise - bug has been total pain - fingers crossed this resolves it
  • Posts: 447

    Initial prognosis: doesn't help.

    I switched to 'On My iPad' and I've been editing a project and been hit multiple times by the "not saved" bug.

  • dave1707dave1707 Mod
    Posts: 7,866

    @LoopSpace I wasn’t sure if that would help or not, but I thought I’d suggest it anyways. How large of a project and how many tabs is your current project. I’ve been trying to cause the problem to see if I can track something down, but I haven’t been able to cause it. Maybe with more info and everyone trying to pin it down, we can find the cause and get it fixed.

  • dave1707dave1707 Mod
    Posts: 7,866

    Trying to create loss of project data bug, but I can cause a Codea crash consistently. Don’t know if this is related to the project data loss.

    1. From the Files app, open a Codea project.
    2. At the project editor screen, finger squeeze the screen to minimize it.
    3. Tap the Files app screen to enlarge it.
    4. From the Files app, open the currently running Codea project.
    5. A loading spinner will show but the project won’t open.
    6. Finger squeeze the screen to minimize it.
    7. Eventually a pop up will show saying Codea Crashed and asks if you want to share additional information with the developer.
  • Posts: 447

    @dave1707 It was definitely worth a try. I shall try again as I didn't force-quit Codea between making the change and coding (but my iPad is out of juice so I'm waiting on that).

    My current project is 3 tabs, the primary tab is about 500 lines long. It does side-load quite a large amount of code from other projects, though. That shouldn't affect saving because it should save it before trying to run it.

  • dave1707dave1707 Mod
    edited October 26 Posts: 7,866

    Here’s some code that shows the purpose of the Run & Save option of long pressing the Run icon. Make a change in the prt function and run (not run and save) the code. It displays the code on the screen. Keep tapping the screen to reread the tab and it takes about 10 seconds before the code is actually updated. If you do the Run & Save, the code is updated before its run. I’ve been playing around with this trying to get the bug to show by force closing, causing errors, or anything. But so far I haven’t had any success to get the bug.

    PS. I’m wondering if there could be something happening at the time when the code is being updated and something else going on.

    PSs. Somehow, Codea has to be interrupted before it can update the current edited code so that the code in some buffer is still there and used ignoring any changes just made.

    displayMode(FULLSCREEN)
    
    function setup()
        cnt=0
        prt()
    end
    
    function draw()
        background(0)
        fill(255)
        text("tap screen to read tab, count   "..cnt,WIDTH/2,HEIGHT-100)
        text(str,WIDTH/2,HEIGHT/2-10)
    end
    
    function prt()
    
        print("0")  -- change something here between the “ “      
    
        str=readProjectTab("Main")
    end
    
    function touched(t)
        if t.state==BEGAN then
            cnt=cnt+1
            prt()
        end
    end
    
  • dave1707dave1707 Mod
    Posts: 7,866

    Not sure if this will explain anything, but if you load this code, then remove the function temp, and run the code which I have coded to crash Codea, after loading the code again, the function temp will still be there. If you do the above steps with Run & Save, then the function temp won’t be there if you removed it.

    It takes about 10 seconds for the edited code to be updated. So if you’re in a cycle where you change and run your code quickly and Codea crashes, then your changes won’t be there when you reload it.

    Does this seem to mimic the problems somewhat.

    Just so everyone knows, the code xx=xx..xx causes Codea to run out of memory and crash.

    function setup()
        xx="qwertyuiop"
    end
    
    function draw()
        background(0)
        xx=xx..xx  
    end
    
    function temp()
        print("temp")
    end
    
  • Posts: 1,366

    @Simeon - I know it's low priority, but just letting you know I have seen similar problems with not updating the edited project code in Air code Codea on my browser. It also has a greater tendency to bomb out of Codea. When editing with Air code I tend to exit to the list of projects and run another project before switching back to ensure edits have been adopted - that usually works fine. But, if you don't run another project and return to the edited file the edits have disappeared. I am using Safari on my Mac.

    Note also, the tendency to bomb out is usually in the project list window after a short period of time. Could this be down to the same code changes in the latest beta?

  • AnatolyAnatoly Mod
    Posts: 873

    Not sure if that’s related, but lately I’ve been experiencing similar problems:

    • Editor randomly crashes and loses lately added edits.
    • Even switching the code tab can lead to code loss.
    • When running project, exiting the app, you may notice your code is lost.
    • Touching the sprite and color selector leads to the crashes most of the time.
    • If editing the code and exiting by going back to the start screen, code may be also lost.

    I lost two hours of work yesterday. I suggest everyone until the fix to

    • edit only a little, make sure you saved the part (Hold the run button), click Save & Run

    @Simeon is it possible to add in the next version a save indicator. If your code is saved, at the top show an “Your code is saved” indicator. Also add a force-save button, where code will be saved, if not automatically before.

  • Posts: 1,366
    @Anatoly - some of these bombing incidents seem to be tied to the filing system - such as the sprite selector. I mentioned to @Simeon before about modifications to the file system but he reported no change there. But, have Apple changed the system in their filing libraries? Or have they introduced new issues with the iPadOS launch?
  • I have to admit that I am holding off on most of my projects until this is resolved. It’s unfortunate, considering this is (and I am sure will continue to be) my go-to dev environment for fun at home. I will celebrate when we are past this!

  • edited November 5 Posts: 1,366
    Jump down two - posted on a phone originally which wouldn't let me enter links properly !!!! Dohhhh
  • Posts: 742

    Thanks for this - I'm finding it particularly frustrating of late. Hoping it gets resolved soon

  • Posts: 1,366

    All - just picked up on a techie website that iOS 13 has introduced major bugs, in particular memory management which has caused apps to crash. I assume iPadOS suffers from the same problems. If so, resolution of our recent problems could take a significant time to resolve.

    Link below - not sure how reliable it is.

    Techie Comment

  • AnatolyAnatoly Mod
    Posts: 873

    If code edited, asset picker - opening to edit a shader - crashes the editor.

    Codea is not crashing when opening the shaders lab from the start screen.

  • edited November 8 Posts: 1,366

    @Anatoly - sounds like quite a few members have encountered problems with lost code. I've even seen it with Air code. Suggestion for anyone with a PC or Mac - set out your code in an editor then cut and paste to Air code retain your code in the editor files - messy but at least you retain the code in the text editor.
    No feedback from @Simeon as yet - must be tough problem.

  • Posts: 742

    IOS update installed and no lost code yet. Fingers crossed the issue is resolved.

  • Posts: 1,366

    @West - just installed 13.2.2 but haven’t had chance to check it out yet. Fingers, legs and eyes crossed!!!

Sign In or Register to comment.