pkulchenko / ZeroBraneStudio

Lightweight Lua-based IDE for Lua with code completion, syntax highlighting, live coding, remote debugger, and code analyzer; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and other Lua interpreters on Windows, macOS, and Linux
http://studio.zerobrane.com/
Other
2.61k stars 519 forks source link

Corona interpreter runs main twice #624

Closed abigpotostew closed 8 years ago

abigpotostew commented 8 years ago

Start debugging with corona interpreter seems to run main.lua twice. I can't reproduce with Lua / Lua5.3 interpreters. Using latest dev version on Mac. Mobdebug is not required to reproduce. But you can put a breakpoint in the code with mobdebug running and it will break on that single point twice.

Any program will do it, here's one I used:

local x = 1
local y =x
x = y+1
print('x',x,'y',y)

Output looks like below. Notice how it runs corona twice.

Program starting as '"/Applications/CoronaSDK/Corona Simulator.app/Contents/MacOS/Corona Simulator" -no-console YES -debug 1 -project "/Users/abigpotostew/Downloads/test/main.lua"'.
Program 'Corona Simulator' started in '/Users/abigpotostew/Downloads/test' (pid: 13983).
Apr 03 09:07:47.207: 
Copyright (C) 2009-2015  C o r o n a   L a b s   I n c .
Apr 03 09:07:47.208:    Version: 3.0.0
Apr 03 09:07:47.208:    Build: 2015.2731
Apr 03 09:07:47.254: Platform: iPad / x86_64 / 10.11.3 / NVIDIA GeForce GT 750M OpenGL Engine / 2.1 NVIDIA-10.8.14 310.42.15f01 / 2015.2731
Apr 03 09:07:47.269: Loading project from:   ~/Downloads/test
Apr 03 09:07:47.269: Project sandbox folder: ~/Library/Application Support/Corona Simulator/test-6A0275459F7E690E7A171D1B4EAE2041
Apr 03 09:07:47.316: x  2   y   1
Apr 03 09:07:47.866: 
Copyright (C) 2009-2015  C o r o n a   L a b s   I n c .
Apr 03 09:07:47.867:    Version: 3.0.0
Apr 03 09:07:47.867:    Build: 2015.2731
Apr 03 09:07:47.893: Platform: iPad / x86_64 / 10.11.3 / NVIDIA GeForce GT 750M OpenGL Engine / 2.1 NVIDIA-10.8.14 310.42.15f01 / 2015.2731
Apr 03 09:07:47.906: Loading project from:   ~/Downloads/test
Apr 03 09:07:47.906: Project sandbox folder: ~/Library/Application Support/Corona Simulator/test-6A0275459F7E690E7A171D1B4EAE2041
Apr 03 09:07:47.938: x  2   y   1
Apr 03 09:07:49.752: 
Copyright (C) 2009-2015  C o r o n a   L a b s   I n c .
Apr 03 09:07:49.752:    Version: 3.0.0
Apr 03 09:07:49.752:    Build: 2015.2731
Program stopped (pid: 13983).
Apr 03 09:07:49.786: Platform: iPad / x86_64 / 10.11.3 / NVIDIA GeForce GT 750M OpenGL Engine / 2.1 NVIDIA-10.8.14 310.42.15f01 / 2015.2731
Program completed in 3.16 seconds (pid: 13983).
pkulchenko commented 8 years ago

@abigpotostew, I'm not sure it's caused by the IDE. There used to be a very similar (maybe the same) issue couple of years ago, which was caused by the mechanism in Corona that detected that the application was hanging and restarted it. It was generally happening when running under the debugger and the Corona folks have changed something to avoid that, although I do have some simple logic that attempts to help with this issue in the Corona sample I have:

function onUpdate(event)
  -- let the first call to onUpdate to return quickly;
  -- start the debugging during the second call to trick Corona SDK
  -- and avoid restarting the app.
  if done == nil then done = false return end
  if not done then
    require("mobdebug").start()
    done = true
  end
  ...

I don't remember it ever happening on running the application. Do you have a different version of Corona SDK installed? Or maybe try on their latest nightly build to see if it's fixed there. What if you run the same command from the command line (outside of the IDE)? If the simulator is only started once, it doesn't seem to be related to the IDE.

abigpotostew commented 8 years ago

Can't recreate on latest versions of all my software. thanks