From fd5d4539137044c2a13c05315be19bd2d59f04dd Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 25 May 2023 23:17:29 +0200 Subject: [PATCH] Add the option to not wait for tile loading for cases when the WMS server is misbehaving --- include/openspace/interaction/sessionrecording.h | 9 ++++++++- modules/globebrowsing/src/renderableglobe.cpp | 4 +++- src/interaction/sessionrecording.cpp | 9 +++++++-- src/interaction/sessionrecording_lua.inl | 11 ++++++++--- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/include/openspace/interaction/sessionrecording.h b/include/openspace/interaction/sessionrecording.h index 1f8968be04..583cf24ab4 100644 --- a/include/openspace/interaction/sessionrecording.h +++ b/include/openspace/interaction/sessionrecording.h @@ -203,11 +203,15 @@ public: * LuaLibrary entry for SessionRecording for details on these time modes * \param loop if true then the file will playback in loop mode, continuously * looping back to the beginning until it is manually stopped + * \param shouldWaitForFinishedTiles if true, the playback will wait for tiles to be + * finished before progressing to the next frame. This value is only used when + * `enableTakeScreenShotDuringPlayback` was called before. Otherwise this value + * will be ignored * * \return `true` if recording to file starts without errors */ bool startPlayback(std::string& filename, KeyframeTimeRef timeMode, - bool forceSimTimeAtStart, bool loop); + bool forceSimTimeAtStart, bool loop, bool shouldWaitForFinishedTiles); /** * Used to stop a playback in progress. If open, the playback file will be closed, @@ -253,6 +257,8 @@ public: */ bool isSavingFramesDuringPlayback() const; + bool shouldWaitForTileLoading() const + /** * Used to obtain the state of idle/recording/playback. * @@ -743,6 +749,7 @@ protected: bool _saveRenderingDuringPlayback = false; double _saveRenderingDeltaTime = 1.0 / 30.0; double _saveRenderingCurrentRecordedTime = 0.0; + bool _shouldWaitForFinishLoadingWhenPlayback = false; std::chrono::steady_clock::duration _saveRenderingDeltaTime_interpolation_usec; std::chrono::steady_clock::time_point _saveRenderingCurrentRecordedTime_interpolation; double _saveRenderingCurrentApplicationTime_interpolation = 0.0; diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index deddea41b8..fcb58d8020 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -1282,7 +1282,9 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, } _localRenderer.program->deactivate(); - if (global::sessionRecording->isSavingFramesDuringPlayback()) { + if (global::sessionRecording->isSavingFramesDuringPlayback() && + global::sessionRecording->shouldWaitForTileLoading()) + { // If our tile cache is very full, we assume we need to adjust the level of detail // dynamically to not keep rendering frames with unavailable data // After certain number of iterations(_debugProperties.dynamicLodIterationCount) diff --git a/src/interaction/sessionrecording.cpp b/src/interaction/sessionrecording.cpp index 3adfa64eb9..709508f2c5 100644 --- a/src/interaction/sessionrecording.cpp +++ b/src/interaction/sessionrecording.cpp @@ -341,7 +341,7 @@ void SessionRecording::stopRecording() { bool SessionRecording::startPlayback(std::string& filename, KeyframeTimeRef timeMode, bool forceSimTimeAtStart, - bool loop) + bool loop, bool shouldWaitForFinishedTiles) { std::string absFilename; if (std::filesystem::is_regular_file(filename)) { @@ -372,6 +372,7 @@ bool SessionRecording::startPlayback(std::string& filename, _playbackLineNum = 1; _playbackFilename = absFilename; _playbackLoopMode = loop; + _shouldWaitForFinishLoadingWhenPlayback = shouldWaitForFinishedTiles; // Open in ASCII first _playbackFile.open(_playbackFilename, std::ifstream::in); @@ -1048,6 +1049,10 @@ bool SessionRecording::isSavingFramesDuringPlayback() const { return (isPlayingBack() && _saveRenderingDuringPlayback); } +bool SessionRecording::shouldWaitForTileLoading() const { + _shouldWaitForFinishLoadingWhenPlayback; +} + SessionRecording::SessionState SessionRecording::state() const { return _state; } @@ -1857,7 +1862,7 @@ void SessionRecording::moveAheadInTime() { _saveRendering_isFirstFrame = false; return; } - if (isSavingFramesDuringPlayback()) { + if (_shouldWaitForFinishLoadingWhenPlayback && isSavingFramesDuringPlayback()) { // Check if renderable in focus is still resolving tile loading // do not adjust time while we are doing this, or take screenshot const SceneGraphNode* focusNode = diff --git a/src/interaction/sessionrecording_lua.inl b/src/interaction/sessionrecording_lua.inl index 72cdd87266..d09141e07e 100644 --- a/src/interaction/sessionrecording_lua.inl +++ b/src/interaction/sessionrecording_lua.inl @@ -71,7 +71,8 @@ namespace { * stopped. */ [[codegen::luawrap("startPlayback")]] void startPlaybackDefault(std::string file, - bool loop = false) + bool loop = false, + bool shouldWaitForTiles = false) { using namespace openspace; @@ -82,7 +83,8 @@ namespace { file, interaction::KeyframeTimeRef::Relative_recordedStart, true, - loop + loop, + shouldWaitForTiles ); } @@ -102,6 +104,7 @@ namespace { file, interaction::KeyframeTimeRef::Relative_applicationStart, false, + false, false ); } @@ -123,7 +126,8 @@ namespace { file, interaction::KeyframeTimeRef::Relative_recordedStart, false, - loop + loop, + false ); } @@ -142,6 +146,7 @@ namespace { file, interaction::KeyframeTimeRef::Absolute_simTimeJ2000, false, + false, false ); }