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

gideros live-coding not working on device player #795

Open keszegh opened 7 years ago

keszegh commented 7 years ago

see details here: http://giderosmobile.com/forum/discussion/comment/52568#Comment_52568

pkulchenko commented 7 years ago

@keszegh, I wouldn't expect there to be any difference between remote and local execution for the scratchpad (at least in the case of Gideros integration as currently implemented).

So, is the issue that the editor tab stays read-only, so it's not possible to do any updates? Does the scratchpad actually starts in this case (Scratchpad icon on the toolbar stays selected)?

I also wonder if you have the following two lines in your script before calling start() as suggested in http://notebook.kulchenko.com/zerobrane/gideros-live-coding-a-simple-example:

if initialized then return end
initialized = true
keszegh commented 7 years ago

yes, the editor tab stays read-only. no, the scratchpad does not start. no, I did not have those two lines in my script before start, now i added them but it did not have any effect.

pkulchenko commented 7 years ago

@keszegh, can you start the (remote) debugging as you do normally and then switch to scratchpad? Switching to scratchpad should still be enabled after remote debugging is started.

It's still puzzling that it works locally and doesn't work on the device as from the IDE perspective it's all the same and is taken care by the interpreter code with Gideros integration.

keszegh commented 7 years ago

while debugging is running the sratchpad button is inactive.

just in case, let me write here exactly the code i use for livecoding (mobdebug.lua and socket.lua from zbs folder are added to the project):

[set remote debugging](macro:shell(ide.config.gideros = {remote = "192.168.0.*"})) --ip of android tablet

if initialized then return end initialized = true if pcall(require, 'mobdebug') then require('mobdebug').start("192.168.0.*") --ip of pc end

pkulchenko commented 7 years ago

@keszegh, I can see why it doesn't allow to enable Scratchpad after a regular debugging is started remotely as there is a subtle difference in launching Gideros in "local" and "remote" configurations.

Changing this logic requires allowing scratchpad to be turned on after regular debugging is established, which should make it work in both configurations: when scratchpad is started from the IDE (and remote address is specified) and when the debugging is started remotely and then switched to scratchpad.

Can you try the following patch and let me know if this works for you:

diff --git a/src/editor/menu_project.lua b/src/editor/menu_project.lua
index cdb84be..bd0e22f 100644
--- a/src/editor/menu_project.lua
+++ b/src/editor/menu_project.lua
@@ -312,13 +312,13 @@ frame:Connect(ID_RUNNOW, wx.wxEVT_UPDATE_UI,
   function (event)
     local editor = GetEditor()
     local debugger = ide:GetDebugger()
-    -- allow scratchpad if there is no server or (there is a server and it is
-    -- allowed to turn it into a scratchpad) and we are not debugging anything
+    -- allow scratchpad if there is no server or the current debugger can be turned into
+    -- scratchpad or it's already running scratchpad (so that it can be turned off)
     event:Enable((ide.interpreter) and (ide.interpreter.hasdebugger) and
                  (ide.interpreter.frun ~= nil) and -- nil == no running from this interpreter
                  (ide.interpreter.scratchextloop ~= nil) and -- nil == no scratchpad support
-                 (editor ~= nil) and ((debugger:IsConnected() == nil or debugger.scratchable)
-                 and ide:GetLaunchedProcess() == nil or debugger.scratchpad ~= nil))
+                 (editor ~= nil) and
+                 (debugger:IsConnected() == nil or debugger.scratchable or debugger.scratchpad))
     local isscratchpad = debugger.scratchpad ~= nil
     menuBar:Check(ID_RUNNOW, isscratchpad)
     local tool = ide:GetToolBar():FindTool(ID_RUNNOW)
keszegh commented 7 years ago

it did not enable scratchpad button for me when debugging, not even on desktop debugging.

pkulchenko commented 7 years ago

Hm, interesting. Assuming Gideros is selected as the interpreter, can you run the following command in the console and show me the output after you start debugging locally and remotely:

> !local debugger = ide:GetDebugger(); return ide.interpreter.scratchextloop, debugger:IsConnected() == nil, debugger.scratchable, not not debugger.scratchpad
pkulchenko commented 7 years ago

Also, what if you start scratchpad in remote configuration; does it work?

keszegh commented 7 years ago

local debug paused and command run: true false false false remote debug paused and command run: true false false false

local scratchpad nonpaused: true false false false

when nothing is running then the results are: true true false false

if i run scratchpad in remote conf then it runs but i cannot edit the file while running.

On Tue, Aug 22, 2017 at 7:51 AM, Paul Kulchenko notifications@github.com wrote:

Also, what if you start scratchpad in remote configuration; does it work?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pkulchenko/ZeroBraneStudio/issues/795#issuecomment-323926039, or mute the thread https://github.com/notifications/unsubscribe-auth/ADrLHgUc9Kwdn3VQdCf6Qw9UwtVMEf3_ks5samxogaJpZM4O8RcD .

keszegh commented 7 years ago

any updates on this issue? thanks

pkulchenko commented 7 years ago

Still working on it. I've applied several fixes that I'd expect to eliminate the issue, but they all have some undesirable side-effects, so I'm still working through the options.

keszegh commented 6 years ago

any news about this issue?

pkulchenko commented 6 years ago

@keszegh, yes, I plan to have changes for you to test, but I'm getting close to the release and it is risky to apply them right now.

keszegh commented 6 years ago

understood