f3d-app / f3d

Fast and minimalist 3D viewer.
https://f3d.app
BSD 3-Clause "New" or "Revised" License
2.88k stars 207 forks source link

--no-render is not correctly taken into account when used with the default configuration #1087

Closed chenrui333 closed 8 months ago

chenrui333 commented 11 months ago

👋 while trying to rebuild f3d 2.2.1 against vtk 9.3, I ran into some test failure as shown below:

==> /opt/homebrew/Cellar/f3d/2.2.1_1/bin/f3d --verbose --no-render --geometry-only /private/tmp/f3d-test-20231205-97965-nnec4d/test.obj 2>&1
sh: line 1: 97976 Segmentation fault: 11  /opt/homebrew/Cellar/f3d/2.2.1_1/bin/f3d --verbose --no-render --geometry-only /private/tmp/f3d-test-20231205-97965-nnec4d/test.obj 2>&1
Loading plugin "alembic"
  Version: 1.0
  Description: Alembic support (version 1.8.6)
  Readers:
    Alembic
Loading plugin "assimp"
  Version: 1.0
  Description: Assimp support (version 5.3.0)
  Readers:
    Filmbox
    Collada
    AutoCAD DXF
    Object File Format
Loading plugin "exodus"
  Version: 1.0
  Description: VTK Exodus support
  Readers:
    Exodus II
Loading plugin "native"
  Version: 1.0
  Description: Native VTK I/O support
  Readers:
    Autodesk 3D Studio
    CityGML
    DICOM
    GL Transmission Format
    MetaImage
    Nearly Raw Raster Data
    Wavefront OBJ
    Polygon
    Point Cloud
    Standard Triangle Language
    TIFF
    VRML
    VTK Legacy
    VTK XML UnstructuredGrid
    VTK XML PolyData
    VTK XML ImageData
    VTK XML RectangularGrid
    VTK XML StructuredGrid
    VTK XML MultiBlock
Loading plugin "occt"
  Version: 1.0
  Description: OpenCASCADE support (version 7.7.2)
  Readers:
    STEP ISO 10303
    Initial Graphics Exchange Specification
    Open CASCADE BRep
Using config file /opt/homebrew/Cellar/f3d/2.2.1_1/share/f3d/configs/config.d
Loading: /private/tmp/f3d-test-20231205-97965-nnec4d/test.obj

No animations available in this file

Animation(s) time range is: [inf, -inf].
No camera available in this file

=== test.obj ===
Number of points: 3
Number of polygons: 1
Number of lines: 0
Number of vertices: 0
0 point data array(s):
1 cell data array(s):
  GroupIds : float : 0
0 field data array(s):

Axis widget cannot be shown without an interactor
No array to color with
/opt/homebrew/Library/Homebrew/ignorable.rb:29:in `block in raise'
Minitest::Assertion: Expected: 0
  Actual: 139

It looks like the vtk 9.3 is supported now, https://github.com/f3d-app/f3d/pull/1068. Any chance of cutting off a new release? Thanks!

relates to https://github.com/Homebrew/homebrew-core/pull/154232

Meakk commented 11 months ago

We are planning a new release early January. We are very close to wrap up the USD plugin which is the last feature we want to add for 2.3

chenrui333 commented 11 months ago

noted, thanks for the update!

Also if you know which commits I can include for fixing the vtk 9.3 compatibility, that would help unblocking that brew PR.

mwestphal commented 11 months ago

We did not merge anything related to VTK 9.3 support. So far I'm unable to reproduce any issue with F3D 2.2.1 with VTK 9.3.0.

I wonder if new dependency were added in your VTK 9.3 package that could be detrimental to F3D somehow. Could you provide more info, a stacktrace maybe ?

cho-m commented 11 months ago

Maybe one thing to try for reproduction is run same command after deleting cache directory/file. Alternatively, run in a separate env with a temporary HOME (which is how brew's test runs).

In my experience, the above lead to segfaults with --no-render.


With VTK 9.3.0, I get following stacktrace:

Process 71724 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00000001045a4d28 libvtkRenderingOpenGL2-9.3.1.dylib`vtkOpenGLRenderWindow::ActivateTexture(this=0x0000000000000000, texture=0x00006000007cb840) at vtkOpenGLRenderWindow.cxx:2431:9
   2428 //------------------------------------------------------------------------------
   2429 void vtkOpenGLRenderWindow::ActivateTexture(vtkTextureObject* texture)
   2430 {
-> 2431   this->GetState()->ActivateTexture(texture);
                ^
   2432 }
   2433
   2434 //------------------------------------------------------------------------------
Target 0: (f3d) stopped.
bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x00000001045a4d28 libvtkRenderingOpenGL2-9.3.1.dylib`vtkOpenGLRenderWindow::ActivateTexture(this=0x0000000000000000, texture=0x00006000007cb840) at vtkOpenGLRenderWindow.cxx:2431:9
    frame #1: 0x0000000104652368 libvtkRenderingOpenGL2-9.3.1.dylib`vtkTextureObject::Allocate2D(this=0x00006000007cb840, width=512, height=512, numComps=2, vtkType=5, level=0) at vtkTextureObject.cxx:1795:18
    frame #2: 0x000000010460ff98 libvtkRenderingOpenGL2-9.3.1.dylib`vtkPBRLUTTexture::Load(this=0x000000014fe667a0, ren=0x000000015084a600) at vtkPBRLUTTexture.cxx:57:26
    frame #3: 0x0000000100c82394 libf3d.2.dylib`vtkF3DCachedLUTTexture::Load(this=0x000000014fe667a0, ren=0x000000015084a600) at vtkF3DCachedLUTTexture.cxx:26:30
    frame #4: 0x0000000100ca4394 libf3d.2.dylib`vtkF3DRenderer::ConfigureHDRILUT(this=0x000000015084a600) at vtkF3DRenderer.cxx:819:14
    frame #5: 0x0000000100ca3908 libf3d.2.dylib`vtkF3DRenderer::ConfigureHDRI(this=0x000000015084a600) at vtkF3DRenderer.cxx:635:11
    frame #6: 0x0000000100ca72a8 libf3d.2.dylib`vtkF3DRenderer::UpdateActors(this=0x000000015084a600) at vtkF3DRenderer.cxx:1341:9
    frame #7: 0x0000000100cd3650 libf3d.2.dylib`vtkF3DRendererWithColoring::UpdateActors(this=0x000000015084a600) at vtkF3DRendererWithColoring.cxx:572:21
    frame #8: 0x0000000100c6101c libf3d.2.dylib`f3d::detail::window_impl::UpdateDynamicOptions(this=0x0000600003ac0970) at window_impl.cxx:349:30
    frame #9: 0x0000000100c476cc libf3d.2.dylib`f3d::detail::loader_impl::internals::LoadGeometry(this=0x0000600000acc870, name="test.obj", source=0x00006000001da220, reset=true) at loader_impl.cxx:168:18
    frame #10: 0x0000000100c47170 libf3d.2.dylib`f3d::detail::loader_impl::loadGeometry(this=0x0000600003ad0150, filePath="/***/test.obj", reset=true) at loader_impl.cxx:233:20
    frame #11: 0x00000001000ac570 f3d`F3DStarter::LoadFile(this=0x000000016fdff780, index=0, relativeIndex=false) at F3DStarter.cxx:536:20
    frame #12: 0x00000001000aac4c f3d`F3DStarter::Start(this=0x000000016fdff780, argc=5, argv=0x000000016fdff9f8) at F3DStarter.cxx:299:9
    frame #13: 0x00000001000b463c f3d`main(argc=5, argv=0x000000016fdff9f8) at main.cxx:13:19
    frame #14: 0x0000000184a9d0e0 dyld`start + 2360

I also tried patching in https://github.com/Kitware/VTK/commit/817df022695fafdd5ce0a8ace597637e4378dad9 since it added a few extra return when there is no render window.

This led to another stacktrace:

Process 17094 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x0000000100ca5274 libf3d.2.dylib`(anonymous namespace)::SaveTextureToImage(tex=0x0000000000000000, target=3553, level=0, size=512, type=5) at vtkF3DRenderer.cxx:109:31
   106    unsigned int dims[2] = { size, size };
   107    vtkIdType incr[2] = { 0, 0 };
   108
-> 109    unsigned int nbFaces = tex->GetTarget() == GL_TEXTURE_CUBE_MAP ? 6 : 1;
                                      ^
   110
   111    vtkNew<vtkImageData> img;
   112    img->SetDimensions(size, size, nbFaces);
Target 0: (f3d) stopped.
bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x0000000100ca5274 libf3d.2.dylib`(anonymous namespace)::SaveTextureToImage(tex=0x0000000000000000, target=3553, level=0, size=512, type=5) at vtkF3DRenderer.cxx:109:31
    frame #1: 0x0000000100ca4400 libf3d.2.dylib`vtkF3DRenderer::ConfigureHDRILUT(this=0x000000015b05e200) at vtkF3DRenderer.cxx:824:43
    frame #2: 0x0000000100ca3908 libf3d.2.dylib`vtkF3DRenderer::ConfigureHDRI(this=0x000000015b05e200) at vtkF3DRenderer.cxx:635:11
    frame #3: 0x0000000100ca72a8 libf3d.2.dylib`vtkF3DRenderer::UpdateActors(this=0x000000015b05e200) at vtkF3DRenderer.cxx:1341:9
    frame #4: 0x0000000100cd3650 libf3d.2.dylib`vtkF3DRendererWithColoring::UpdateActors(this=0x000000015b05e200) at vtkF3DRendererWithColoring.cxx:572:21
    frame #5: 0x0000000100c6101c libf3d.2.dylib`f3d::detail::window_impl::UpdateDynamicOptions(this=0x000060000352cec0) at window_impl.cxx:349:30
    frame #6: 0x0000000100c476cc libf3d.2.dylib`f3d::detail::loader_impl::internals::LoadGeometry(this=0x000060000052d320, name="test.obj", source=0x0000600000e2fb80, reset=true) at loader_impl.cxx:168:18
    frame #7: 0x0000000100c47170 libf3d.2.dylib`f3d::detail::loader_impl::loadGeometry(this=0x0000600003523810, filePath="/***/test.obj", reset=true) at loader_impl.cxx:233:20
    frame #8: 0x00000001000ac570 f3d`F3DStarter::LoadFile(this=0x000000016fdff780, index=0, relativeIndex=false) at F3DStarter.cxx:536:20
    frame #9: 0x00000001000aac4c f3d`F3DStarter::Start(this=0x000000016fdff780, argc=5, argv=0x000000016fdff9f8) at F3DStarter.cxx:299:9
    frame #10: 0x00000001000b463c f3d`main(argc=5, argv=0x000000016fdff9f8) at main.cxx:13:19
    frame #11: 0x0000000184a9d0e0 dyld`start + 2360
mwestphal commented 11 months ago

So I've just build VTK 9.3.0, F3D 2.2.1 on my macOS and I'm able to run the following command without any issue:

f3d cow.vtp --no-render

The stach you are providing points to F3D being used without --no-render in a environnement that does not have a graphical environnement or something similar.

Please provide more precises steps to reproduce @chenrui333 @cho-m .

FYI, I have no idea what " run in a separate env with a temporary HOME (which is how brew's test runs)." means.

mwestphal commented 10 months ago

ping @chenrui333 @cho-m ?

mwestphal commented 9 months ago

2.3.0 is out, closing.

chenrui333 commented 9 months ago

@mwestphal sorry about the late reply, trying it now.

chenrui333 commented 9 months ago

Sorry about the late reply, I can still see some test failure, error log in here, https://github.com/Homebrew/homebrew-core/actions/runs/7773611929/job/21197540326?pr=154232

==> Testing f3d
  ==> /opt/homebrew/Cellar/f3d/2.3.0_1/bin/f3d --verbose --no-render --geometry-only /private/tmp/f3d-test-20240204-1409-a75ao9/test.obj 2>&1
  sh: line 1:  1420 Segmentation fault: 11  /opt/homebrew/Cellar/f3d/2.3.0_1/bin/f3d --verbose --no-render --geometry-only /private/tmp/f3d-test-20240204-1409-a75ao9/test.obj 2>&1
  ========== Initializing ==========
  Loading plugin "alembic"
    Version: 1.0
    Description: Alembic support (version 1.8.6)
    Readers:
      Alembic
  Loading plugin "assimp"
    Version: 1.0
    Description: Assimp support (version 5.3.0)
    Readers:
      Filmbox
      Collada
      AutoCAD DXF
      Object File Format
      DirectX File Format
      3D Manufacturing Format
  Loading plugin "exodus"
    Version: 1.0
    Description: VTK Exodus support
    Readers:
      Exodus II
  Loading plugin "native"
    Version: 1.0
    Description: Native VTK I/O support
    Readers:
      Autodesk 3D Studio
      CityGML
      DICOM
      GL Transmission Format
      MetaImage
      Nearly Raw Raster Data
      Wavefront OBJ
      Polygon
      Point Cloud
      Standard Triangle Language
      TIFF
      VRML
      VTK Legacy
      VTK XML UnstructuredGrid
      VTK XML PolyData
      VTK XML ImageData
      VTK XML RectangularGrid
      VTK XML StructuredGrid
      VTK XML MultiBlock
  Loading plugin "occt"
    Version: 1.0
    Description: OpenCASCADE support (version 7.7.2)
    Readers:
      STEP ISO 10303
      Initial Graphics Exchange Specification
      Open CASCADE BRep
  Using config file /opt/homebrew/Cellar/f3d/2.3.0_1/share/f3d/configs/config.d
  ========== Configuring engine ==========
  Engine configured
  ========== Loading 3D file ==========
  Loading 3D geometry: /private/tmp/f3d-test-20240204-[140](https://github.com/Homebrew/homebrew-core/actions/runs/7773611929/job/21197540326?pr=154232#step:3:141)9-a75ao9/test.obj

  No animations available in this file

  Animation(s) time range is: [inf, -inf].
  No camera available in this file

  === test.obj ===
  Number of points: 3
  Number of polygons: 1
  Number of lines: 0
  Number of vertices: 0
  0 point data array(s):
  1 cell data array(s):
    GroupIds : float : 0
  0 field data array(s):

  Axis widget cannot be shown without an interactor
  No array to color with
  ERROR: In vtkPBRLUTTexture.cxx, line 35
  vtkF3DCachedLUTTexture (0x12ce6eca0): No render window.

  Error: f3d: failed
  An exception occurred within a child process:
    Minitest::Assertion: Expected: 0
chenrui333 commented 9 months ago

Axis widget cannot be shown without an interactor No array to color with ERROR: In vtkPBRLUTTexture.cxx, line 35 vtkF3DCachedLUTTexture (0x12ce6eca0): No render window.

maybe test needs to be updated?

mwestphal commented 9 months ago

I think you just found a bug (--no-render + --hdri).

mwestphal commented 9 months ago

So after testing and reproducing on my side, a quick fix should be to add

--axis=0 --hdri-ambient=0 to your test.

In any case, we have an issue to fix.

mwestphal commented 9 months ago

I wish we had fixed this for 2.3.0 though, at least you have a work around for now @chenrui333