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

Commit 07e0e29e authored by en.liu's avatar en.liu Committed by Ray Chin
Browse files

SF: fix SurfaceFlinger crash [1/1]



PD#SWPL-144146

Problem:
SurfaceFlinger crash. The race condition was described in
b/312686113#comment4.

Solution:
during VSyncDispatchTimerQueue deconstruction
skip timerCallback to avoid sf crash

Verify:
adt4, a TV set top box.

Bug: 312686113
Test: Suspend <-> resume for over 7 days. "Skip timerCallback" showed 15 times without SF crash.
Change-Id: I3cbf0294ee70dde697cba91962477d51c1bc986e
Signed-off-by: default avatarEn Liu <en.liu@amlogic.com>
parent 45c433c4
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -237,6 +237,7 @@ VSyncDispatchTimerQueue::VSyncDispatchTimerQueue(std::unique_ptr<TimeKeeper> tk,

VSyncDispatchTimerQueue::~VSyncDispatchTimerQueue() {
    std::lock_guard lock(mMutex);
    mRunning = false;
    cancelTimer();
    for (auto& [_, entry] : mCallbacks) {
        ALOGE("Forgot to unregister a callback on VSyncDispatch!");
@@ -305,6 +306,10 @@ void VSyncDispatchTimerQueue::timerCallback() {
    std::vector<Invocation> invocations;
    {
        std::lock_guard lock(mMutex);
        if (!mRunning) {
            ALOGD("TimerQueue is not running. Skipping callback.");
            return;
        }
        auto const now = mTimeKeeper->now();
        mLastTimerCallback = now;
        for (auto it = mCallbacks.begin(); it != mCallbacks.end(); it++) {
+4 −0
Original line number Diff line number Diff line
@@ -148,6 +148,10 @@ private:

    std::mutex mutable mMutex;

    // During VSyncDispatchTimerQueue deconstruction, skip timerCallback to
    // avoid crash
    bool mRunning = true;

    static constexpr nsecs_t kInvalidTime = std::numeric_limits<int64_t>::max();
    std::unique_ptr<TimeKeeper> const mTimeKeeper;
    VsyncSchedule::TrackerPtr mTracker;