From 52b783f76af58a948dad4d3b4d1b7ad7979347ce Mon Sep 17 00:00:00 2001 From: John Reck Date: Tue, 24 Nov 2015 11:12:55 -0800 Subject: INT_MAX nanoseconds is not very long Bug: 25843358 If the time between last swap & current vsync grew larger than 2 seconds it would overflow when placed into an int, causing frames to be dropped as negative numbers are definitely less than 2_ms. Change-Id: Icd2136989e5bbf5a0e21611b95a4d515b5ff9b14 --- libs/hwui/renderthread/CanvasContext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index 89cadea775f3..ca85dfbf1bab 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -237,7 +237,7 @@ void CanvasContext::prepareTree(TreeInfo& info, int64_t* uiFrameInfo, if (CC_LIKELY(mSwapHistory.size())) { nsecs_t latestVsync = mRenderThread.timeLord().latestVsync(); const SwapHistory& lastSwap = mSwapHistory.back(); - int vsyncDelta = std::abs(lastSwap.vsyncTime - latestVsync); + nsecs_t vsyncDelta = std::abs(lastSwap.vsyncTime - latestVsync); // The slight fudge-factor is to deal with cases where // the vsync was estimated due to being slow handling the signal. // See the logic in TimeLord#computeFrameTimeNanos or in -- cgit v1.2.3-59-g8ed1b