Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python debugger becomes unresponsive (windows) #315

Closed
IvanCobotic opened this issue Apr 15, 2024 · 3 comments
Closed

Python debugger becomes unresponsive (windows) #315

IvanCobotic opened this issue Apr 15, 2024 · 3 comments
Assignees
Labels
triage-needed Needs assignment to the proper sub-team

Comments

@IvanCobotic
Copy link

IvanCobotic commented Apr 15, 2024

Type: Bug

Behaviour

Running the following code

import moderngl_window as mglw
import matplotlib

class Test(mglw.WindowConfig):

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

    def render(self, time: float, frametime: float):
        pass

mglw.run_window_config(Test)

with a breakpoint in the init of class Test, i.e. break on super().init(**kwargs), causes the debugger to break on the line, but the debugger becomes unresponsive. Its not possible to enter debug console commands or step the program.

Steps to reproduce:

  1. I isolated the problem to moderngl_window and matplotlib.
    if the import of matplotlib is removed the debugger works as expected.
    I realize im using 2 packages external to VScode to reproduce this error, but my testing shows that the error only occurs on windows (on linux the debugger works fine).
    I also tested with the built in python pdb debugger and the pdb debugger can break in the init function without problem. So even though two external dependencies are used, I believe the issue must be a problem with vscode debugpy on windows.

To reproduce, please run (in a virtual environment)

pip install moderngl-window==2.4.5
pip install matplotlib==3.8.4

my python version is 3.11, Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\python.exe

Diagnostic data

launch.json configuration

"version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: Current File",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "env": {"PYTHONPATH": "${workspaceFolder}/python"}
        },

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

2024-04-15 22:54:55.642 [info] Send text to terminal: �
2024-04-15 22:54:55.642 [info] Send text to terminal:  c:; cd 'c:\mygits\deepose'; & 'c:\mygits\deepose\.venv\Scripts\python.exe' 'c:\Users\IvanL\.vscode\extensions\ms-python.debugpy-2024.4.0-win32-x64\bundled\libs\debugpy\adapter/../..\debugpy\launcher' '52449' '--' 'C:\mygits\deepose\python\experimental\debugger_issue.py' 

Output for Python Debugger in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python Debugger)

2024-04-15 22:53:16.347 [info] DAP Server launched with command: c:\mygits\deepose\.venv\Scripts\python.exe c:\Users\IvanL\.vscode\extensions\ms-python.debugpy-2024.4.0-win32-x64\bundled\libs\debugpy\adapter

# Behaviour

Debugger freezes. Debug console input is ignored and the step/ play etc debug commands stop working.

Extension version: 2024.4.0
VS Code version: Code 1.88.1 (e170252f762678dec6ca2cc69aba1570769a5d39, 2024-04-10T17:41:02.734Z)
OS version: Windows_NT x64 10.0.22631
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.9
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): VirtualEnvironment
System Info
Item Value
CPUs 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz (8 x 2803)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 15.73GB (0.46GB free)
Process Argv --crash-reporter-id 799a61cb-faff-4879-ae9f-0711229a9745
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:30899288
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
pythongtdpath:30769146
welcomedialogc:30910334
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
h48ei257:31000450
pythontbext0:30879054
accentitlementsc:30995553
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
d34g3935:30971562
fegfb526:30981948
bg6jg535:30979843
ccp2r3:30993541
dsvsc020:30976470
pythonait:31006305
jchc7451:30973076
gee8j676:31009558
showvideoc:31016891
dsvsc021:30996838
gd77d436:30999572
0ee40948:31013168

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Apr 15, 2024
@IvanCobotic
Copy link
Author

I made some more testing and found that the freezing of vscode python debugger is related to what backend is used in the matplotlib package. The default backend of matplotlib is QtAgg. If a different backend is used, such as TkAgg

import moderngl_window as mglw
import matplotlib
matplotlib.use('TkAgg')

class Test(mglw.WindowConfig):

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

    def render(self, time: float, frametime: float):
        pass

mglw.run_window_config(Test)

vscode can break correctly on the
super().init(**kwargs)
line.

I can use TkAgg as the backend for matplotlib, so this workaround solves my issue at the moment. It still seems weird to me though that the usage of QtAgg backend in Matplotlib should cause the vscode debugger to become unresponsive.

@paulacamargo25 paulacamargo25 removed the triage-needed Needs assignment to the proper sub-team label May 30, 2024
@paulacamargo25 paulacamargo25 added the triage-needed Needs assignment to the proper sub-team label May 30, 2024
@paulacamargo25
Copy link
Contributor

@int19h do you know what is happening?

@paulacamargo25
Copy link
Contributor

Thanks for your bug report, that is manage by debugpy, could you fill an issue there?

@paulacamargo25 paulacamargo25 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

3 participants