Howdy, Stranger!

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

Air Code Bug

edited August 2013 in Bugs Posts: 59

It wouldn't save what I put on air code. Is it supposed to not save?

Comments

  • Posts: 1,976

    No. Did you exit the Codea app to close it, and did you close your browser before Codea?

  • I'm not sure, but anyways now it always says there was an error creating server, even when I'm on wifi.

  • Posts: 157

    I have found that AirCode can get confused and basically stop updating pretty frequently. It looks to me like an Alpha-quality feature that's mostly just for seeing how it works at this point; I wouldn't rely on it until it's a bit more stable.

  • Posts: 90

    I think I know what the problem is (but it's still a bug). If you don't notice compile errors in one tab when you move to another one, then come back, AirCode (helpfully?) reverts the code in the first tab back to the last known working state. Never leave a tab with erroneous syntax--fix it with legal Lua or comment it out before switching tabs. AirCode doesn't report an erroneous tab like the code editor does (it should).

    It probably has something to do with Codea trying to keep your program running at all times, even while you're revising it. That aspect is helpful when you're debugging the draw loop, because you can see your changes on-screen in real-time, but in other situations, not so much, particularly when it loses the code in the process. I'd rather it'd work like the code editor in that regard--highlight the tab in error and show a message at the line in error--the code editor doesn't try to "fix" anything.

    There may be other situations, too, but the above is easily replicated.

  • edited August 2013 Posts: 1,976

    @Simeon Video. That supposed to happen?

  • Posts: 90

    Nice, concise demo, @SkyTheCoder.

  • SimeonSimeon Admin Mod
    Posts: 5,716

    @SkyTheCoder @starblue Air Code intentionally does not save / attempt to execute invalid code. If the code cannot be loaded into the Lua runtime, it is not saved to the project.

  • Ok

  • Posts: 90

    @Simeon. It's fine that the code isn't saved to the runtime on the iPad, but why does that mean blitzing it in the browser? After all, one is trying to modify it to get it to run successfully, and having it vanish on you doesn't advance that goal.

    In the video, what if the user had just typed in a 100-line function rather than a line of garbage and then went back to the main tab to create the call to it and then ran the program? It fails, he goes back to the tab to fix the bug, except...

    I consider it to be a bug, but since there's a ready workaround, even I don't consider it high priority to fix. But when you run of things to do :-) you might want to reconsider.

  • SimeonSimeon Admin Mod
    Posts: 5,716

    @starblue that's a good point. The original intention of Air Code was to make instantaneous changes to an already-running project. The idea being to see code changes live.

    I can see how someone making large scale changes could find this behaviour unpleasant. I'll try to find a solution to it.

  • beebee
    Posts: 381

    @simeon: Why does it have to be a live action? Why not just put a run/play button so user can run the program at wish? Just like the regular editor. Or provide an option so user could select whether AirCode to run live or not. A good automation is good on some cases but it can be annoying at other cases.

  • Posts: 90

    @Simeon 's idea isn't bad, just different, with benefits of its own. I don't see it as an either-or thing--why can't it be live yet leave the code in the browser alone? Maybe the current implementation makes it hard to do, but it seems doable. Right now, though, his idea just comes through as buggy. That's what I'm asking him to review.

  • Posts: 90

    I've discovered another problem with the current implementation. If one types in valid code that puts you into an infinite loop, you can't regain control in either AirCode or Codea. (Aside: I think triple-tap is supposed to break out of loops, but I have that set to zoom the screen via Apple's Accessibility feature.) Even if you abort Codea (via the iPad's "wiggle dance"), restart it, and invoke AirCode again, you're put right back into your infinite loop (it's valid code, remember). The only way to regain control is to restart Codea and go into the code editor to fix the code causing the infinite loop. This could be construed as an argument to not run live from AirCode. If AirCode could issue an "abort" signal to stop the interpreter, I don't see that we have to scrap the "live" feature.

  • edited August 2013 Posts: 1,976

    My Codea is still frozen.

    I didn't show in there, but even after I removed the while true loop it's still frozen.

    Triple-tapping with three fingers isn't doing anything, either.

  • Try exiting Codea and double tapping the home button. A little thing should come up at the bottom of the screen. Hold down on the Codea icon until a little red thing comes up in the corner. Tap the red thing. Then go back into Codea. It should be fixed. Just remove the while true statement. Now it should not freeze.(doing all this will restart Codea. You can do this with other apps to if they are freezing.)

  • Posts: 90

    When AirCode becomes frozen due to an infinite loop, typing further into the browser is futile. The browser window is still active, and you can type whatever you want into it, but Codea's WiFi link has been lost (or at least it can't look for it while caught in the loop).

  • Posts: 1,976

    @EpicPotato I know how to restart an app, I was just saying what should work that didn't.

    @starblue Apparently.

  • SimeonSimeon Admin Mod
    Posts: 5,716

    @SkyTheCoder this is not related to Air Code. Running an infinite loop in Codea is going to cause issues.

    We used to have a default instruction limit set to avoid these issues. If you would like to use that, please call setInstructionLimit( 10000000 ) in setup(). We stopped this default behaviour because hitting an instruction limit was more problematic than running into infinite loops.

  • Posts: 90

    @Simeon, did you see above where I discussed where an infinite loop causes problems with AirCode because, since it's valid code, even if you get out of Codea, come back, and restart AirCode, you're back in the loop. It's starting to look more and more like there needs to be a mode where you're not running live while in AirCode.

    An alternative, though specific to this case, is that when you enter AirCode, live mode is off until the first Ctrl-R--that gives a window where one can fix the infinite loop. A third option is to implement a live mode on/off switch as @bee described, with the default as "off".

    Incidentally, what is the command to interrupt the program and return to the code editor? Where is it documented? The "Getting Started" box on the front page would be a good place to mention it.

  • SimeonSimeon Admin Mod
    Posts: 5,716

    @starblue yes, I did see that. The instruction limit solution should prevent this behaviour in Air Code, too. (We can re-enable an instruction limit as default behaviour but I don't like that.)

    There is no way to interrupt your program during an infinite loop because it runs on the main thread. While it would be possible to run the Lua interpreter in a different thread and queue all drawing commands on the main thread, I am unsure of how that would effect performance (it would also be a big rewrite).

    If you suspect you might inadvertently construct an infinite loop I suggest using setInstructionLimit to prevent it from locking up interaction. You can then remove it when you are confident in your code.

  • Posts: 90

    @Simeon, no, I don't want an execution limit. (My current project is a program to do data collection over a period of hours--I don't want it to die at hour 7 and lose everything.) I'm just saying that a switch to set live-ness on/off may be useful to have in AirCode after all.

    Incidentally, although this thread may seem to indicate otherwise, I think AirCode is the best thing to happen for development in Codea since Zagg Bluetooth keyboards. It's a bit rough around the edges currently (I've been keeping a list of things that could be made smoother) but I use it almost exclusively now and only revert back to the code editor for things you just can't do in AirCode yet (like tab management). It's a great idea you had there (apart from Codea itself, of course)!

  • SimeonSimeon Admin Mod
    edited August 2013 Posts: 5,716

    @starblue I am not suggesting the instruction limit for your actual release code, just for while you are working / debugging so you don't stumble into an infinite loop — if you are expecting that to be a problem. (The instruction limit should also be reset each draw call, so it shouldn't matter how long your program runs so long as you don't perform a massive series of operations in a single draw call.)

  • xenxen
    Posts: 2

    I have similar problem with Air Code, it is a bit annoying. I can't "trust" interface because it is invisible for user what it behind user don't see feedback. Another unintuitive thing that when I switch between tabs it is not always that I completed my changes, often it is impossible to have working state of your code between changes. For example during refactoring, when you are moving code from one tab to another. You cut code and then switch between tabs and see that Codea rollback your changes.

    iPad interface isn't best, Air Code supposed to help here, but in current state AC doesn't fix that. I very like Codea, and very thankful for this great product, but this part just doesn't work.

  • SimeonSimeon Admin Mod
    Posts: 5,716

    @xen you are correct — it definitely needs to save your changes regardless of whether they run. I'll be making it do that in the future.

  • Jmv38Jmv38 Mod
    Posts: 3,297

    @Simeon please, do NOT re-introduce instructionlimit by default. None of my project would work and i would have to add instructionlimit(0) in all of them. I dont have any problems due to the current settings.

Sign In or Register to comment.