SketchUp / sketchup-extension-vscode-project

VSCode Project for SketchUp Extension Development
MIT License
54 stars 17 forks source link

SketchUp 2021 does not run from vscode via run task #7

Open habermeier opened 3 years ago

habermeier commented 3 years ago

I'm running into a vscode / sketchup issue.

If I try to use run task... from vscode sketchup does not start at all.

If I run skippy sketchup:debug 2021 on the command line, sketchup 2021 does open (but breakpoints do not work).

This public GitHub repo is based on your VSCode Project for SketchUp Extension project -- I have done very little to it yet.

I have installed the latest SketchUp Ruby API Debugger on my Mac.

thomthom commented 3 years ago

Can you provide the output of these two commands please?

skippy -v
skippy sketchup:list

Also, what version of macOS are you using?

habermeier commented 3 years ago

Certainly.

% skippy -v   
Skippy version 0.4.2.a

% skippy sketchup:list
Known SketchUp versions:
  SketchUp 2017   64bit   
  SketchUp 2021   64bit   (debugger)

macOS Catalina, Version 10.15.7

% uname -rsv
Darwin 19.6.0 Darwin Kernel Version 19.6.0: Tue Nov 10 00:10:30 PST 2020; root:xnu-6153.141.10~1/RELEASE_X86_64
thomthom commented 3 years ago

If I run skippy sketchup:debug 2021 on the command line, sketchup 2021 does open (but breakpoints do not work).

That will only start SketchUp with the debugger listening. You also have to attach the debugger from the Run (Formerly Debug) tab in VSCode with the "Listen for rdebug" selected.

thomthom commented 3 years ago

If I try to use run task... from vscode sketchup does not start at all.

What does your tasks.json file look like?

thomthom commented 3 years ago

hm... I was trying to use skippy to launch SketchUp on my mac, but I'm running into errors. I need to sort that out first.

thomthom commented 3 years ago

Ok, got my dev environment corrected.

I also observe that using the tasks from tasks.json doesn't launch SketchUp. I have to look closer that what's going on there.

However, if I start from the terminal, skippy sketchup:debug 2021 and then attach the debugger I will hit the breakpoints I set. Did you attach the debugger after launching SketchUp in debug mode?

thomthom commented 3 years ago

For the sake of testing I also tried to launch another SketchUp version, this time one I didn't have the debugger installed to:

Screenshot 2021-01-18 at 12 06 35

This indicates that skippy is at least starting, but it the fails to launch SketchUp. I don't understand why though, since executing the same command directly in the terminal works fine while via VSCode it fails. Maybe some kind of permission change in Catalina?

thomthom commented 3 years ago

While we figure this out, a workaround is to use a task that starts SU directly:

{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "tasks": [
    {
      "label": "open SU",
      "type": "shell",
      "command": "open",
      "args": [
        "-a",
        "/Applications/SketchUp 2021/SketchUp.app",
        "--args",
        "-rdebug",
        "ide port=7000",
      ],
      "runOptions": {
        "reevaluateOnRerun": false
      },
      "problemMatcher": [],
      "isBackground": false,
    },
    {
      "label": "Launch SketchUp in Ruby Debug mode",
      "type": "shell",
      "command": "skippy",
      "args": [
        "sketchup:debug",
        "${input:sketchupVersion}"
      ],
      "runOptions": {
        "reevaluateOnRerun": false
      },
      "problemMatcher": [],
      "isBackground": false,
    }
  ],
  "inputs": [
    {
      "id": "sketchupVersion",
      "type": "pickString",
      "description": "SketchUp Version",
      "options": [
        "2021",
        "2020",
        "2019",
        "2018",
        "2017"
      ],
      "default": "2021"
    }
  ]
}
habermeier commented 3 years ago

Yep -- that seems to start sketchup. I've not gotten breakpoints to work yet, but I can now start sketchup when I run the task. I admit, this is my first time trying to develop in Sketchup via Visual Code, so maybe I'm missing something very basic.

I was assuming it would be enough for me to set a breakpoint, and run the method, either from the extension drop-down, or from the ruby console, but it doesn't break on the breakpoints that I've set.

thomthom commented 3 years ago

Because the debugging is a remote sessions (since it's running inside SU and not VSCode) we first need to launch SU with the debug command line args to enable the debugger. Then once SU has started you need to attach the debugger (From the Run) tab in VSCode).

Then your breakpoints should trigger when you execute the code with the breakpoint.

Did you attach the debugger after launching SU in your testing?

habermeier commented 3 years ago

I suspect at this point I'm just doing something wrong because I'm new to this environment. After I run the task, I do see the following in the TERMINAL output window:

> Executing task: open -a '/Applications/SketchUp 2021/SketchUp.app' --args -rdebug 'ide port=7000' <

And SU opens, and I can load a model, etc. In VSCode, I do see the Start Debugging option under Run. But once I do that I now see an error message in the DEBUG CONSOLE in VSCode:

Debugger error: Client: Error: connect ECONNREFUSED 127.0.0.1:7000

When looking at my process list:

habermeier-macbookpro2% ps aux | grep -i sketc
habermeier       56184   0.0  0.3  4668252  49524   ??  S    12:13PM   0:00.39 /Applications/SketchUp 2021/SketchUp.app/Contents/Frameworks/SketchUp Helper.app/Contents/MacOS/SketchUp Helper --type=gpu-process --no-sandbox --lang=en-US --log-file=/Users/habermeier/Library/Application Support/SketchUp 2021/WebCache/debug.log --product-version=Chrome/64.0.3282.119 SketchUp Pro/21.0 (Mac) --gpu-preferences=GAAAAAAAAAAAAQAAAQAAAAAAAAAAAGAA --gpu-vendor-id=0x1002 --gpu-device-id=0x7340 --gpu-driver-vendor --gpu-driver-version --gpu-driver-date --gpu-secondary-vendor-ids=0x8086 --gpu-secondary-device-ids=0x3e9b --gpu-active-vendor-id=0x1002 --gpu-active-device-id=0x7340 --amd-switchable --lang=en-US --log-file=/Users/habermeier/Library/Application Support/SketchUp 2021/WebCache/debug.log --product-version=Chrome/64.0.3282.119 SketchUp Pro/21.0 (Mac) --service-request-channel-token=EC32F49931964FC0F6851F232FE340DC
habermeier       56181   0.0  1.7  5744608 288420   ??  S    12:13PM   0:16.09 /Applications/SketchUp 2021/SketchUp.app/Contents/MacOS/SketchUp -rdebug ide port=7000

I see that it appears SketchUp was run with -rdebug ide port=7000, which appears to be what we want, but when I look at all open TCP sockets for the SU processes running, I don't see an open 7000 port that would be listening for connections:

habermeier-macbookpro2% lsof -P -p 56184,56181 -a -i TCP 
COMMAND    PID       USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
SketchUp 56181 habermeier   65u  IPv4 0xd1cff2513ea4a1fb      0t0  TCP macbook-pro.localdomain:63185->lax17s34-in-f19.1e100.net:80 (CLOSED)
SketchUp 56181 habermeier   69u  IPv4 0xd1cff2513bcef45b      0t0  TCP macbook-pro.localdomain:63187->ec2-35-155-205-123.us-west-2.compute.amazonaws.com:443 (CLOSED)
SketchUp 56181 habermeier   77u  IPv4 0xd1cff2513ea47a7b      0t0  TCP macbook-pro.localdomain:63188->server-13-227-73-55.sfo20.r.cloudfront.net:443 (CLOSED)
SketchUp 56181 habermeier   78u  IPv4 0xd1cff251434e7a7b      0t0  TCP macbook-pro.localdomain:63189->lax17s34-in-f19.1e100.net:80 (CLOSED)

Implying that the Sketchup is ignoring the -rdebug command? or something... so, yeah... still no debugging for me!

thomthom commented 3 years ago

Any firewall or anything that could be blocking the ports?

habermeier commented 3 years ago

well... unless I'm getting the commands wrong, I was looking for what processes have an open TCP port 7000... and came up with nothing. Ie: no process is listening on that port. A firewall might prevent a connection from getting made to that port, but it would not prevent a process from starting and listening on that port, right?

I am running this on a corporate Mac, so, there could be something going on from a security perspective, but again -- From the run info I linked above, I'm seeing 2 processes when sketchup starts. The first one: PID: 56181 looks like it's the entry-point / shell that subsequently forks a new process with PID: 56184. I might have expected PID 56181 to pass some argument down to 56184 with the debugging port number, but I'm speculating...

I looked at /Users/habermeier/Library/Application Support/SketchUp 2021/WebCache/debug.log which is kinda busy, but didn't see anything that jumped out at me straight up.

Is there more information I can look up about -rdebug 'ide port=7000'? Seems like something is going wrong somewhere with that....

thomthom commented 3 years ago

Is there more information I can look up about -rdebug 'ide port=7000'? Seems like something is going wrong somewhere with that....

We have the source code here. You could try building it and set a break point to see what happens when it initializes. https://github.com/SketchUp/sketchup-ruby-debugger

I'm more familiar with Windows, so I'm not sure exactly what to suggest. I don't see anything in your setup that raises any flags.

On Windows I would have suggested using ProcessExplorer to inspect whether the Ruby Debugger DLL is in fact loaded. Any are familiar with similar tool for mac?