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

PCLVisualizer tutorial issue on Windows #1601

Open
SergioRAgostinho opened this issue May 4, 2016 · 76 comments
Open

PCLVisualizer tutorial issue on Windows #1601

SergioRAgostinho opened this issue May 4, 2016 · 76 comments

Comments

@SergioRAgostinho
Copy link
Member

There's been some people getting exceptions on the PCLVisualizer tutorial on Windows platforms. More info in threads
http://www.pcl-users.org/Can-t-visualize-normals-Exception-thrown-td4041574.html
http://www.pcl-users.org/Access-Violation-vtkOpenGLBufferObject-GenerateBuffer-enum-vtkOpenGLBufferObject-ObjectType-td4041634.html

@UnaNancyOwen do you mind giving it a try? You're kind of our Windows person :)

@UnaNancyOwen
Copy link
Member

UnaNancyOwen commented May 6, 2016

I have tried the PCLVisualizer tutorial on Windows.

Test results of each command argument is here.
I couldn't identify the error cause.
But, I found that doesn't occur error with to remove the following lines.
The error cause might be on that lines.

command arguments test result doesn't occur error
when comment out this lines
-h operate correctly
-s operate correctly
-r operate correctly
-c operate correctly
-n runtime error #L92
-a runtime error #L117
-v runtime error #L169-170
-i runtime error

Does this tutorial will operate correctly in other environments (Linux, Mac OS)?

@SergioRAgostinho
Copy link
Member Author

Thanks a lot Tsukasa.

On Linux yes, I will try on Mac over the weekend but assume that it does.

I've requested people a bunch of stacktraces but the thing was kind of cryptic. The only thing I know is that the problem is triggered once you request the viewer to spinOnce().

I would also suggest we now start with the addPointCloudNormals, and ver minimal example. Synthesize a 3-point point cloud, compute the normals, see if we can reproduce the error.

@UnaNancyOwen
Copy link
Member

UnaNancyOwen commented May 8, 2016

This runtime error didn't occur when VTK_RENDERING_BACKEND is OpenGL.
There is a possibility that there is a cause of the problem in the OpenGL2 backend support of PCL.
(Probably, "-i" case is another cause.)

command arguments OpenGL2 backend OpenGL backend
-h operate correctly operate correctly
-s operate correctly operate correctly
-r operate correctly operate correctly
-c operate correctly operate correctly
-n runtime error operate correctly
-a runtime error operate correctly
-v runtime error operate correctly
-i runtime error runtime error

From now on, PCL is desirable to be able to use the OpenGL2 backend for performance.
For the reason, I think that this issue is should be solved.

@SergioRAgostinho
Copy link
Member Author

Is the runtime error on the interactive mode, triggered when you start interacting with the mouse or does it happens regardless of the interaction? I've had a crash on Linux on '-i' when I started using the mouse.

@UnaNancyOwen
Copy link
Member

UnaNancyOwen commented May 9, 2016

I've had a crash on Linux on '-i' when I started using the mouse.

That runtime error will occur at the same situation on Windows.
It error will occur when controlled mouse.

@UnaNancyOwen
Copy link
Member

UnaNancyOwen commented May 16, 2016

Does anyone have ideas to solve these errors?
Under the circumstances, Would it be better to use the OpenGL-backend rather than OpenGL2-backend on Windows?

@UnaNancyOwen
Copy link
Member

UnaNancyOwen commented Jun 2, 2016

I have distribute "PCL 1.8.0 RC2 All-in-one Installer" that include VTK OpenGL/OpenGL2 backend for verify this issues.
You can confirm this issues immediately.

@SergioRAgostinho
Copy link
Member Author

Thanks Tsukasa. I'll try to at least sort the bug with the interactive mode before the Hackfest. But I won't be able to sort the issue with the OpenGL2 backend.

@UnaNancyOwen
Copy link
Member

@SergioRAgostinho
Probably, This issues will take more time to resolve because it is only occur on Windows.
I will propose that PCL 1.8.0 pre-built package for Windows should release with OpenGL-backend.

@RobertSpir
Copy link

I don't have any of these crashes with opengl2 backend, only crashing with -i and that is caused because the viewer pointer somehow doesn't get passed to event handlers. When I changed the viewer to global variable, everything works without crashing.

And I think that in this case the tutorial is wrong because it is passing the address of local variable viewer when registering callback (lines 216 and 217)
viewer->registerKeyboardCallback (keyboardEventOccurred, (void*)&viewer);
the variable on that address doesn't exist when the event handler gets called

@RobertSpir
Copy link

oh and another problem on windows is when mixing static and dynamic vtk/pcl libraries, it is causing a lot of crashes. I'm currently using both vtk and pcl libraries as static without problems. It also worked when I was using both as dynamic dll's.

@ShangxuanWu
Copy link

Is this related to addsphere() crash? I am using win10+pcl1.8.0 and when I call addshpere() it always crashes.

@ShangxuanWu
Copy link

Fixed by switching VTK backend from OpenGL2 to OpenGL backend. Hope that PCL (VTK) fix this bug soon.

@bygreencn
Copy link

bygreencn commented Aug 2, 2017

Is this issue continue fixing? addPointCloudNormals still crash with

  1. PCL 1.8.1 rc2
  2. VTK 7.0.0 with opengl backend static version.
  3. MSVC-2013p5

Have run VTK tests, all passed except TestStructuredGridLIC2DYSlice(this is not reason of addPointCloudNormals crash).

the crash reason is:

  • vtkSmartPointer polyData = vtkSmartPointer::New ();
  • this->Device = vtkActor::New();
  • vtkObject* vtkObjectFactory::CreateInstance(const char* vtkclassname)
  • for(vtkObjectFactory::RegisteredFactories->InitTraversal(osit);
    (factory = vtkObjectFactory::RegisteredFactories->
    GetNextObjectFactory(osit));)_

vtkObjectFactory::RegisteredFactories->InitTraversal() got NULL result, which cause the pointer of vtkActor is NULL and the next operation is crashed.

I do not know how to fixed, so...

@YouYue123
Copy link

Recompiling PCL and VTK with OPENGL option works for me. All of the samples under pcl visualisation works for me.

My env is as ::

  1. MacOS 10.13.1 (17B1003)
  2. PCL 1.8.0
  3. VTK 8.0.0
  4. cmake 3.10.0
  5. Apple LLVM version 9.0.0 (clang-900.0.39.2) x86_64-apple-darwin17.2.0

I wrote a resolve solution

https://youyue123.github.io/tech/2018/01/19/Fix-Add-Normal-Crash-Bug-for-PCL.html

Hope next release of PCL could consider this issue and make a progressive way by leveraging OPENGL2 performance bonus and some regression bug.

@SergioRAgostinho
Copy link
Member Author

SergioRAgostinho commented Jan 22, 2018

I wrote a resolve solution

https://youyue123.github.io/tech/2018/01/19/Fix-Add-Normal-Crash-Bug-for-PCL.html

I went through your blog post but didn't exactly see any solution posted, just instructions for building PCL and selecting the VTK rendering engine. Nevertheless if you have indeed solved it, please consider submitting a pull request.

@bygreencn
Copy link

After more debugging, I could confirm that almost more reasons about addPointCloudNormals crashed at Windows is cauesed by User that he does not operate completely by this rule of "How Implementation Modules Are Initialized at VTK/Build System Migration" .

Put the following definition before the code will fix almost all of them:
#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL); //if render backen is OpenGL2, it should changes to vtkRenderingOpenGL2
VTK_MODULE_INIT(vtkInteractionStyle);
VTK_MODULE_INIT(vtkRenderingFreeType);
VTK_MODULE_INIT(vtkRenderingVolumeOpenGL); //if render backen is OpenGL2, it should changes to vtkRenderingVolumeOpenGL2

@SergioRAgostinho
Copy link
Member Author

@bygreencn Thanks for digging that up. We now have some pointers on what to look for.

@taketwo How about we migrate the default rendering engine to OpenGL 2 and see how it goes during the RC?

@taketwo
Copy link
Member

taketwo commented Aug 31, 2018

I'm not sure what you mean. Backend version is a property of VTK installation that the user has, we have no control over it.

@SergioRAgostinho
Copy link
Member Author

Tsukasa controlled it in its all in one installer. I mixed concepts and thought we were setting it ourselves somehow.

@taketwo
Copy link
Member

taketwo commented Sep 1, 2018

Oh, I see what you mean. But what would this bring? We already know that OpenGL 2 on Windows causes problems. Having a bunch of people try pre-compiled library and report this again won't help.

I think we rather need a Windows person who knows how to compile PCL to figure out what's wrong with VTK_MODULE_INIT. From the link posted by @bygreencn I gather we either need these inits either in the source code, or in compiler definitions. As far as I understand, in PCL we go the latter way and on Linux it works smoothly. When I build against VTK with old backend I get a bunch of AUTOINIT options like this inserted into the compiler flags:

-DvtkRenderingContext2D_AUTOINIT="1(vtkRenderingContextOpenGL)"

And when compiling against VTK with OpenGL 2 backend, the version number in these options is changed accordingly:

-DvtkRenderingContext2D_AUTOINIT="1(vtkRenderingContextOpenGL2)" 

@UnaNancyOwen
Copy link
Member

Can this issue be add in pcl-1.9.0 milestone?
The recent versions of VTK display many warning against will be removed OpenGL backend in near future.
In fact, this merge request has already been merged to VTK.
I think it's about time we should be fix this issue in this version.
I will report update the latest status of this issue in the near days.

@SergioRAgostinho
Copy link
Member Author

SergioRAgostinho commented Sep 29, 2018

👍 Jump on it. I'll be cleaning up things on the other topics.

Edit: Don't forget to confirm that the VTK definitions are being passed properly to the tutorial.

@SergioRAgostinho SergioRAgostinho added this to the pcl-1.9.0 milestone Sep 29, 2018
@claudiofantacci
Copy link
Contributor

I can also make test on Windows (but only during work days).
Let me know if you need any 👍

@SergioRAgostinho
Copy link
Member Author

Any updates on this?

@UnaNancyOwen
Copy link
Member

UnaNancyOwen commented Oct 4, 2018

Update Status (pcl-master ac27a0d)
I think that normals is suspicious.

command arguments test result
-h operate correctly
-s operate correctly
-r operate correctly
-c operate correctly
-n runtime error
-a runtime error
-v runtime error
-i operate correctly

@larshg
Copy link
Contributor

larshg commented Aug 1, 2019

I think we simply can't integrate static VTK into dynamic PCL dlls.

If I compile PCL static as well, all works as expected.

I did find a flag for g++ like this, which maybe could have solved the issue, but I haven't found a equivalent for MSVC - nor if it matters for MSVC.

It seems that some functions is not correctly found (NULL pointers) - depending on the code layout - but I'm almost guessing now as its way beyond my knowledge of compiler and linking.

Regards Lars

@UnaNancyOwen
Copy link
Member

UnaNancyOwen commented Sep 2, 2019

It will take time to fully resolve this issue.
However, We may need to next release without waiting for this issue to be resolved.
We would choose to release pre-built PCL with dynamic linked VTK as a temporary solution in that case.
I propose adding (temporarily) a script that adds the VTK path (PCL_ROOT/3rdParty/VTK/bin) to the environment variable in install process of PCL All-in-one Installer.

  • pcl/cmake/Modules/NSIS.template.in
diff --git a/cmake/Modules/NSIS.template.in b/cmake/Modules/NSIS.template.in
index 09e8aa4a5..471e2756b 100644
--- a/cmake/Modules/NSIS.template.in
+++ b/cmake/Modules/NSIS.template.in
@@ -735,6 +735,13 @@ Section "-Add to path"
   StrCmp $DO_NOT_ADD_TO_PATH "1" doNotAddToPath 0
     Call AddToPath
   doNotAddToPath:
+  ; This is temporary solution for issue #1601.
+  Push $INSTDIR\3rdParty\VTK\bin
+  StrCmp "ON" "ON" 0 doNotAddVTKToPath
+  StrCmp $DO_NOT_ADD_TO_PATH "1" doNotAddVTKToPath 0
+  StrCmp $VTK_selected "0" doNotAddVTKToPath 0
+    Call AddToPath
+  doNotAddVTKToPath:
 SectionEnd
 
 ;--------------------------------
@@ -900,6 +907,12 @@ Section "Uninstall"
   StrCmp $DO_NOT_ADD_TO_PATH_ "1" doNotRemoveFromPath 0
     Call un.RemoveFromPath
   doNotRemoveFromPath:
+  ; This is temporary solution for issue #1601.
+  Push $INSTDIR\3rdParty\VTK\bin
+  StrCmp $DO_NOT_ADD_TO_PATH_ "1" doNotRemoveVTKFromPath 0
+  StrCmp $VTK_was_installed "0" doNotRemoveVTKFromPath 0
+    Call un.RemoveFromPath
+  doNotRemoveVTKFromPath:
 SectionEnd
 
 ;--------------------------------

What do you think?

@taketwo
Copy link
Member

taketwo commented Sep 3, 2019

This sounds like the most reasonable approach. Do you know if there are any deficits or potential problems if we go this way?

@UnaNancyOwen
Copy link
Member

UnaNancyOwen commented Sep 3, 2019

I think there's nothing. It just add/remove the VTK path for temporary solution.
I have already tested this installer/uninstaller on my environment. It works correctly without problem which option choose.

  C:\Program Files\PCL\bin
+ C:\Program Files\PCL\3rdParty\VTK\bin

Also, It means we are ready to generate and publish the PCL 1.10.0 All-In-One Installer (that include pre-built PCL with dynamic linked VTK as a temporary solution for this issue).

UnaNancyOwen added a commit to UnaNancyOwen/pcl that referenced this issue Sep 3, 2019
Add install and uninstall process to add and remove VTK path to environment variables PATH.
This is temporary solution for issue PointCloudLibrary#1601.
@didory123
Copy link

I'm not sure if this is the right place to make further comments, but for anyone else working with PCL on Windows who had been searching for a solution to this issue:

I had to add the following lines

#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL);

to a cpp source file before including any other vtk libraries (meaning that these lines need to go before say, the PCL visualization module which itself includes the VTK libraries) as per explained in this vtk migration guide page. However, this means that you can't use precompiled headers to include the PCL modules that do use vtk, so you'll have to find some other workaround for that.

@stale
Copy link

stale bot commented Jun 9, 2020

Marking this as stale due to 30 days of inactivity. It will be closed in 7 days if no further activity occurs.

@stale stale bot added the status: stale label Jun 9, 2020
@kunaltyagi
Copy link
Member

@UnaNancyOwen does this issue only occur with deprecated OpenGL bindings? If so, we can consider the "temporary" solution as a bit more permanent (and close this issue). If it occurs with OpenGL2 bindings too, then we need to continue looking for solutions.

@stale stale bot removed the status: stale label Jun 9, 2020
@UnaNancyOwen
Copy link
Member

UnaNancyOwen commented Jun 9, 2020

@kunaltyagi It works fine with OpenGL1 rendering backend that deprecated/removed option in VTK, but it not works fine with OpenGL2 rendering backend that built as a static linking library.
It has been worked around by linking VTK that built as a dynamic linking library as temporary workaround. (As a bad side effects, developers have to attached many many dependent dll files of VTK when they distribute their applications.)

@kunaltyagi
Copy link
Member

it not works fine with OpenGL2 rendering backend

Oh. That's the reverse of expected situation. Got it 😄

@kunaltyagi
Copy link
Member

Bumping off milestones due to lack of activity

@kunaltyagi kunaltyagi removed this from the pcl-1.11.1 milestone Aug 6, 2020
@AndreV84
Copy link

@UnaNancyOwen is there a recent PCL for windows release?

@UnaNancyOwen
Copy link
Member

@AndreV84 The latest version of PCL All-in-one Installer has been published now! Please see release page.

@Cras1990
Copy link

The latest version of PCL All-in-one Installer has been published now! Please see release page.

@UnaNancyOwen I tried with pcl-1.11.1 all in one installer and I´m still having issue:

image
image

and many more such errors concering vtk dll files.

Has a solution for this kind of issues been already found? I cannot run visualizer in windows because of this. Or is my issue comming from something different?
Thanks in advance.

@UnaNancyOwen
Copy link
Member

@Cras1990 The pre-built PCL are use dynamically linked VTK. Therefore, You need to add %PCL_ROOT%\3rdParty\VTK\bin to environment variable PATH of your system. Please read the log of this issue. #1601 (comment)

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

No branches or pull requests