osudroid / osu-droid

Home Page:http://osudroid.moe

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Memory leaks and overhead when global leaderboard is enabled

Reco1I opened this issue · comments

The possible reasons and solutions here:

  • Avatar size, it should be downloaded in the necessary size instead of a fixed one. That size should match the Sprite width and height.
  • Java synchronization, using it everywhere causes lag. Instead you should use a better approach with conditions or a listener.
  • AsyncTask.cancel() doesn't really shutdown the thread where the task is running, it waits until the task ends. Inside those tasks (score parsing and avatar loading) are loops, these loops should listen to when the task has been cancelled so it will not continue looping.
  • Avatar loading continues running in background while playing, this shouldn't happen.

I think bullet 3 can be implemented as a start, along with bullet 5 as OkHttpClient instances can be reused. The required effort for both bullets should be minimal.

Bullet 1 is not possible as modifying avatar image size on download is not supported server-side, though the downloaded avatar size is always the same.

Bullet 2 will need extra effort due to refactoring. Let's explore the easier options first.

Bullet 4 will need a special pause handle to avoid empty avatars in global leaderboards after the player initiates gameplay, and thus will require extra effort.