diff --git a/profiler/src/profiler/TracyView_FrameTimeline.cpp b/profiler/src/profiler/TracyView_FrameTimeline.cpp index 83ee1b1c..e56123fe 100644 --- a/profiler/src/profiler/TracyView_FrameTimeline.cpp +++ b/profiler/src/profiler/TracyView_FrameTimeline.cpp @@ -95,7 +95,7 @@ void View::DrawTimelineFrames( const FrameData& frames ) { const std::pair zrange = m_worker.GetFrameRange( frames, m_vd.zvStart, m_vd.zvEnd ); if( zrange.first < 0 ) return; - if( m_worker.GetFrameBegin( frames, zrange.first ) > m_vd.zvEnd || m_worker.GetFrameEnd( frames, zrange.second ) < m_vd.zvStart ) return; + if( m_worker.GetFrameBegin( frames, zrange.first ) > m_vd.zvEnd || m_worker.GetFrameEnd( frames, zrange.second - 1 ) < m_vd.zvStart ) return; const auto wpos = ImGui::GetCursorScreenPos(); const auto dpos = wpos + ImVec2( 0.5f, 0.5f ); diff --git a/profiler/src/profiler/TracyView_Messages.cpp b/profiler/src/profiler/TracyView_Messages.cpp index 9e18b808..acaabb7b 100644 --- a/profiler/src/profiler/TracyView_Messages.cpp +++ b/profiler/src/profiler/TracyView_Messages.cpp @@ -243,7 +243,7 @@ void View::DrawMessageLine( const MessageData& msg, bool hasCallstack, int& idx { m_msgHighlight = &msg; - if( m_showMessageImages ) + if( m_showMessageImages && m_worker.GetFrameCount( *m_frames ) > 0 ) { const auto frameIdx = m_worker.GetFrameRange( *m_frames, msg.time, msg.time ).first; auto fi = m_worker.GetFrameImage( *m_frames, frameIdx ); diff --git a/profiler/src/profiler/TracyView_Navigation.cpp b/profiler/src/profiler/TracyView_Navigation.cpp index 75f5eaea..f1aee251 100644 --- a/profiler/src/profiler/TracyView_Navigation.cpp +++ b/profiler/src/profiler/TracyView_Navigation.cpp @@ -74,7 +74,7 @@ void View::ZoomToRange( int64_t start, int64_t end, bool pause ) void View::ZoomToPrevFrame() { - if( m_vd.zvStart >= m_worker.GetFrameBegin( *m_frames, 0 ) ) + if( m_worker.GetFrameCount( *m_frames ) > 0 && m_vd.zvStart >= m_worker.GetFrameBegin( *m_frames, 0 ) ) { size_t frame; if( m_frames->continuous ) @@ -98,6 +98,8 @@ void View::ZoomToPrevFrame() void View::ZoomToNextFrame() { + if( m_worker.GetFrameCount( *m_frames ) == 0 ) return; + int64_t start; if( m_zoomAnim.active ) { @@ -133,6 +135,7 @@ void View::CenterAtTime( int64_t t ) void View::SetViewToLastFrames() { const int total = m_worker.GetFrameCount( *m_frames ); + if( total == 0 ) return; m_vd.zvStart = m_worker.GetFrameBegin( *m_frames, std::max( 0, total - 4 ) ); if( total == 1 ) diff --git a/profiler/src/profiler/TracyView_Timeline.cpp b/profiler/src/profiler/TracyView_Timeline.cpp index d9b0d70b..3edcbfef 100644 --- a/profiler/src/profiler/TracyView_Timeline.cpp +++ b/profiler/src/profiler/TracyView_Timeline.cpp @@ -310,7 +310,7 @@ void View::DrawTimeline() auto& frames = m_worker.GetFrames(); for( auto fd : frames ) { - if( Vis( fd ) ) + if( Vis( fd ) && m_worker.GetFrameCount( *fd ) > 0 ) { DrawTimelineFrames( *fd ); } diff --git a/profiler/src/profiler/TracyView_TraceInfo.cpp b/profiler/src/profiler/TracyView_TraceInfo.cpp index 39349fbd..6b0e073f 100644 --- a/profiler/src/profiler/TracyView_TraceInfo.cpp +++ b/profiler/src/profiler/TracyView_TraceInfo.cpp @@ -183,7 +183,7 @@ void View::DrawInfo() ImGui::TreePop(); } - if( m_worker.AreFramesUsed() && ImGui::TreeNode( "Frame statistics" ) ) + if( m_worker.AreFramesUsed() && ImGui::TreeNode( "Frame statistics" ) && m_worker.GetFrameCount( *m_frames ) > 0 ) { auto fsz = m_worker.GetFullFrameCount( *m_frames ); if( fsz != 0 ) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 97be71e1..fa7eebcc 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -2074,6 +2074,7 @@ int64_t Worker::GetFirstTime() const int64_t Worker::GetFrameTime( const FrameData& fd, size_t idx ) const { + assert( idx < fd.frames.size() ); if( fd.continuous ) { if( idx < fd.frames.size() - 1 ) @@ -2108,6 +2109,7 @@ int64_t Worker::GetFrameBegin( const FrameData& fd, size_t idx ) const int64_t Worker::GetFrameEnd( const FrameData& fd, size_t idx ) const { + assert( idx < fd.frames.size() ); if( fd.continuous ) { if( idx < fd.frames.size() - 1 ) @@ -2142,6 +2144,7 @@ const FrameImage* Worker::GetFrameImage( const FrameData& fd, size_t idx ) const std::pair Worker::GetFrameRange( const FrameData& fd, int64_t from, int64_t to ) { + assert( !fd.frames.empty() ); auto zitbegin = std::lower_bound( fd.frames.begin(), fd.frames.end(), from, [] ( const auto& lhs, const auto& rhs ) { return lhs.start < rhs; } ); if( zitbegin == fd.frames.end() ) zitbegin--;