SF: fix floating-point-exception in SurfaceFlinger::setCompositorTimingSnapped
Change-Id: Ia14965b6cb7bdfc4ea87fb98a43d8adff9201cb3
Fixes: 216829967
Test: build
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 3459a8f..396fdd3 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2356,9 +2356,11 @@
// something (such as user input) to an accurate diasplay time.
// Snapping also allows an app to precisely calculate
// mVsyncConfiguration->getCurrentConfigs().late.sf with (presentLatency % interval).
- nsecs_t bias = stats.vsyncPeriod / 2;
- int64_t extraVsyncs = (compositeToPresentLatency - idealLatency + bias) / stats.vsyncPeriod;
- nsecs_t snappedCompositeToPresentLatency =
+ const nsecs_t bias = stats.vsyncPeriod / 2;
+ const int64_t extraVsyncs = (stats.vsyncPeriod) > 0 ?
+ ((compositeToPresentLatency - idealLatency + bias) / stats.vsyncPeriod) :
+ 0;
+ const nsecs_t snappedCompositeToPresentLatency =
(extraVsyncs > 0) ? idealLatency + (extraVsyncs * stats.vsyncPeriod) : idealLatency;
std::lock_guard<std::mutex> lock(getBE().mCompositorTimingLock);