Is that possible to find out the reason which caused lagging of UI like specific thread or method?
Cause I kind of put all the heavy work into another thread but I’ve still getting a lagged UI.
I’m using CameraX where ImageAnalysis works in separate thread in which I do emotion detection via neural network. So when a neural network process an image in this not UI thread my UI thread also lags.
Is that possible at all? Can the separate thread slow down the UI thread by executing heavy task?
Maybe there’s some plugin for Android Studio or something like that to solve the problem.
At the moment pytorch android thread count is fixed by device and equal “number of big cores of cpu”(N) on device.
As you also have bg thread for image decoding + UI thread - at the moment of inference you have at least (N + 2) competing threads for N big cores (+other applications threads). I think that is the reason why you see UI thread slow downs.
We are thinking to expose control of number of threads to java api, in that case you can set for example singleThread mode, that should not affect too much UI thread responsiveness.