VadimBoev / FlappyBird

Less than 100 Kilobytes. Works for Android 5.1 and above
2.03k stars 129 forks source link

Device becomes warm while the app is open #31

Open An-anonymous-coder opened 2 weeks ago

An-anonymous-coder commented 2 weeks ago

Pixel 8 running GrapheneOS (Android 14)

While using the app, the battery begins to heat up more than it should. This is an indication of nonessential loops or unoptimized code.

Check to see if any code is running while the app is idle that is not required.

VadimBoev commented 2 weeks ago

The code is available, it can be viewed and analyzed. I'm closing this, it sounds weird.

illerokcob commented 2 weeks ago

No, he was right, I double checked on a rooted Android 11 device the cpu usage with top, and I found the following:

My test can be replicated easily on a rooted emulator as well with adb. I'd suggest reviewing the code in main.c and checking for state's activityState alongside destroyRequested because it can detect when the app is backgrounded.

WSQS commented 2 weeks ago

I think we should add a nanosleep in the loop of android_main

VadimBoev commented 2 weeks ago

I think we should add a nanosleep in the loop of android_main

from the point of view of working with threads, this is a good idea, but I can't be sure that this is a good practice for android native