Forum Discussion
wangxiaogangan
7 years agoExplorer
(Android) Unity got Poor CPU Performance compared with Native apk
Hello everyone, my team have been contributing to develop " view dependent media player ", which using a single thread decode 2048 * 1536 with android-media-codec (we can call it BASE TEX) and four thread decode 512 * 256 * 24 split blocks for viewer directly look at with ffmpeg (we can call it HD TEX), very similar with VR_5K_PLAYER.
The above main framework make the cpu usage more heavy compare with gpu. Cpu need decode 2048 *1536 totally and upload YUV from memory to video memory every frame, while gpu only decode 2048 *1536. After a few test with Samsung S8 & Quest, i found that, s8 & Quest got different performance which s8 got a high fps because of Quest has less cpu avaliability compare with S8.
( PS: S8 & Quest all equiped with snapdragon 835. as far as i know, the 835 chip contain 8 core, 4 core of all 8 core are big core responsible for heavy work )
To confirm my point of view , i made a test proj using unity & the latest gear sdk, add heavy cpu work for some thread
the enclosed python file use "adb shell cat /proc/stat" to calculate 8 core usage.
the above result is S8, the last four core are big core usage, while 3 big core execute full load.
the below result is executed with S8 using unity & gear & same dynamic library,
public class NewBehaviourScript : MonoBehaviour {
// Use this for initialization
void Start ()
{
for (int i = 0; i < 8; i++)
{
ThreadStart method = () => threadWork();
Thread thread = new Thread(method);
thread.Start();
}
void Update()
{
long sum = 0;
for (int i = 0; i < 1000000; ++i)
sum = (int)((sum + i) * 2.0f / 2.0f);
}
void threadWork()
{
while (true)
{
long sum = 0;
for (int i = 0; i < 100000000; ++i)
sum = (int)((sum + i) * 2.0f / 2.0f);
Debug.LogFormat("TestThread End name:{0} curr thread id:{1} cur timeStamp:{2}", sum, Thread.CurrentThread.ManagedThreadId, DateTime.Now.ToString());
}
}
}the enclosed python file use "adb shell cat /proc/stat" to calculate 8 core usage.
the above result is S8, the last four core are big core usage, while 3 big core execute full load.
the above result is Quest, the last four core are big core usage, while 2 big core execute full load.
my team also made a native android project which using gradle & android studio & without gear, loading my dynamic library through jni & execute view dependent media player. the S8 cpu usage is
my team also made a native android project which using gradle & android studio & without gear, loading my dynamic library through jni & execute view dependent media player. the S8 cpu usage is
the below result is executed with S8 using unity & gear & same dynamic library,
the two test show that native apk get a better & average cpu usage while heavy cpu work executing, compared with unity & gear apk.
My question is,
- Is there a way for unity & gear apk to control device cpu availability rate ?
- why native apk performance diff with unity & gear apk?
- why Quest got less core to execute cpu work compared with S8?
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 10 months ago
- 5 years ago
- 3 years ago