Skip to content

Commit 7ce7d4e

Browse files
Case Beamanfacebook-github-bot
authored andcommitted
Add logging for soft error cases when raising thread priority
Summary: The two cases being logged are: 1. We looped several times and never succeeded at raising the thread priority. If we only ever see this and rarely (2), then perhaps it is safe to only make one attempt instead of looping 2. We looped more than once and eventually found a priority we could successfully set With this information maybe we can tell which devices / OS versions / etc, have issues with manually setting thread priorities Reviewed By: OlehMalanchuk Differential Revision: D75980989 fbshipit-source-id: f449cc94ecdacd31cb2644e825639d15857adb42
1 parent 676642f commit 7ce7d4e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

litho-core/src/main/java/com/facebook/litho/ThreadUtils.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@ object ThreadUtils {
108108
threadPriority += Process.THREAD_PRIORITY_LESS_FAVORABLE
109109
}
110110
}
111+
if (threadPriority == originalThreadPriority) {
112+
// We were unable to raise the priority of the thread at all.
113+
ComponentsConfiguration.softErrorHandler?.handleSoftError(
114+
"Unable to raise priority to $targetThreadPriority from $originalThreadPriority",
115+
"ThreadUtils")
116+
} else if (threadPriority > targetThreadPriority) {
117+
// We were able to raise the priority but not at the desired level.
118+
ComponentsConfiguration.softErrorHandler?.handleSoftError(
119+
"ThreadUtils",
120+
"Encountered an error raising priority to $targetThreadPriority from $originalThreadPriority but succeeded at $threadPriority")
121+
}
111122
return Pair(originalThreadPriority, threadPriority)
112123
}
113124

0 commit comments

Comments
 (0)