TimerThread: Add timeout analysis logic
Automatically dumps TimeCheck analysis if
there is an actionable blocked binder call.
Test: dedicated "crasher" test, check logcat
Test: adb shell dumpsys media.audio_flinger
Bug: 219958414
Change-Id: Ie21ef8940404fa7174938277bbf9c7aab2817ef7
diff --git a/media/utils/include/mediautils/TimerThread.h b/media/utils/include/mediautils/TimerThread.h
index 2dfe499..ffee602 100644
--- a/media/utils/include/mediautils/TimerThread.h
+++ b/media/utils/include/mediautils/TimerThread.h
@@ -212,6 +212,36 @@
void copyRequests(std::vector<std::shared_ptr<const Request>>& requests) const;
};
+ // Analysis contains info deduced by analysisTimeout().
+ //
+ // Summary is the result string from checking timeoutRequests to see if
+ // any might be caused by blocked calls in pendingRequests.
+ //
+ // Summary string is empty if there is no automatic actionable info.
+ //
+ // timeoutTid is the tid selected from timeoutRequests (if any).
+ //
+ // HALBlockedTid is the tid that is blocked from pendingRequests believed
+ // to cause the timeout.
+ // HALBlockedTid may be INVALID_PID if no suspected tid is found,
+ // and if HALBlockedTid is valid, it will not be the same as timeoutTid.
+ //
+ static constexpr pid_t INVALID_PID = -1;
+ struct Analysis {
+ std::string summary;
+ pid_t timeoutTid = INVALID_PID;
+ pid_t HALBlockedTid = INVALID_PID;
+ };
+
+ // A HAL method is where the substring "Hidl" is in the class name.
+ // The tag should look like: ... Hidl ... :: ...
+ static bool isRequestFromHal(const std::shared_ptr<const Request>& request);
+
+ // Returns analysis from the requests.
+ static Analysis analyzeTimeout(
+ const std::vector<std::shared_ptr<const Request>>& timeoutRequests,
+ const std::vector<std::shared_ptr<const Request>>& pendingRequests);
+
std::vector<std::shared_ptr<const Request>> getPendingRequests() const;
// A no-timeout request is represented by a handles at the end of steady_clock time,