Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8d7e7841 authored by Ady Abraham's avatar Ady Abraham
Browse files

SF: fix floating-point-exception in SurfaceFlinger::setCompositorTimingSnapped

Change-Id: Ia14965b6cb7bdfc4ea87fb98a43d8adff9201cb3
Fixes: 216829967
Test: build
parent ac1c828e
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -2356,9 +2356,11 @@ void SurfaceFlinger::setCompositorTimingSnapped(const DisplayStatInfo& stats,
    // 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);