cmcpasserby / MayaCharm

Maya integration for PyCharm.
MIT License
177 stars 44 forks source link

Debugger Not working , breakpoint not riggered #32

Closed sevelee closed 5 years ago

sevelee commented 5 years ago

pycharm version: 2018.3 mayacharm version: 3.0.1 maya version: 2018

I can execute file to maya var run/debug configurations in pycharm. But breakpoint just not work. The breakpoints won't trigger. I comes with: image

image image

sevelee commented 5 years ago

I also have pycharm 2018.2.7 I changed back to it and use mayacharm 2.1.6, use mayacharm debugger and it works. So I think there is something wrong with pycharm 2018.3.5 and mayacharm 3.0.1 image

cmcpasserby commented 5 years ago

wont be able to look into things till the weekend, but yes newer versions of PyCharm removed the api the old version of MayaCharm uses so the 3.x versions are a complete rewrite that takes a very different approach to debugging.

Old version was hooking into the Remote Debugger of PyCharm Pro, new version is attaching to the local process directly.

sevelee commented 5 years ago

I also re-install my pycharm 2018.3.1 and mayacharm 3.0.0 to test but I just won't trigger the breakpoint.. image But I remember It should be work a few weeks ago, I have a memory that I used pycharm 2018.3 to debug some code.

Thanks for your contribution to this plugin 😄

cmcpasserby commented 5 years ago

yeah when i get home and take a look at it again, i might need to get you to test a few things, i only have access to older versions of maya

sevelee commented 5 years ago

Fell free to contact me for any testing. I have accesss to maya 2017 and 2017+ here.

cmcpasserby commented 5 years ago

so it looks to be working in my end with Maya 2016 PyCharm 2018.3 and the 3.0.1 version of the plugin.

can you show me what your settings panel for MayaCharm looks like, as well as your interpreter setup and run Config.

also try running Run>Attach to process... and tell me if your maya instance displays there and if it can attach that way.

sevelee commented 5 years ago

test with pyCharm 2018.3.5 and maya 2018, mayaCharm 3.0.1

  1. setting panel for mayaCharm: image
  2. interpreter setup: image
  3. run config image
  4. if I run "Attach to process...": image
  5. Still not work now ...
cmcpasserby commented 5 years ago

i can't recreate often, but i have a few times now. looks to be a bit of a race condition. where the command to execute code happens before the debugger si fully attached. noticed it only happens with simple scripts something more complex where i need to interact in maya before hitting a break point works.

so in a future version i will need to listen to see when Maya is ready, or add a longer delay(right now its 500ms)

sevelee commented 5 years ago

Is there a way that I can change 500ms to a longer time locally (in my computer) so that I can have a test?

cmcpasserby commented 5 years ago

not currently, it is a hard coded value but i am looking into a better way then just waiting. Also i don't think it would solve all of your issues, since manually attaching from the run menu also does not work for you.

sevelee commented 5 years ago

Well. I didn't change anything and works now. Looking for your next version to fix this. Thanks

cmcpasserby commented 5 years ago

yeah been too busy to spend any serious time on the plug-in. But for now the best work around is using Attach To Process... waiting for that to complete then clicking run on your config.

Its happening because right after attach, a bit of python code is executed to setup PyDev, and the code to execute in the process is running before that PyDev setup has returned.

can see what is going on, in these 2 files MayaCharmDebugRunner.kt MayaCharmDebugProcess.kt

more or less afterConnect gets called way to early.

being a timing issue doing a manual attach to process... should work before running your code. The plugin adds hooks into attach to process... so it sees Maya like a normal python process.

sevelee commented 5 years ago

I get it. image A little weird thing now is that sometimes the "Process finished with exit code 0 Server stopped." comes very quick so that I need to click run config very quick 😭

cmcpasserby commented 5 years ago

yeah there is some weirdness with Maya not always accepting it, when i get time i want to fix both of these issues, and make it so you can hit debug and it "just works" consistently but hard to find the time when i do primarily work with Maya or Python anymore

sevelee commented 5 years ago

I will see if I have sometime to change and test this plugin on my computer 👍

ManaDork commented 5 years ago

Question: Having an inability to hit breakpoints also: Tried multiple versions of PyCharm and MayaCharm based on combinations that people have reported success with and haven't been having much luck. Running Maya 2018.5 (and wondering if its the culprit?)

If the console reports the Server stopped, when manually attaching to a Maya Process, that would mean that debug won't work? (noob to IDE's)

dseeni commented 5 years ago

I also have pycharm 2018.2.7 I changed back to it and use mayacharm 2.1.6, use mayacharm debugger and it works. So I think there is something wrong with pycharm 2018.3.5 and mayacharm 3.0.1

I can confirm this works for me as well. Whew. I'm pretty new to all of this, so it's nice to have a working set up at least. Very useful plugin, hopefully a fix can be made with out to much trouble at some point.

cmcpasserby commented 5 years ago

this issue seems mostly tied to a race condition and only happens when debugging via a run configuration.

for now i am removing support for attaching the debugger via run config and just letting people do it manually via Run/Attach to Process... since it is more consistent and does not have the Maya code execute too early