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

Linux only: PCLVisualizer.close() does not close the window #172

Closed
tcavallari opened this issue Jul 7, 2013 · 17 comments
Closed

Linux only: PCLVisualizer.close() does not close the window #172

tcavallari opened this issue Jul 7, 2013 · 17 comments

Comments

@tcavallari
Copy link
Contributor

#85 fixed the bug for Windows and MacOS but apparently that is not enough on Linux with vtk 5.8.

A quote from that thread that might help:

I've looked into the pcl code and into some vtk references and it seems to me that the odd Linux behavior depends on a potentially incomplete implementation of the vtkRendererWindowInteractor's specialization for the X environment (I'm not 100% sure about this though, I don't have enough knowledge of the vtk internals).

What makes me think so is the following:
The vtkRendererWindowInteractor's TerminateApp documentation states that the function "should be overridden by platform dependent subclasses to provide a termination procedure if one is required." The Win32 and MacOS versions apparently are doing so but the X version has those "question marks" in the docs. That leaves me thinking that the implementation might have some issues..

Still, I'm not a vtk nor an X programming expert, I honestly have no idea. If someone else wants to take a look at this it might be better...

@rbrusu
Copy link
Member

rbrusu commented Sep 7, 2013

Can we build a small example that we can run to replicate this bug? I'm not familiar with the issue - I always assumed .close () works well.

@tcavallari
Copy link
Contributor Author

The code snippet in #85 should be fine; I'm pasting it here to avoid confusion:

#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>

int main (int argc, char ** argv)
{
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>());
  pcl::io::loadPCDFile("bunny.pcd", *cloud);
  {
    pcl::visualization::PCLVisualizer viewer;
    viewer.addPointCloud(cloud);
    viewer.spin();   // if you press Q the spin loop terminates but
    viewer.close(); // the window does not close, 
    // it remains open and frozen behind the new window
  }
  {
    pcl::visualization::PCLVisualizer viewer;
    viewer.addPointCloud(cloud);
    viewer.spin();
    viewer.close();
  }
  // both windows close now because the program terminates
}

@VictorLamoine
Copy link
Contributor

I have the same problem with the CloudViewer, I posted it on the mailing list few months ago:
http://www.pcl-users.org/Closing-CloudViewer-td4032686.html

I opened an issue on the VTK bug tracker:
http://www.vtk.org/Bug/view.php?id=14985

@KermMartian
Copy link

This bug appears to still be extant. Thanks in advance for any help with it.

@VictorLamoine
Copy link
Contributor

Please append a message to the VTK bug report so that it gains visibility!

http://www.vtk.org/Bug/view.php?id=14985

@giacomodabisias
Copy link
Contributor

Hi,
still no solution to that?

@KermMartian
Copy link

Nope, still no solution that I'm aware of. I bumped the VTK thread, for what it's worth.

@VictorLamoine
Copy link
Contributor

Issue has moved to: https://gitlab.kitware.com/vtk/vtk/issues/14985

@IgniparousTempest
Copy link
Contributor

This has been fixed in 1.8.0: https://gitlab.kitware.com/vtk/vtk/issues/14985

@VictorLamoine
Copy link
Contributor

VictorLamoine commented Sep 4, 2017

  • Works with VTK trunk
  • I did not test with VTK 8.0.1 release
  • Does not work with VTK 8.0 release

I have tested with the latest VTK and PCL trunk; it works.

#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>

int main(void)
{
  {
    pcl::visualization::PCLVisualizer viewer;
    viewer.spin();
    viewer.close();
  }
  {
    pcl::visualization::PCLVisualizer viewer;
    viewer.spin();
    viewer.close();
  }

  return 0;
}

@taketwo
Copy link
Member

taketwo commented Sep 4, 2017

The merge request that fixed the problem in VTK is marked for the 8.0.1 milestone, so I suppose this is the first version that has the problem fixed.

@Kaju-Bubanja
Copy link
Contributor

This bug still seems to exist in some form in 1.9.1. When I run the above test the window does not close. When I use spinOnce instead of spin it closes but only in the test case, and because the whole program closes. When the program doesn't close the window also does not close. I'm using following code:

#include <pcl/visualization/pcl_visualizer.h>

int main(void)
{
  pcl::visualization::PCLVisualizer viewer;
  viewer.spinOnce();
  viewer.close();
  while(true){}
}

I guess this is a bug? Is there a way to close the window with another method or a workaround?

@yifan-hou
Copy link

yifan-hou commented Jul 3, 2020

@Kaju-Bubanja In my case, the line while(true){} was the cause of problem. Immediate pausing after viewer.close() will cause the viewer window to freeze, I don't know why. The code snippet above works for me:

#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>

int main(void)
{
  {
    pcl::visualization::PCLVisualizer viewer;
    viewer.spin();
    viewer.close();
  }
  {
    pcl::visualization::PCLVisualizer viewer;
    viewer.spin();
    viewer.close();
  }

  return 0;
}

I was using pcl1.11 and vtk8.2.

@PerceptMD
Copy link
Contributor

PerceptMD commented Oct 14, 2020

I need to ask for some user input after visualizing clouds but the viewer does not close when quitted.
Setup: PCL1.11 and VTK8.2 on Ubuntu 20.04.
Code to reproduce:

#include <pcl/io/pcd_io.h>
#include <pcl/visualization/pcl_visualizer.h>

int main(void)
{
  {
    pcl::visualization::PCLVisualizer viewer;
    viewer.spin();
    viewer.close();
  } // closes fine
  {
    pcl::visualization::PCLVisualizer viewer;
    viewer.spin();
    viewer.close();
  } // will not close until return 0

	cout << "Input: ";
	cin >> type;
	cout << type;

  return 0;
}

When waiting for a user input the viewer window wont close until the application ends. Any ideas on how to get the viewer window closed before continuing with cin?

When running:

{
	pcl::visualization::PCLVisualizer viewer("viewer1");
	viewer.spin();
	viewer.close();
}
for(int i = 0; i < 100000; i++) {
	std::cout << i;
}
std::cout << std::endl;
{
	pcl::visualization::PCLVisualizer viewer("viewer2");
	viewer.spin();
	viewer.close();
}

also "viewer1" will freeze until the for loop is over.
It seems like the window will only close when a new window is opened or the applications ends.

@vebjornjr
Copy link

Any updates on this? I experience the same behavior as @PerceptMD with PCL 1.11 and VTK 6.3 on Ubuntu 18.04.

@fabrizioschiano
Copy link

fabrizioschiano commented Feb 9, 2022

@vebjornjr , did you figure out how to solve this issue? I have the same problem on Ubuntu 20.04 and vtk7-7.1.1
I need to close the viewer windo manually all the time.

@fabrizioschiano
Copy link

I also tried what is mentioned in #3959 (comment) without success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests