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

Can NOT close PCLVisualizer #3959

Open
lihk11 opened this issue Apr 22, 2020 · 10 comments
Open

Can NOT close PCLVisualizer #3959

lihk11 opened this issue Apr 22, 2020 · 10 comments
Labels
help wanted kind: bug Type of issue module: visualization needs: feedback Specify why not closed/merged yet skill: vtk Skills/areas of expertise needed to tackle the issue

Comments

@lihk11
Copy link

lihk11 commented Apr 22, 2020

Can NOT close PCLVisualizer

As a thread on Stackoverflow said,

" I am writing a program to record and store pointclouds. Part of the programs function to observe the recorded clouds, for this I use the PCL visualizer. The problem is that if I close the visualizers window the window just stops, but won't close. I tried calling the close() method, but nothing. I read that this was a problem before VTK 8.0, but I use 8.1 and the problem is still there. I also use PCL 1.9.1 and Ubuntu 18.04. Anyone has a solution for this? Thanks in advance. "

And I am experiencing the very same problem, could someone give some workarounds?

Code to reproduce the problem:

#include <pcl/visualization/pcl_visualizer.h>

#include <iostream>

int main(void) {
    pcl::visualization::PCLVisualizer viewer;
    while (!viewer.wasStopped()) {
        viewer.spinOnce();
    }
    viewer.close();
    std::cout << "closed!" << std::endl;
    while (true) {
    }
}

OS: Ubuntu 18.04
gcc:(Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
VTK: 8.2.0
pcl: 1.9.1 or 1.10.1

@lihk11 lihk11 added kind: bug Type of issue status: triage Labels incomplete labels Apr 22, 2020
@SergioRAgostinho
Copy link
Member

It originally sounded like a duplicate of #172 but with the VTK version you're using, you should no longer have that problem. :/

@lihk11
Copy link
Author

lihk11 commented Apr 22, 2020

@SergioRAgostinho I have investigated #172 , and tried every solution that issue mentioned, but my problem still unsolved...
According to the last comment given by @Kaju-Bubanja the problem still exists...

@lihk11
Copy link
Author

lihk11 commented Apr 22, 2020

And I am pretty sure that the pcl library has been linked to VTK 8.2.0
the ldd output of libpcl_visualization.so

→ ldd libpcl_visualization.so
	linux-vdso.so.1 (0x00007fff46fcf000)
	libboost_filesystem.so.1.71.0 => /usr/local/lib/libboost_filesystem.so.1.71.0 (0x00007f7e67a2e000)
	libboost_thread.so.1.71.0 => /usr/local/lib/libboost_thread.so.1.71.0 (0x00007f7e6780a000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f7e675eb000)
	libpcl_io.so.1.9 => /usr/local/lib/libpcl_io.so.1.9 (0x00007f7e67265000)
	libpcl_kdtree.so.1.9 => /usr/local/lib/libpcl_kdtree.so.1.9 (0x00007f7e66f2f000)
	libvtkIOPLY-8.2.so.1 => /usr/local/lib/libvtkIOPLY-8.2.so.1 (0x00007f7e66d16000)
	libvtkRenderingContextOpenGL2-8.2.so.1 => /usr/local/lib/libvtkRenderingContextOpenGL2-8.2.so.1 (0x00007f7e66ae5000)
	libvtkRenderingLOD-8.2.so.1 => /usr/local/lib/libvtkRenderingLOD-8.2.so.1 (0x00007f7e668d6000)
	libvtkViewsContext2D-8.2.so.1 => /usr/local/lib/libvtkViewsContext2D-8.2.so.1 (0x00007f7e666ca000)
	libvtkRenderingGL2PSOpenGL2-8.2.so.1 => /usr/local/lib/libvtkRenderingGL2PSOpenGL2-8.2.so.1 (0x00007f7e664b8000)
	libvtkRenderingOpenGL2-8.2.so.1 => /usr/local/lib/libvtkRenderingOpenGL2-8.2.so.1 (0x00007f7e66086000)
	libvtkChartsCore-8.2.so.1 => /usr/local/lib/libvtkChartsCore-8.2.so.1 (0x00007f7e65cce000)
	libvtkRenderingContext2D-8.2.so.1 => /usr/local/lib/libvtkRenderingContext2D-8.2.so.1 (0x00007f7e65a8c000)
	libvtkInteractionWidgets-8.2.so.1 => /usr/local/lib/libvtkInteractionWidgets-8.2.so.1 (0x00007f7e655f5000)
	libvtkImagingSources-8.2.so.1 => /usr/local/lib/libvtkImagingSources-8.2.so.1 (0x00007f7e653a3000)
	libvtkFiltersModeling-8.2.so.1 => /usr/local/lib/libvtkFiltersModeling-8.2.so.1 (0x00007f7e65111000)
	libvtkIOImage-8.2.so.1 => /usr/local/lib/libvtkIOImage-8.2.so.1 (0x00007f7e64d80000)
	libvtkInteractionStyle-8.2.so.1 => /usr/local/lib/libvtkInteractionStyle-8.2.so.1 (0x00007f7e64b2f000)
	libvtkFiltersExtraction-8.2.so.1 => /usr/local/lib/libvtkFiltersExtraction-8.2.so.1 (0x00007f7e6482f000)
	libvtkRenderingAnnotation-8.2.so.1 => /usr/local/lib/libvtkRenderingAnnotation-8.2.so.1 (0x00007f7e6450a000)
	libvtkImagingCore-8.2.so.1 => /usr/local/lib/libvtkImagingCore-8.2.so.1 (0x00007f7e6409c000)
	libvtkRenderingFreeType-8.2.so.1 => /usr/local/lib/libvtkRenderingFreeType-8.2.so.1 (0x00007f7e63df1000)
	libvtkRenderingCore-8.2.so.1 => /usr/local/lib/libvtkRenderingCore-8.2.so.1 (0x00007f7e639e1000)
	libvtkCommonColor-8.2.so.1 => /usr/local/lib/libvtkCommonColor-8.2.so.1 (0x00007f7e637c3000)
	libvtkFiltersSources-8.2.so.1 => /usr/local/lib/libvtkFiltersSources-8.2.so.1 (0x00007f7e6351a000)
	libvtkFiltersGeneral-8.2.so.1 => /usr/local/lib/libvtkFiltersGeneral-8.2.so.1 (0x00007f7e62fe8000)
	libvtkFiltersCore-8.2.so.1 => /usr/local/lib/libvtkFiltersCore-8.2.so.1 (0x00007f7e6285c000)
        ...

@lihk11
Copy link
Author

lihk11 commented Apr 26, 2020

Any updates?

@kunaltyagi kunaltyagi added the needs: feedback Specify why not closed/merged yet label Apr 26, 2020
@yifan-hou
Copy link

yifan-hou commented Jul 3, 2020

@lihk11 I had the same problem with pcl 1.11 and vtk 8.2. It turns out the problem is caused by the immediate pause (the while loop) after viewer.close().

#include <pcl/visualization/pcl_visualizer.h>

#include <iostream>

int main(void) {
    pcl::visualization::PCLVisualizer viewer1("viewer1");
    while (!viewer1.wasStopped()) {
        viewer1.spinOnce();
    }
    viewer1.close();
    while (true) {} // if you remove this line, the close will be successful

    pcl::visualization::PCLVisualizer viewer2("viewer2");
    // now you can see two viewer windows. However,
    // if you comment out the while(true) line,
    // there should be only one window now.
    while (!viewer2.wasStopped()) {
        viewer2.spinOnce();
    }
    viewer2.close();
}

Beside while(true){}, a getchar() can also cause the same problem. It seems like the visualizer needs a flushing mechanism, something like viewer.flush().

@lihk11
Copy link
Author

lihk11 commented Jul 3, 2020

I don't think the problem is caused by inmmediate pause. A window will always remain before the whole program exits.
It looks like after calling "viewer.close()", PCL or VTK does not release those window-related resources before the corresponding thread ends.
Besides, I gave up using PCL, but wrote an osg based viewer for visualizing point clouds.

@yifan-hou
Copy link

I see, that's a slightly different problem. I don't know if the last window will stay till the program exits.

My case is that I need to draw and inspect different things in a loop; after 100 loops, I would end up with 99 dead windows.... So I basically can not do large loops. Now this problem is fixed, the window in each loop can close before the next loop starts.

@kunaltyagi kunaltyagi added help wanted skill: vtk Skills/areas of expertise needed to tackle the issue labels Jul 3, 2020
@tpham3783
Copy link

any news?

is there a way to hide the window then?

@larshg
Copy link
Contributor

larshg commented Oct 25, 2022

@tpham3783 What OS / PCL version do you use?

@huanglilong
Copy link
Contributor

huanglilong commented Dec 7, 2022

this issue fix by updating VTK(9.2 or master) and rebuild PCL with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted kind: bug Type of issue module: visualization needs: feedback Specify why not closed/merged yet skill: vtk Skills/areas of expertise needed to tackle the issue
Projects
None yet
Development

No branches or pull requests

7 participants