Skip to content

Commit

Permalink
Merge pull request #778 from mwestphal/fix_segfault_progress
Browse files Browse the repository at this point in the history
Fix segfault on reload with progress bar
  • Loading branch information
mwestphal authored Apr 26, 2023
2 parents fab37ca + 44253f6 commit e035ec3
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 14 deletions.
15 changes: 10 additions & 5 deletions application/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# F3D Testing
function(f3d_test)

cmake_parse_arguments(F3D_TEST "DEFAULT_LIGHTS;LONG_TIMEOUT;HDRI;INTERACTION;NO_BASELINE;NO_RENDER;NO_OUTPUT;WILL_FAIL" "NAME;CONFIG;DATA;RESOLUTION;THRESHOLD;REGEXP;REGEXP_FAIL;DEPENDS" "ARGS" ${ARGN})
cmake_parse_arguments(F3D_TEST "DEFAULT_LIGHTS;LONG_TIMEOUT;HDRI;INTERACTION;NO_BASELINE;NO_RENDER;NO_OUTPUT;WILL_FAIL;FORCE_PROGRESS_BAR" "NAME;CONFIG;DATA;RESOLUTION;THRESHOLD;REGEXP;REGEXP_FAIL;DEPENDS" "ARGS" ${ARGN})

if(F3D_TEST_CONFIG)
list(APPEND F3D_TEST_ARGS "--config=${F3D_TEST_CONFIG}")
Expand Down Expand Up @@ -94,6 +94,10 @@ function(f3d_test)
set_tests_properties(f3d::${F3D_TEST_NAME} PROPERTIES FIXTURES_REQUIRED f3d::${F3D_TEST_DEPENDS}_FIXTURE)
endif()

if(F3D_TEST_FORCE_PROGRESS_BAR)
set_tests_properties(f3d::${F3D_TEST_NAME} PROPERTIES ENVIRONMENT "CTEST_PROGRESS_BAR_TESTING=1")
endif()

endfunction()

f3d_test(NAME TestPLY DATA suzanne.ply DEFAULT_LIGHTS)
Expand Down Expand Up @@ -466,6 +470,11 @@ f3d_test(NAME TestInteractionLoadParentDirectory DATA multi/dragon.vtu ARGS --fi
f3d_test(NAME TestInteractionEmptyLoadParentDirectory INTERACTION NO_BASELINE REGEXP "No file loaded, no rendering performed") #Down;
f3d_test(NAME TestInteractionGroupGeometriesLoadParentDirectory DATA mb/mb_0_0.vtu ARGS --group-geometries --filename INTERACTION DEFAULT_LIGHTS) #Down;

# Progress test
f3d_test(NAME TestProgress DATA cow.vtp ARGS --progress NO_BASELINE FORCE_PROGRESS_BAR)
f3d_test(NAME TestProgressScene DATA WaterBottle.glb ARGS --progress NO_BASELINE FORCE_PROGRESS_BAR)
f3d_test(NAME TestInteractionProgressReload DATA cow.vtp ARGS --progress NO_BASELINE FORCE_PROGRESS_BAR INTERACTION) #Up;Up;Up;Up

# Drop file test needs https://gitlab.kitware.com/vtk/vtk/-/merge_requests/9199
if(VTK_VERSION VERSION_GREATER_EQUAL 9.1.20220519) # Drop file test uses stream version 1.2

Expand Down Expand Up @@ -497,10 +506,6 @@ f3d_test(NAME TestOutputNoBackground DATA cow.vtp ARGS --no-background NO_BASELI
f3d_test(NAME TestInteractionRecord DATA cow.vtp ARGS --interaction-test-record=${CMAKE_BINARY_DIR}/Testing/Temporary/interaction.log NO_BASELINE)
f3d_test(NAME TestInteractionPlay DATA cow.vtp ARGS --interaction-test-play=${CMAKE_BINARY_DIR}/Testing/Temporary/interaction.log DEPENDS TestInteractionRecord NO_BASELINE)

# Progress test
f3d_test(NAME TestProgress DATA cow.vtp ARGS --progress NO_BASELINE)
f3d_test(NAME TestProgressScene DATA world.obj ARGS --progress NO_BASELINE)

# Window position test
f3d_test(NAME TestPosition DATA dragon.vtu ARGS --position=100,100 NO_BASELINE)

Expand Down
17 changes: 9 additions & 8 deletions library/VTKExtensions/Rendering/vtkF3DRenderPass.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,7 @@ void vtkF3DRenderPass::ReleaseGraphicsResources(vtkWindow* w)
// ----------------------------------------------------------------------------
void vtkF3DRenderPass::Initialize(const vtkRenderState* s)
{
if (this->InitializeTime == this->MTime)
{
// already initialized
return;
}

this->ReleaseGraphicsResources(s->GetRenderer()->GetRenderWindow());

// Always updates props from the renderstate
this->BackgroundProps.clear();
this->MainProps.clear();

Expand All @@ -94,6 +87,14 @@ void vtkF3DRenderPass::Initialize(const vtkRenderState* s)
}
}

if (this->InitializeTime == this->MTime)
{
// already initialized
return;
}

this->ReleaseGraphicsResources(s->GetRenderer()->GetRenderWindow());

// background pass, setup framebuffer, clear and draw skybox
vtkNew<vtkOpaquePass> bgP;
vtkNew<vtkCameraPass> bgCamP;
Expand Down
3 changes: 2 additions & 1 deletion library/src/loader_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class loader_impl::internals
progressData->timer->StopTimer();
vtkProgressBarWidget* widget = progressData->widget;
// Only show and render the progress bar if loading takes more than 0.15 seconds
if (progressData->timer->GetElapsedTime() > 0.15)
if (progressData->timer->GetElapsedTime() > 0.15 ||
vtksys::SystemTools::HasEnv("CTEST_PROGRESS_BAR_TESTING"))
{
widget->On();
vtkProgressBarRepresentation* rep =
Expand Down
34 changes: 34 additions & 0 deletions testing/recordings/TestInteractionProgressReload.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# StreamVersion 1.1
ExposeEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
KeyPressEvent 354 650 0 0 1 Up
CharEvent 354 650 0 0 1 Up
KeyReleaseEvent 354 650 0 0 1 Up
ExposeEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
KeyPressEvent 354 650 0 0 1 Up
CharEvent 354 650 0 0 1 Up
KeyReleaseEvent 354 650 0 0 1 Up
ExposeEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
KeyPressEvent 354 650 0 0 1 Up
CharEvent 354 650 0 0 1 Up
KeyReleaseEvent 354 650 0 0 1 Up

0 comments on commit e035ec3

Please sign in to comment.