From 4592dc19b3026122162122270d404800e84f2818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=8F=82?= Date: Tue, 18 Jun 2024 20:13:00 +0800 Subject: [PATCH] fix crash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 张珂 --- utils/sync_fence/src/sync_fence_tracker.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utils/sync_fence/src/sync_fence_tracker.cpp b/utils/sync_fence/src/sync_fence_tracker.cpp index 743fa56a63..139f5f2fd0 100644 --- a/utils/sync_fence/src/sync_fence_tracker.cpp +++ b/utils/sync_fence/src/sync_fence_tracker.cpp @@ -166,7 +166,10 @@ inline int32_t SyncFenceTracker::GetFrameRate() int32_t frameRate = 0; auto frameNum = frameStartTimes->size(); if (frameNum > 1) { - frameRate = FRAME_PERIOD * (frameNum - 1) / (frameStartTimes->back() - frameStartTimes->front()); + auto interval = frameStartTimes->back() - frameStartTimes->front(); + if(interval > 0) { + frameRate = FRAME_PERIOD * (frameNum - 1) / interval; + } } HILOG_DEBUG(LOG_CORE, "frameNum: %zu, frameRate: %{public}" PRId32, frameNum, frameRate);