SurfaceFlinger: Reset VsyncReactor's timer thread
If any of the syscalls the timer uses returns an error, reset the timer.
This is a workaround for an issue seen where VsyncReactor is not calling
new callbacks. In addition this change adds more log prints to help
identifying the underlying issue.
Bug: 151892277
Test: simulate an error in syscall and observe timer resets
Change-Id: I6fd62f9d73f75f32a87d1483cea14f3f1b358507
diff --git a/services/surfaceflinger/Scheduler/Timer.h b/services/surfaceflinger/Scheduler/Timer.h
index 0ae82c8..a8e2d5a 100644
--- a/services/surfaceflinger/Scheduler/Timer.h
+++ b/services/surfaceflinger/Scheduler/Timer.h
@@ -34,18 +34,27 @@
// Most users will want to serialize thes calls so as to be aware of the timer state.
void alarmIn(std::function<void()> const& cb, nsecs_t fireIn) final;
void alarmCancel() final;
+ void dump(std::string& result) const final;
private:
- int const mTimerFd;
- int const mEpollFd;
- std::array<int, 2> mPipes;
+ enum class DebugState { Reset, Running, Waiting, Reading, InCallback, Terminated };
+ void reset();
+ void cleanup();
+ void setDebugState(DebugState state) EXCLUDES(mMutex);
+ const char* strDebugState(DebugState state) const;
+
+ int mTimerFd = -1;
+ int mEpollFd = -1;
+ std::array<int, 2> mPipes = {-1, -1};
std::thread mDispatchThread;
- void dispatch();
+ void threadMain();
+ bool dispatch();
void endDispatch();
- std::mutex mMutex;
+ mutable std::mutex mMutex;
std::function<void()> mCallback GUARDED_BY(mMutex);
+ DebugState mDebugState GUARDED_BY(mMutex);
};
} // namespace android::scheduler