the-blue-alliance / the-blue-alliance-android

An Android app for accessing information about the FIRST Robotics Competition.
MIT License
76 stars 34 forks source link

Performance improvement suggestion #952

Open cataloque opened 4 years ago

cataloque commented 4 years ago

Dear developers, I found an API, setImageURI(), is used in the-blue-alliance-android. For setImageURI(), Google says this: " This does Bitmap reading and decoding on the UI thread, which can cause a latency hiccup. ” In addition, using this method to create a picture cannot handle the picture size. If the loaded picture is too large, it may cause OOM. If that's a concern, consider using setImageDrawable(android.graphics.drawable.Drawable) or setImageBitmap(android.graphics.Bitmap) and BitmapFactory instead.

I also noticed that in the following code, om.thebluealliance.androidclient.activities.ConfirmImageSuggestionActivity. lambda.cacheAndLoadImage();bitmap object is created with the invocation of decodeStream(). However, decodeStream() is a slow operation and it is in the UI thread. maybe we should move Bitmap reading and decoding to a background thread. Could you kindly have a look at this issue? Thanks.