The HuoLaLa and Lalamove Android project employs inline-hook
techniques to address system-level issues and enhance app's overall stability or performance.
Avoid suspending thread timeout to make process kill by Abort
signal.
-
Android [5,11] : Hook ThreadSuspendByPeerWarning() to modified log level, if hit thread suspend timeout, will call
suspendThreadTimeout()
to notified java side. -
Android [12,14] : Hook SuspendThreadByPeer() function and replace it to call SuspendThreadByPeerId() function, will not need to call
suspendThreadTimeout()
to notified java side, because if thread suspend timeout can not send abort signal. -
Android 15 : Hook StringPrintf() function and block thread to wait thread suspends finish, will call
suspendThreadTimeout()
to notified java side.
In Lalamove Side, the number of thread suspend timeout crash times is so huge.
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
dependencies {
implementation 'com.github.HuolalaTech:hll-sys-hook-android:1.4-SNAPSHOT'
}
SuspendThreadSafeHelper.getInstance()
.suspendThreadSafe(object : SuspendThreadSafeHelper.SuspendThreadCallback {
override fun suspendThreadTimeout(waitTime: Double) {
Log.i("TAG", "Waitting for thread suspend done, spend : $waitTime s")
}
override fun onError(errorMsg: String) {
Log.e("TAG", "onError: $errorMsg")
}
})