Sublime and Corona - cannot get breakpoints or inspect variable, strange debug behavior

Ok, I have a strange situation here, and as a newbie to both Sublime, Corona, and debugging this in general, it’s very frustrating for me to find answers.  Maybe someone here will know what is wrong or at least what I can do to fix this.

I am on windows 10, and have installed Corona and Sublime to the D drive due to not owning the computer I am working on.  (The owner insists I install everything to this drive instead of C to avoid clashing with them.)

I have installed Sublime 3.0, the Corona plugin for it, and the Corona stable download.  This has resulted in two states for using “Corona”.

State 1:

If I run just Corona Simulator directly, as explained in the balloon tutorial, I can then use Explorer > Sublime to edit files, and view the live update in the simulator.  The problem is that I CANNOT use breakpoints, or Inspect Variable, or basically anything in Sublime that the Corona plugin was supposed to enable.

In this state, the corona editor itself has a console, but I can’t find any good documentation how I would use that console to do any live debugging. 

So in this state I can code and see visual changes but if some bug comes up that isn’t visual or some code isn’t working like I think it is, I have no way to debug it. 

State 2:

If I try to run Sublime first, without the Corona simulator running, I can try using the Corona Editor > Corona Debugger > Run option.  I have already edited the config in the Preferences > Sublime settings user file to have the following change:

,

“corona_sdk_simulator_path”: “D:\Program Files (x86)\Corona Labs\Corona\Corona Simulator.exe”

That fixes the “cannot find simulator” problem I was getting the first time I tried this method.  But now I get the following behaviors:

The first time I hit Run, the simulator does NOT OPEN.  But the code starts stepping through and stops at breakpoints that have been setup.  I can use Sublime Debugging such as Inspect Variable in this state.  But without the simulator window I have no visual on what is happening in the app nor a way to interact with it.

The second time I hit Run, the simulator window will open but will run the ENTIRE code, ignoring any breakpoints and not letting me do anything with sublime’s debugging options such as Inspect Variable.  It seems to be running as if in State 1, except that the console is missing, and if I attempt to open the console in the simulator window the entire simulator will crash terribly.  Sublime itself seems to not detect the simulator running in this state at all, not even marking where in the code the simulator is running.

Running the Run feature a third time will refuse to update the “simulator window”, leaving it running the old version.  But Sublime will respect break points again and let me debug Variables using the Inspect Variable tools again.


I have not used a working version of all the features, but I’m guessing neither of these states is what is expected behavior for the SDK. 

The manual for Corona just vaguely states that all these debugging commands are supposed to be working out of the box, with nothing about troubleshooting them.

How can I “fix” this, so that I can use Sublime text and the debugging commands such as Inspect Variable and breakpoints, but still have the visual feedback of the simulator?  In other words, how can I get both State 1’s visual feedback and State 2’s working debugging breakpoints/variable inspection features?

I don’t know how these tools are supposed to function “normally”, so I don’t know what could be causing this or how to go about fixing the situation.  I need the debugging to be working so I can get work done.  I really don’t want to go into using Corona without a working debugging method for viewing what’s happening in memory during the game.

Where do I begin to unravel this mess?

Further info: Running the application using Corona Editor > Run Project from in sublime:

The simulator launches and runs the application, but the debug modes are ignored and variable inspection does not work.  Furthermore, the simulator is left open and if I use this again two of them are running(and three, and four, and so on).

I finally figured out how to look up the version information for these stuff, so here you go:

Sublime Text Version 3 build 3143

Corona Editor for Sublime Text Version 1.7.3

I’m on Windows 10 64 bit, and both Corona and Sublime are installed to the D drive (C is a solid state):  They are located at the following directories (they are just default directories with a drive letter change, but I will share them for information completion):

D:\Program Files (x86)\Corona Labs\Corona

D:\Program Files\Sublime Text 3

I hope a solution can be found soon.  I’d like to try using Corona for an entry into the git game off jam (https://itch.io/jam/game-off-2017) to learn the engine crash course style.  The jam starts later today, but with the compiler like this I’m not going to get very far once I start needing to debug. :wink:

I don’t know anything about sublime but if you need an ide with a debugger give a try to zerobrane

 I just tried zerobrane.   It’s support for 4K is questionable at best. 

The tool bar icons are way too small to use, and despite maximizing the window screen I can’t seem to fix the issue.  Opening prefs just pulls up some sort of config script to edit, which is no help in making the application usable.  Most of the pop ups, including the debug log, save dialogs, and error messages are also in “post for ants” mode, not scaling up for the 4K screen I’m stuck with on this laptop.

The actual coding tool seems ok from the 10 seconds I tried it.  I just can’t see worth beans in any of the windows due to the font size being too small.  And with the interface the way it is, I have no idea where to click to get it configured or running things for Corona SDK.  Gonna have to say that doesn’t solve the issue. :frowning:

I can’t swap to lower resolutions for reasons of my other artwork software being setup for 4K, and it being a pain to swap back and forth between code and artwork editing.

Besides, Sublime is the supposedly “official” most supported editor.  I’d really rather get that working since I spent all the time configuring it to be readable at 4K already.

@darkgrif, thank you for the feedback on ZeroBrane Studio. Configuring it for Corona should be quite simple: you need to set the interpreter to Corona (Project | Lua Interpreter | Corona) and set the path for the Corona Simulator. In fact, some of the installation locations are supported by default, so if you install you Corona into “D:\Program Files (x86)\Corona Labs\Corona SDK” folder, then no additional configuration will be needed. I’m not sure how “default” is “Corona Labs\Corona” location, but I added it to the list of locations checked.

I don’t have a 4k monitor, so can’t comment on the visual aspects of the UI there, but there are configuration settings to increase the font size in the editor and other windows; the icons can also be set to a larger size, but they need to be packaged with the IDE. I’m looking into scaling the existing icons to make them larger on large screens. I’d appreciate if you could email a screenshot of how it looks on your monitor to paul@zerobrane.com. Thanks.

Paul.

Screenshot sent.

I found the language setting, but am a bit lost on the second part of setting this up where you say to “set the path to Corona Simulator”.  I tried reading the docs for the settings config but I can’t seem to grasp what I would type in the settings conf file to make it work.

Any attempt to run or debug results in an error saying it can’t find the path to Corona SDK.  The installer for Corona installed it to “D:\Program Files (x86)\Corona Labs\Corona”, which isn’t one of the listed places the app is looking in.  So I think all that’s left is to tell the compiler to look there.

Off tangent, but is there a “dark theme” for the program to swap the white for a dark grey or black?  (I suppose using the preferences would help me configure one myself if I knew what I was doing there. :stuck_out_tongue: )

> Screenshot sent.

Got it; thank you. I already have a patch that allows setting the toolbar icons to 48x48, which should improve that aspect of the UI (96 and 64 are also supported, but look a bit ugly as it’s a scaled bitmap, not a separate manually drawn icon). Other icons need to be scaled as well, but this requires a bit more work.

> I found the language setting, but am a bit lost on the second part of setting this up where you say to “set the path to Corona Simulator”.  I tried reading the docs for the settings config but I can’t seem to grasp what I would type in the settings conf file to make it work.

Setting path.corona = "D:\\Program Files (x86)\\Corona Labs\\Corona\\Corona Simulator.exe" should work, but see below for an alternative.

> Any attempt to run or debug results in an error saying it can’t find the path to Corona SDK.  The installer for Corona installed it to “D:\Program Files (x86)\Corona Labs\Corona”, which isn’t one of the listed places the app is looking in.  So I think all that’s left is to tell the compiler to look there.

I added looking in the Corona folder as well, so you can either set path.corona or apply the following patch:

diff --git a/interpreters/corona.lua b/interpreters/corona.lua
index ed748e2…c10b2af 100644
— a/interpreters/corona.lua
+++ b/interpreters/corona.lua
@@ -14,6 +14,7 @@ return {
       local sep = win and ‘;’ or ‘:’
       local default =
            win and (GenerateProgramFilesPath(‘Corona SDK’, sep)…sep…
+                    GenerateProgramFilesPath(‘Corona Labs\Corona’, sep)…sep…
                     GenerateProgramFilesPath(‘Corona Labs\Corona SDK’, sep)…sep)
         or mac and (’/Applications/CoronaSDK/Corona Simulator.app/Contents/MacOS’…sep)
         or ‘’
 

> Off tangent, but is there a “dark theme” for the program to swap the white for a dark grey or black?  (I suppose using the preferences would help me configure one myself if I knew what I was doing there. :stuck_out_tongue: )

Yes, there are several dark schemes, which you can see/test by opening cfg/scheme-picker.lua in the ide. The names of the schemes are clickable links that will change the UI. The example for setting the configuration is in the same file (just change the scheme name). You’ll need to restart the IDE after making the config changes (or run ide:Restart(true) in the console).

Thanks!  I’ve got the configuration set and hitting run opens the corona simulator.  I also set up the dark themes so that will save my eyeballs.  So far, so good.  With a bit of window resizing I’ve managed to get it mostly usable, with the exception of the toolbar and small text size of the file tabs.  It’s functional, and will do for now.

I am still having trouble with debugging. 

ZeroBrane will run the simulator every time, but it seems to be ignoring my breakpoints like Sublime was doing.  The watch window just shows “variable=?” for everything I add a watch to regardless where the actual simulator is in the program as well.  I’ve tried clearing breakpoints and using both Project > Run, Project > Run as Scratchpad, and Project > Start Debugging. 

All three options result in the same behavior, the simulator runs the app but the breakpoints I placed never halt the application to let me inspect anything.

I’m starting to wonder if this is a bug with Corona Simulator itself.  But I’m at a loss where to begin narrowing that down.  Perhaps I will try uninstalling and reinstalling Corona’s SDK later and see if that fixes anything.

> All three options result in the same behavior, the simulator runs the app but the breakpoints I placed never halt the application to let me inspect anything.

@darkgrif, I wonder if you added require(“mobdebug”).start() line to your main.lua script as described here (http://notebook.kulchenko.com/zerobrane/debugging-and-live-coding-with-corona-sdk-applications-and-zerobrane-studio). This would be the only explanation I have (other than something being wrong with the Corona SDK itself, which is unlikely).

If the breakpoints still don’t work, you may want to check this section in the FAQ: https://studio.zerobrane.com/doc-faq#why-breakpoints-are-not-triggered

Paul.

Ok, with this in the top of the script:

require(“mobdebug”).start()

both Sublime and Zerobrane now are halting on the breakpoints.  Thanks for that!

Right now I have been testing both IDEs in the balloon project tutorial.  I put a break point in the pushBalloon function.

In both, the breakpoints now stop the code.  The Corona Simulator wipes to a blank screen while inspecting/halted.  The watch variables seem to function though, letting me inspect data, and pressing Run again will restore the simulator to just after the break triggered.

If I run ZeroBrane in Scratchpad mode, Corona Simulator updates as I change the code.  I believe it’s restarting the application every time, though the balloon game is pretty limited in testing this.

Sublime is…weird, to put it lightly.  It seems random if the simulator even opens when I pick run, and sometimes it tries to run multiple instances of the simulator with each “Debug > Run” operation, even if a previous simulator exists.  I’ve also had Sublime crash/lockup completely if the Corona Simulator is manually closed by me after “Run” is selected.  Other times it just “works” and, aside from the Corona black screen during a break trigger, seems to function just as well as ZeroBrane.

I’m not sure what the standard use of the Simulator is in Sublime, so I may be breaking it myself by doing something stupid.  I’ve been using “Debug > Run”, placing a break point in the Sublime editor, and then using Sublime’s “Inspect Variable” to test if the variables are being read correctly.

I’ve also been stopping the application in Sublime with “Debug > Stop”.  This is where the inconsistent part comes in, sometimes the Corona Simulator will close when this is clicked, but other times Sublime leaves it running in the background, often crashed (clicking it will trigger windows 10’s “this program has crashed” thingy).  I have been manually closing these because otherwise they fill up my task bar with “dead” frozen simulations, but maybe that’s what’s breaking Sublime.  Having never had it work perfectly I have no idea what the correct behavior is or how buggy the simulator is supposed to be “normally”.

If I follow the tutorial way of using Sublime/Zerobrane by opening Corona Simulator directly, of course no connection exists between Sublime or Zerobrane and the simulator window.  So it’s not very useful in this state despite this being the one the tutorial teaches you about, since all the debugging doesn’t work at all.

I’m not sure if anything is wrong with my Sublime setup, but the above behavior with not closing/running the simulator seems quite strange to me, and I doubt it’s how the plugin/addon is supposed to be working.

Regardless, I think for now I will just stick with Zerobrane since that seems to be working.

> If I run ZeroBrane in Scratchpad mode, Corona Simulator updates as I change the code.  I believe it’s restarting the application every time, though the balloon game is pretty limited in testing this.

This shouldn’t be happening. The Corona interpreter in the IDE should only reload the content of the file you are modifying (without aborting the application). You may try on a simple example first just to see how it works (http://notebook.kulchenko.com/zerobrane/debugging-and-live-coding-with-corona-sdk-applications-and-zerobrane-studio; see the last section on Live Coding); I remember there was some logic in the Simulator that was restarting the application after a small delay caused by the scratchpad (as it probably detected it as the application hanging), so I added some logic to avoid this in that example above, so you may do the same thing in your code.

> Regardless, I think for now I will just stick with Zerobrane since that seems to be working.

Sounds good; let me know if you run into any other issues.

Further info: Running the application using Corona Editor > Run Project from in sublime:

The simulator launches and runs the application, but the debug modes are ignored and variable inspection does not work.  Furthermore, the simulator is left open and if I use this again two of them are running(and three, and four, and so on).

I finally figured out how to look up the version information for these stuff, so here you go:

Sublime Text Version 3 build 3143

Corona Editor for Sublime Text Version 1.7.3

I’m on Windows 10 64 bit, and both Corona and Sublime are installed to the D drive (C is a solid state):  They are located at the following directories (they are just default directories with a drive letter change, but I will share them for information completion):

D:\Program Files (x86)\Corona Labs\Corona

D:\Program Files\Sublime Text 3

I hope a solution can be found soon.  I’d like to try using Corona for an entry into the git game off jam (https://itch.io/jam/game-off-2017) to learn the engine crash course style.  The jam starts later today, but with the compiler like this I’m not going to get very far once I start needing to debug. :wink:

I don’t know anything about sublime but if you need an ide with a debugger give a try to zerobrane

 I just tried zerobrane.   It’s support for 4K is questionable at best. 

The tool bar icons are way too small to use, and despite maximizing the window screen I can’t seem to fix the issue.  Opening prefs just pulls up some sort of config script to edit, which is no help in making the application usable.  Most of the pop ups, including the debug log, save dialogs, and error messages are also in “post for ants” mode, not scaling up for the 4K screen I’m stuck with on this laptop.

The actual coding tool seems ok from the 10 seconds I tried it.  I just can’t see worth beans in any of the windows due to the font size being too small.  And with the interface the way it is, I have no idea where to click to get it configured or running things for Corona SDK.  Gonna have to say that doesn’t solve the issue. :frowning:

I can’t swap to lower resolutions for reasons of my other artwork software being setup for 4K, and it being a pain to swap back and forth between code and artwork editing.

Besides, Sublime is the supposedly “official” most supported editor.  I’d really rather get that working since I spent all the time configuring it to be readable at 4K already.

@darkgrif, thank you for the feedback on ZeroBrane Studio. Configuring it for Corona should be quite simple: you need to set the interpreter to Corona (Project | Lua Interpreter | Corona) and set the path for the Corona Simulator. In fact, some of the installation locations are supported by default, so if you install you Corona into “D:\Program Files (x86)\Corona Labs\Corona SDK” folder, then no additional configuration will be needed. I’m not sure how “default” is “Corona Labs\Corona” location, but I added it to the list of locations checked.

I don’t have a 4k monitor, so can’t comment on the visual aspects of the UI there, but there are configuration settings to increase the font size in the editor and other windows; the icons can also be set to a larger size, but they need to be packaged with the IDE. I’m looking into scaling the existing icons to make them larger on large screens. I’d appreciate if you could email a screenshot of how it looks on your monitor to paul@zerobrane.com. Thanks.

Paul.

Screenshot sent.

I found the language setting, but am a bit lost on the second part of setting this up where you say to “set the path to Corona Simulator”.  I tried reading the docs for the settings config but I can’t seem to grasp what I would type in the settings conf file to make it work.

Any attempt to run or debug results in an error saying it can’t find the path to Corona SDK.  The installer for Corona installed it to “D:\Program Files (x86)\Corona Labs\Corona”, which isn’t one of the listed places the app is looking in.  So I think all that’s left is to tell the compiler to look there.

Off tangent, but is there a “dark theme” for the program to swap the white for a dark grey or black?  (I suppose using the preferences would help me configure one myself if I knew what I was doing there. :stuck_out_tongue: )

> Screenshot sent.

Got it; thank you. I already have a patch that allows setting the toolbar icons to 48x48, which should improve that aspect of the UI (96 and 64 are also supported, but look a bit ugly as it’s a scaled bitmap, not a separate manually drawn icon). Other icons need to be scaled as well, but this requires a bit more work.

> I found the language setting, but am a bit lost on the second part of setting this up where you say to “set the path to Corona Simulator”.  I tried reading the docs for the settings config but I can’t seem to grasp what I would type in the settings conf file to make it work.

Setting path.corona = "D:\\Program Files (x86)\\Corona Labs\\Corona\\Corona Simulator.exe" should work, but see below for an alternative.

> Any attempt to run or debug results in an error saying it can’t find the path to Corona SDK.  The installer for Corona installed it to “D:\Program Files (x86)\Corona Labs\Corona”, which isn’t one of the listed places the app is looking in.  So I think all that’s left is to tell the compiler to look there.

I added looking in the Corona folder as well, so you can either set path.corona or apply the following patch:

diff --git a/interpreters/corona.lua b/interpreters/corona.lua
index ed748e2…c10b2af 100644
— a/interpreters/corona.lua
+++ b/interpreters/corona.lua
@@ -14,6 +14,7 @@ return {
       local sep = win and ‘;’ or ‘:’
       local default =
            win and (GenerateProgramFilesPath(‘Corona SDK’, sep)…sep…
+                    GenerateProgramFilesPath(‘Corona Labs\Corona’, sep)…sep…
                     GenerateProgramFilesPath(‘Corona Labs\Corona SDK’, sep)…sep)
         or mac and (’/Applications/CoronaSDK/Corona Simulator.app/Contents/MacOS’…sep)
         or ‘’
 

> Off tangent, but is there a “dark theme” for the program to swap the white for a dark grey or black?  (I suppose using the preferences would help me configure one myself if I knew what I was doing there. :stuck_out_tongue: )

Yes, there are several dark schemes, which you can see/test by opening cfg/scheme-picker.lua in the ide. The names of the schemes are clickable links that will change the UI. The example for setting the configuration is in the same file (just change the scheme name). You’ll need to restart the IDE after making the config changes (or run ide:Restart(true) in the console).

Thanks!  I’ve got the configuration set and hitting run opens the corona simulator.  I also set up the dark themes so that will save my eyeballs.  So far, so good.  With a bit of window resizing I’ve managed to get it mostly usable, with the exception of the toolbar and small text size of the file tabs.  It’s functional, and will do for now.

I am still having trouble with debugging. 

ZeroBrane will run the simulator every time, but it seems to be ignoring my breakpoints like Sublime was doing.  The watch window just shows “variable=?” for everything I add a watch to regardless where the actual simulator is in the program as well.  I’ve tried clearing breakpoints and using both Project > Run, Project > Run as Scratchpad, and Project > Start Debugging. 

All three options result in the same behavior, the simulator runs the app but the breakpoints I placed never halt the application to let me inspect anything.

I’m starting to wonder if this is a bug with Corona Simulator itself.  But I’m at a loss where to begin narrowing that down.  Perhaps I will try uninstalling and reinstalling Corona’s SDK later and see if that fixes anything.

> All three options result in the same behavior, the simulator runs the app but the breakpoints I placed never halt the application to let me inspect anything.

@darkgrif, I wonder if you added require(“mobdebug”).start() line to your main.lua script as described here (http://notebook.kulchenko.com/zerobrane/debugging-and-live-coding-with-corona-sdk-applications-and-zerobrane-studio). This would be the only explanation I have (other than something being wrong with the Corona SDK itself, which is unlikely).

If the breakpoints still don’t work, you may want to check this section in the FAQ: https://studio.zerobrane.com/doc-faq#why-breakpoints-are-not-triggered

Paul.

Ok, with this in the top of the script:

require(“mobdebug”).start()

both Sublime and Zerobrane now are halting on the breakpoints.  Thanks for that!

Right now I have been testing both IDEs in the balloon project tutorial.  I put a break point in the pushBalloon function.

In both, the breakpoints now stop the code.  The Corona Simulator wipes to a blank screen while inspecting/halted.  The watch variables seem to function though, letting me inspect data, and pressing Run again will restore the simulator to just after the break triggered.

If I run ZeroBrane in Scratchpad mode, Corona Simulator updates as I change the code.  I believe it’s restarting the application every time, though the balloon game is pretty limited in testing this.

Sublime is…weird, to put it lightly.  It seems random if the simulator even opens when I pick run, and sometimes it tries to run multiple instances of the simulator with each “Debug > Run” operation, even if a previous simulator exists.  I’ve also had Sublime crash/lockup completely if the Corona Simulator is manually closed by me after “Run” is selected.  Other times it just “works” and, aside from the Corona black screen during a break trigger, seems to function just as well as ZeroBrane.

I’m not sure what the standard use of the Simulator is in Sublime, so I may be breaking it myself by doing something stupid.  I’ve been using “Debug > Run”, placing a break point in the Sublime editor, and then using Sublime’s “Inspect Variable” to test if the variables are being read correctly.

I’ve also been stopping the application in Sublime with “Debug > Stop”.  This is where the inconsistent part comes in, sometimes the Corona Simulator will close when this is clicked, but other times Sublime leaves it running in the background, often crashed (clicking it will trigger windows 10’s “this program has crashed” thingy).  I have been manually closing these because otherwise they fill up my task bar with “dead” frozen simulations, but maybe that’s what’s breaking Sublime.  Having never had it work perfectly I have no idea what the correct behavior is or how buggy the simulator is supposed to be “normally”.

If I follow the tutorial way of using Sublime/Zerobrane by opening Corona Simulator directly, of course no connection exists between Sublime or Zerobrane and the simulator window.  So it’s not very useful in this state despite this being the one the tutorial teaches you about, since all the debugging doesn’t work at all.

I’m not sure if anything is wrong with my Sublime setup, but the above behavior with not closing/running the simulator seems quite strange to me, and I doubt it’s how the plugin/addon is supposed to be working.

Regardless, I think for now I will just stick with Zerobrane since that seems to be working.