Open3D icon indicating copy to clipboard operation
Open3D copied to clipboard

open3d.visualization crashing Python interpreter

Open noahstier opened this issue 6 years ago • 28 comments

Description

Creating a matplotlib window after using o3d.visualization.draw_geometries crashes the Python interpreter with the following error message:

X Error of failed request:  BadWindow (invalid Window parameter)
Major opcode of failed request:  15 (X_QueryTree)
Resourc eid in failed request:  0x3e000a7
Serial number of failed request:  1360
Current serial number in output stream:  1360

To Reproduce

  1. open the o3d visualization window
  2. close it
  3. open a matplotlib window
  4. close it
import open3d as o3d
import matplotlib.pyplot as plt

pc = o3d.geometry.PointCloud(o3d.utility.Vector3dVector(np.random.rand(2, 3)))
o3d.visualization.draw_geometries([pc]) # close it
fig = plt.figure() # close it

Environment Ubuntu 18.04 Python 3.7.6 Open3D 0.9.0.0 Not a remote workstation Installed Open3D with pip

Additional Information My interpreter crashes all the time a few statements after using open3d.visualization. This is just the one example I've found that does it consistently.

noahstier avatar Apr 16 '20 17:04 noahstier

I can also confirm this, just happened to me. Same environment as the described above.

ManuelZ avatar Apr 26 '20 05:04 ManuelZ

I am having a problem reproducing this, whether I install open3d via pip or compile master branch. Can you follow along the commands I did for pip install: https://gist.github.com/pvarvak/34e813af82c4660bc8b914d33338c7f3 and for compiling master branch: https://gist.github.com/pvarvak/a95b01e761874d8156fe4e7f012b3205 and put up gist with what your output was? (If you run into compilation issues, please check https://github.com/intel-isl/Open3D/blob/master/docs/compilation.rst that appropriate dependencies have been installed, including virtualenv and python-pip)

pvarvak avatar Apr 29 '20 03:04 pvarvak

I figured out a fix, at least for my situation.

Background: I use ipython --pylab tk primarily as my interactive interpreter. This conveniently imports numpy and matplotlib, and sets matpotlib to interactive mode, but it also does some other stuff, I'm not sure what exactly.

I discovered that I don't get the crashing bug if I don't use the --pylab tk option. According to this thread, using pylab is not recommended anyway.

So as a workaround / improvement to my current setup, I changed my ipython alias from ipython --pylab tk to ipython --matplotlib, and I copied pylab's imports into ~/.ipython/profile_default/startup/imports.py:

    import numpy
    import matplotlib
    from matplotlib import pylab, mlab, pyplot
    np = numpy
    plt = pyplot

    from IPython.display import display
    from IPython.core.pylabtools import figsize, getfigs

    from pylab import *
    from numpy import *

So I still get automatic interactive mode and imports, but without whatever else --pylab tk was doing, and my crashes related to open3d are fixed.

noahstier avatar Apr 29 '20 19:04 noahstier

Gah I just got another crash even with the changes I described above... If I can find another way to consistently reproduce the crash I'll post it.

noahstier avatar Apr 29 '20 21:04 noahstier

I have also stumbled into this problem. For me it was caused by performing it in the opposite order. I.e. matplotlib followed by o3d.

SebastianGrans avatar May 27 '20 06:05 SebastianGrans

Same problem, I've tried both way (matplotlib followed by o3d and inverse) and both pop out the error. I'm also using open3d 0.9 by pip install. System: Ubuntu16.04

maggielovedd avatar Sep 26 '20 02:09 maggielovedd

Sorry, can't help, but I get this Error too:(

In my application i have a while loop showing something in Open3d then poping up a tkinter dialog. It is running for two iterations then always crahes with the given X Error above.

I have also noticed that when I want to use matplotlib after a visualization by Open3d the error appears too. Guess because it builds on tkinter.

My System is running Ubuntu16.04 with open3d 0.9 installed via pip. Anyone knows a fix? I would really appreciate it.

zaksel avatar Oct 01 '20 14:10 zaksel

Same thing happening to me. Tried installing open3d via pip and conda and used different versions of python, crashes every time.

Sterris avatar Dec 02 '20 13:12 Sterris

same here

harishkashyap avatar Dec 22 '20 00:12 harishkashyap

same here when running visualizer in non blocking mode and trying to halt at a break point in python postmortem debugger from command line (python3 -mpdb myo3dvisualizerscirpt.py . As soon as postmortem debugger swiches X window to interactive mode visualizers crashes with bad window as if it tries to render to commandline window instead of its own viewer window. Assumingly it does for sake of speed not check if the window it tries to draw to or manipulate is still the active window in the the main thread. Strangely when switching focus to openCV.imshow window crash does not happen. Just when some console input from interactive python command line is to be expected.

Not in all but many cases when X bad window exception occurs is that commandline window has to be reset by entering reset instruction to get proper output and input on commandline window again. So visualizer must change paramaters it assues it does on its own window which effectively go to the commandline window.

This also occurs when python script in non blocking visualizer mode expects some input from commandline and window is switched to commandline window to input some text.

open3d still seems to use glfw 3.3.0 dev over at glfw they had after that several issues related to bad window events (eg.: 1633, 1620) when changing window coordinates and other window parameters on decoration less windows like the visualizer window. maybe updating glfw to 3.3.1 or later might solve this issue.

hernot avatar Mar 03 '21 12:03 hernot

Same condition. I am trying to show the images (using either plt.show or cv2.imshow()) along draw_geoemtry. The open3d window crashes every time.

szx0112 avatar Sep 22 '21 20:09 szx0112

I meanwhile switched to visualization.O3DVisualizer with running the gui thread in back ground. And sending all draw commands via visualization.O3DVisualizer.send_to_main_thread to the background thread. With this setup everything works as expected from visualizer. The only issue is when finishing python or trying to restart in debugger that for now a core dump is generated which could easily be solved when there would exists a reset function as oposit to initialize to fully deinitialize and reset gui system as reported in feature requrest #3914.

hernot avatar Sep 24 '21 07:09 hernot

Hello I'm having the same problem here - i.e. a X BadWindow error when running pyplot.show() after having ran open3d.draw_geometries. @hernot could you elaborate a bit more on how you solved it on your side ? I could live with a workaround for a while.

sebastienchappuis avatar Oct 25 '21 15:10 sebastienchappuis

@sebastienchappuis I doe not use open3d.visualization.draw_* and functions and open3d.visualize.visualizer* classes any more. I coded my own viewer using open3.visualize.gui or better open3d.visualize.O3DVisualizer class which is based thereon. A still buggy version (*) thereof you can find as attachment to issue #3914. But as the issue says there is still a crash when the program finishes and you get an exception when restarting the debugger. But at least debugging is possible without BadWindow errors.

(*) had not yet the time to upload the latest version where i have fixed a few more bugs.

hernot avatar Oct 26 '21 06:10 hernot

@hernot thank you for your help, I'll look into your solution :)

sebastienchappuis avatar Oct 26 '21 07:10 sebastienchappuis

Is this still an issue in the newest version of Open3d using the new visualization API?

germanros1987 avatar Dec 03 '21 06:12 germanros1987

Even though, see above, not using old visualization any more, I guess if all visualization.draw_functions and viewers use in the background the new filament based GUI it may be assumed that this is not an issue any more. In some of them still use home brew GL code than this issue still stays.

hernot avatar Dec 03 '21 12:12 hernot

Similar issue here as @hernot describted above.

Environment: Ubuntu 18.04 Python 3.8 Open3D 0.13 Not a remote workstation Installed Open3D with pip

  • visualizer crashes with X Error of failed request: BadWindow (invalid Window parameter) when trying to set a breakpoint.
  • O3DVisualizer works, and thus all draw commands work.

This seems to be related to the GLFW issue hernot pointed to.

mli0603 avatar Dec 13 '21 16:12 mli0603

I have the same problem

domef avatar Sep 26 '22 07:09 domef

any update?

domef avatar Dec 09 '22 16:12 domef