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

Commit 6165155e authored by Dominik Laskowski's avatar Dominik Laskowski
Browse files

SF: Check if mode exists in onKernelTimerChanged

mDisplayModes may no longer contain desiredModeId.

Bug: 255635711
Test: Refresh rate overlay still works
Change-Id: Ie4c90d95886a396757d92791639b910bd6365696
parent 5974651f
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -973,14 +973,18 @@ ftl::Optional<FrameRateMode> RefreshRateSelector::onKernelTimerChanged(
        ftl::Optional<DisplayModeId> desiredModeIdOpt, bool timerExpired) const {
    std::lock_guard lock(mLock);

    const auto current = [&]() REQUIRES(mLock) -> FrameRateMode {
        if (desiredModeIdOpt) {
            const auto& modePtr = mDisplayModes.get(*desiredModeIdOpt)->get();
    const auto current =
            desiredModeIdOpt
                    .and_then([this](DisplayModeId modeId)
                                      REQUIRES(mLock) { return mDisplayModes.get(modeId); })
                    .transform([](const DisplayModePtr& modePtr) {
                        return FrameRateMode{modePtr->getPeakFps(), ftl::as_non_null(modePtr)};
        }

        return getActiveModeLocked();
    }();
                    })
                    .or_else([this] {
                        ftl::FakeGuard guard(mLock);
                        return std::make_optional(getActiveModeLocked());
                    })
                    .value();

    const DisplayModePtr& min = mMinRefreshRateModeIt->second;
    if (current.modePtr->getId() == min->getId()) {