[Xiaomi Redmi Note 5 Pro ROMs, Kernels, Recoveries,] Desmanto:
I have examined the logcat more carefully. It turns out the first few hundred to thousand of the lines seem to tell nothing. But I see repeating pattern here when the SystemUI started to popup as not responding. The log near the popup is something like this and repeating.

08-23 23:54:08.120 3105 5424 I chatty : uid=1000 system_server expire 1 line
08-23 23:54:08.131 3105 5425 I chatty : uid=1000 system_server expire 1 line
08-23 23:54:08.142 3105 5426 I chatty : uid=1000 system_server expire 1 line
08-23 23:54:08.159 3105 5427 I chatty : uid=1000 system_server expire 1 line
08-23 23:54:08.172 3105 5428 I chatty : uid=1000 system_server expire 1 line
08-23 23:54:08.189 3105 5429 I chatty : uid=1000 system_server expire 1 line
08-23 23:54:08.202 3105 5430 I chatty : uid=1000 system_server expire 1 line
08-23 23:54:08.214 3105 5431 I chatty : uid=1000 system_server expire 1 line
08-23 23:54:08.226 3105 5432 I chatty : uid=1000 system_server expire 1 line
08-23 23:54:08.236 3105 5433 I chatty : uid=1000 system_server expire 1 line
08-23 23:54:08.246 3105 5434 I chatty : uid=1000 system_server expire 1 line
08-23 23:54:08.259 3105 5435 I chatty : uid=1000 system_server expire 1 line
08-23 23:54:08.272 3105 5436 I chatty : uid=1000 system_server expire 1 line
08-23 23:54:08.282 3105 5437 I chatty : uid=1000 system_server expire 1 line
08-23 23:54:08.295 3105 5438 I chatty : uid=1000 system_server expire 1 line
08-23 23:54:08.311 3105 5439 I chatty : uid=1000 system_server expire 1 line
08-23 23:54:08.323 3105 5440 I chatty : uid=1000 system_server expire 1 line
08-23 23:54:08.334 3105 5441 I chatty : uid=1000 system_server expire 1 line
08-23 23:54:08.346 3105 4713 I chatty : uid=1000 system_server expire 1 line
08-23 23:54:08.360 3105 5443 I chatty : uid=1000 system_server expire 1 line
08-23 23:54:08.372 3105 5444 I chatty : uid=1000 system_server expire 1 line
08-23 23:54:08.382 3105 5445 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5446) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=683 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.434s
08-23 23:54:08.393 3105 5446 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5447) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=683 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.421s
08-23 23:54:08.404 3105 5447 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5448) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=683 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.408s
08-23 23:54:08.416 3105 5448 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5450) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=683 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.390s
08-23 23:54:08.429 3105 5449 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5450) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=684 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.384s
08-23 23:54:08.442 3105 5450 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5451) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=684 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.374s
08-23 23:54:08.456 3105 5451 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5452) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=684 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.365s
08-23 23:54:08.474 3105 5452 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5454) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=684 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.360s
08-23 23:54:08.485 3105 5454 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5458) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=684 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.345s
08-23 23:54:08.498 3105 5457 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5458) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=685 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.337s
08-23 23:54:08.510 2823 2823 I /system/bin/tombstoned: received crash request for pid 3455
08-23 23:54:08.510 2823 2823 I /system/bin/tombstoned: found intercept fd 512 for pid 3455 and type kDebuggerdJavaBacktrace
08-23 23:54:08.511 3105 5458 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5460) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=685 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.320s
08-23 23:54:08.512 3455 3478 I zygote64: Wrote stack traces to '[tombstoned]'
08-23 23:54:08.514 3105 3169 I zygote64: libdebuggerd_client: done dumping process 3455
08-23 23:54:08.514 3105 3169 I zygote64: libdebuggerd_client: started dumping process 3105
08-23 23:54:08.515 2823 2823 I /system/bin/tombstoned: registered intercept for pid 3105 and type kDebuggerdJavaBacktrace
08-23 23:54:08.517 3105 3119 I zygote64: Thread[2,tid=3119,WaitingInMainSignalCatcherLoop,Thread*=0x7a9180e000,peer=0x13a40110,"Signal Catcher"]: reacting to signal 3
08-23 23:54:08.517 3105 3119 I zygote64:
08-23 23:54:08.524 3105 5460 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5462) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=685 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.305s
08-23 23:54:08.542 3105 5461 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5464) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=685 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.289s
08-23 23:54:08.558 3105 5462 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5464) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=686 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.285s
08-23 23:54:08.572 3105 5464 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5467) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=686 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.271s
08-23 23:54:08.587 3105 5465 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5468) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=686 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.265s
08-23 23:54:08.599 3105 5467 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5468) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=687 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.238s
08-23 23:54:08.614 3105 5468 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5470) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=687 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.227s
08-23 23:54:08.936 3105 3362 I zygote64: hidl_ssvc_poll: spurious wake up, back to work
08-23 23:54:09.324 2823 2823 I /system/bin/tombstoned: received crash request for pid 3105
08-23 23:54:09.324 2823 2823 I /system/bin/tombstoned: found intercept fd 512 for pid 3105 and type kDebuggerdJavaBacktrace
08-23 23:54:09.325 3105 3119 I zygote64: Wrote stack traces to '[tombstoned]'
08-23 23:54:09.329 3105 3169 I zygote64: libdebuggerd_client: done dumping process 3105
08-23 23:54:09.329 3105 3169 I zygote64: libdebuggerd_client: started dumping process 4500
08-23 23:54:09.333 2823 2823 I /system/bin/tombstoned: registered intercept for pid 4500 and type kDebuggerdJavaBacktrace
08-23 23:54:09.335 3105 5469 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5470) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=688 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.927s
08-23 23:54:09.343 4500 4508 I zygote : Thread[3,tid=4508,WaitingInMainSignalCatcherLoop,Thread*=0xf05dac00,peer=0x12d80218,"Signal Catcher"]: reacting to signal 3
08-23 23:54:09.343 4500 4508 I zygote :
08-23 23:54:09.354 3105 5470 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5471) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=688 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.923s
08-23 23:54:09.367 3105 5471 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5474) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=688 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.911s
08-23 23:54:09.378 3105 4734 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5475) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=688 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.894s
08-23 23:54:09.391 3105 5474 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5475) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=689 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.883s
08-23 23:54:09.401 3105 5475 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5477) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=689 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.869s
08-23 23:54:09.410 3105 5476 W zygote64: Long monitor contention with owner PerformPoll Async Thread (5477) at void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run()(NetworkStatsService.java:1152) waiters=690 in void com.android.server.net.NetworkStatsService$PerformPollAsyncThread.run() for 8.851s
08-23 23:54:09.444 3105 4301 W zygote64: Long monitor contention with owner NetworkPolicy (3320) at void com.android.server.net.NetworkPolicyManagerService$7.onReceive(android.content.Context, android.content.Intent)(NetworkPolicyManagerService.java:950) waiters=0 in boolean com.android.server.net.NetworkPolicyManagerService$NetworkPolicyManagerInternalImpl.isUidNetworkingBlocked(int, java.lang.String) for 38.429s

I don't understand it. It seems to be something related to the ong monitor Async Thread. During the file transfer, the whole phone frozen up until the operation completed. The systemUI not responding will popup several time, and I usually press wait. If the transfer is too long to complete (600-900 MB), there can be a force restart and transfer failed. Sometimes the transfer complete and the force restart happens several seconds later.

thermal-engine crash

The other crash of thermal engine that I mention earlier too during the wifi deep sleep drain (don't know if related). I took dmesg and logcat and found out the same pid appear.

dmesg log for 2 instance (pid 32206 and 32227). The pattern repeats

[ 9003.578368] init: starting service 'thermal-engine'...
[ 9003.579165] init: property_set("ro.boottime.thermal-engine", "19536377745619") failed: property already set
[ 9003.580975] init: Created socket '/dev/socket/thermal-send-client', mode 666, user 1000, group 1000
[ 9003.581593] init: Created socket '/dev/socket/thermal-recv-client', mode 660, user 1000, group 1000
[ 9003.582141] init: Created socket '/dev/socket/thermal-recv-passive-client', mode 666, user 1000, group 1000
[ 9003.582683] init: Created socket '/dev/socket/thermal-send-rule', mode 660, user 1000, group 1000
[ 9003.642565] init: Untracked pid 32209 killed by signal 13
[ 9003.646255] init: Service 'thermal-engine' (pid 32206) killed by signal 6
[ 9003.646281] init: Sending signal 9 to service 'thermal-engine' (pid 32206) process group...
[ 9003.646437] init: Successfully killed process cgroup uid 0 pid 32206 in 0ms
[ 9008.579175] init: starting service 'thermal-engine'...
[ 9008.579939] init: property_set("ro.boottime.thermal-engine", "19541378585356") failed: property already set
[ 9008.581844] init: Created socket '/dev/socket/thermal-send-client', mode 666, user 1000, group 1000
[ 9008.582453] init: Created socket '/dev/socket/thermal-recv-client', mode 660, user 1000, group 1000
[ 9008.582993] init: Created socket '/dev/socket/thermal-recv-passive-client', mode 666, user 1000, group 1000
[ 9008.583544] init: Created socket '/dev/socket/thermal-send-rule', mode 660, user 1000, group 1000
[ 9008.642010] init: Service 'thermal-engine' (pid 32227) killed by signal 6
[ 9008.642037] init: Sending signal 9 to service 'thermal-engine' (pid 32227) process group...
[ 9008.642172] init: Successfully killed process cgroup uid 0 pid 32227 in 0ms
[ 9008.642617] init: Untracked pid 32230 killed by signal 13
[ 9008.646255] init: Service 'thermal-engine' (pid 32206) killed by signal 6
[ 9008.646281] init: Sending signal 9 to service 'thermal-engine' (pid 32206) process group...
[ 9008.646437] init: Successfully killed process cgroup uid 0 pid 32206 in 0ms

while for pid 32227, i can check the same crash in the logcat.

--------- beginning of crash
08-23 23:28:10.732 32227 32227 F libc : CANNOT LINK EXECUTABLE "/system/vendor/bin/thermal-engine": library "libthermalfeature.so" not found
08-23 23:28:10.732 32227 32227 F libc : Fatal signal 6 (SIGABRT), code -6 in tid 32227 (thermal-engine), pid 32227 (thermal-engine)
08-23 23:28:10.759 32230 32230 I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
08-23 23:28:10.760 2823 2823 I /system/bin/tombstoned: received crash request for pid 32227
08-23 23:28:10.761 32230 32230 I crash_dump64: performing dump of process 32227 (target tid = 32227)
08-23 23:28:10.762 32230 32230 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
08-23 23:28:10.762 32230 32230 F DEBUG : LineageOS Version: 'unknown'
08-23 23:28:10.762 32230 32230 F DEBUG : Build fingerprint: 'xiaomi/whyred/whyred:8.1.0/OPM1.171019.011/V9.5.6.0.OEIMIFA:user/release-keys'
08-23 23:28:10.762 32230 32230 F DEBUG : Revision: '0'
08-23 23:28:10.762 32230 32230 F DEBUG : ABI: 'arm64'
08-23 23:28:10.762 32230 32230 F DEBUG : pid: 32227, tid: 32227, name: thermal-engine >>> /system/vendor/bin/thermal-engine <<<
08-23 23:28:10.762 32230 32230 F DEBUG : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
08-23 23:28:10.763 32230 32230 F DEBUG : Abort message: 'CANNOT LINK EXECUTABLE "/system/vendor/bin/thermal-engine": library "libthermalfeature.so" not found'
08-23 23:28:10.763 32230 32230 F DEBUG : x0 0000000000000000 x1 0000000000007de3 x2 0000000000000006 x3 0000000000000008
08-23 23:28:10.763 32230 32230 F DEBUG : x4 0000000080808080 x5 0000000080808080 x6 0000000080808080 x7 0000000000000028
08-23 23:28:10.763 32230 32230 F DEBUG : x8 0000000000000083 x9 0b6a7d1746a6b44c x10 0000000000000000 x11 ffffffffffffffff
08-23 23:28:10.763 32230 32230 F DEBUG : x12 0000000000000020 x13 000000005b7ee09a x14 002b036dcc6f3f03 x15 0000a1e37b3ef6c3
08-23 23:28:10.763 32230 32230 F DEBUG : x16 1010959072edbffc x17 0000000000000001 x18 0000000000000004 x19 0000000000007de3
08-23 23:28:10.763 32230 32230 F DEBUG : x20 0000000000007de3 x21 0000000000000083 x22 0000006060775a40 x23 0000007a436ba598
08-23 23:28:10.763 32230 32230 F DEBUG : x24 0000007a436ba598 x25 0000007a437ca3f8 x26 0000007a437ca000 x27 0000007a437ca000
08-23 23:28:10.763 32230 32230 F DEBUG : x28 0000000000000000 x29 0000007ffe2c5f10 x30 0000007a4376a850
08-23 23:28:10.763 32230 32230 F DEBUG : sp 0000007ffe2c5ed0 pc 0000007a4376a870 pstate 0000000060000000
08-23 23:28:10.765 32230 32230 F DEBUG :
08-23 23:28:10.765 32230 32230 F DEBUG : backtrace:
08-23 23:28:10.765 32230 32230 F DEBUG : #00 pc 00000000000a0870 /system/bin/linker64 (__dl_abort+112)
08-23 23:28:10.765 32230 32230 F DEBUG : #01 pc 000000000001dc64 /system/bin/linker64 (__dl___linker_init+3936)
08-23 23:28:10.765 32230 32230 F DEBUG : #02 pc 0000000000024068 /system/bin/linker64 (_start+4)
08-23 23:28:10.776 3105 3461 W NativeCrashListener: Couldn't find ProcessRecord for pid 32227
08-23 23:28:10.778 2823 2823 W /system/bin/tombstoned: crash socket received short read of length 0 (expected 12)
08-23 23:28:10.778 3105 3178 I BootReceiver: Copying /data/tombstones/tombstone_28 to DropBox (SYSTEM_TOMBSTONE)

Both dmesg and logcat error repeat every few seconds. Both pointed out something is wrong with the thermal-engine.