3

I am developing a mobile game for Android in Python using PyGame. So for debugging purposes, I have often used PyDroid, which is basically a mobile IDE for editing Python code on an Android mobile device. It also allows me to run the whole app in Python, since it also includes a working interpreter.

The app runs around 60 FPS with no problems (it's a simple 2D platformer, nothing very sophisticated).

When I build the application via Buildozer (using the procedure discussed in this answer), I am able to obtain an APK using the buildozer android debug command. When I install the APK, it works perfectly except for the frame rate: it's always around 30, never able to reach the same performance I see with PyDroid!

I would like to understand why this is happening. What is the difference between compiling the APK via Buildozer, and running the application on PyDroid? Is there a way to emulate exactly what happens on PyDroid also using Buildozer? Is there something I am doing wrongly? How can I improve the performance of the generated APK?

Vito Gentile
  • 13,336
  • 9
  • 61
  • 96
  • 1
    Is the `debug` required by buildozer? It might add some debugging help or error handling which can slow down things quite a bit. – Banana Mar 18 '22 at 17:51
  • Try `buildozer android release` instead of debug... That command is really for pre-release builds and has some added overhead. Not that this will solve all your issues but it's a first thing to try – Matt Mar 21 '22 at 02:02
  • I tried also with `release` but no differences... – Vito Gentile Mar 21 '22 at 07:20
  • So let me understand your test environment - are you using PyDroid on a phone, then compiling to an APK, then running that on the same phone as a package? I have some Python programs I wrote that I can try to do the same with to see if the performance always take a hit or not, although my code is all math based, not GUI, so not sure how helpful it will be to you. Obviously if math operations take a hit then your visuals will also take a hit, though, since they are all math really in the backend. – Matt Mar 21 '22 at 17:44
  • Yes, I think you understand correctly. My guess is that this FPS difference might be due to some optimization implemented in PyDroid, and it would be great to understand how they did it and what is needed to do the same in any other Python applications deployed via Buildozer... – Vito Gentile Mar 21 '22 at 20:44

1 Answers1

-1

PyDroid simply has better infrastructure which allows for better performance.

I believe this is why - everything is native to Android and in Python. When I was reading about this I stumbled across this and I think this sums it up nicely:

"Pydroid 3 comes with an interface that allows you to install packages without writing your commands in the terminal." - this likely has an impact on performance too.

  • Can you provide references? Can you also explain what do you mean by "has a better infrastructure"? What infrastructure are you referring to? What in such infrastructure allows for better performance, and why? The current answer is too generic... – Vito Gentile Mar 25 '22 at 08:33