samuelclay / NewsBlur

NewsBlur is a personal news reader that brings people together to talk about the world. A new sound of an old instrument.
http://www.newsblur.com
MIT License
6.83k stars 996 forks source link

Android: The speed of entering the login screen is slow #1450

Closed struggggle closed 2 years ago

struggggle commented 3 years ago

Hi,

When I opened Newsblur in an Android device of OnePlus 6T, Android 9.0 I found that I can enter the following login screen immediately.

image

However, when I opened Newsblur in another Android device of Mi Note 3, Android 8.0 I found that the speed of entering the login screen became much slower and following pages will appear before entering the login screen

image

image

I hooked NewsBlur and found that a 840*840 image was decoded in the UI thread, which would be the reason why the speed become slow in Mi Note 3. Below is the 840*840 image:

image

Below is the stack trace obtained by calling Thread.currentThread().getStackTrace() after the image was decoded: (each line contains "class name", "method name", and "line number"):

'' android.graphics.BitmapFactory;decodeStream;-1 android.graphics.BitmapFactory;decodeResourceStream;538 android.graphics.drawable.Drawable;createFromResourceStream;1195 android.content.res.ResourcesImpl;loadDrawableForCookie;812 android.content.res.ResourcesImpl;loadDrawable;630 android.content.res.Resources;loadDrawable;886 android.content.res.TypedArray;getDrawableForDensity;953 android.content.res.TypedArray;getDrawable;928 android.content.res.XResources$XTypedArray;getDrawable;1363 android.widget.ImageView;;188 android.widget.ImageView;;171 androidx.appcompat.widget.AppCompatImageView;;72 androidx.appcompat.widget.AppCompatImageView;;68 androidx.appcompat.app.AppCompatViewInflater;createImageView;187 androidx.appcompat.app.AppCompatViewInflater;createView;107 androidx.appcompat.app.AppCompatDelegateImpl;createView;1407 androidx.appcompat.app.AppCompatDelegateImpl;onCreateView;1457 android.view.LayoutInflater;createViewFromTag;772 android.view.LayoutInflater;createViewFromTag;730 android.view.LayoutInflater;rInflate;863 android.view.LayoutInflater;rInflateChildren;824 android.view.LayoutInflater;rInflate;866 android.view.LayoutInflater;rInflateChildren;824 android.view.LayoutInflater;inflate;515 de.robv.android.xposed.XposedBridge;invokeOriginalMethodNative;-2 de.robv.android.xposed.XposedBridge;handleHookedMethod;361 android.view.LayoutInflater;inflate;-1 android.view.LayoutInflater;inflate;423 com.newsblur.databinding.ActivityMainBinding;inflate;115 com.newsblur.databinding.ActivityMainBinding;inflate;109 com.newsblur.activity.Main;onCreate;59 android.app.Activity;performCreate;7009 android.app.Activity;performCreate;7000 android.app.Instrumentation;callActivityOnCreate;1214 android.app.ActivityThread;performLaunchActivity;2731 android.app.ActivityThread;handleLaunchActivity;2856 android.app.ActivityThread;-wrap11;0 android.app.ActivityThread$H;handleMessage;1589 android.os.Handler;dispatchMessage;106 android.os.Looper;loop;164 android.app.ActivityThread;main;6494 java.lang.reflect.Method;invoke;-2 com.android.internal.os.RuntimeInit$MethodAndArgsCaller;run;438 com.android.internal.os.ZygoteInit;main;807 ''

Below are the created image data in NewsBlur after image decoding (obtained by hooking NewsBlur) :

image

Data description: “840, 840" is the width and hight of an image.

From the obtained image data, I also found that the 840* 840 image is repeated decoded in the UI thread.

Android suggests that the process of decoding large images should not be executed in the main UI thread. https://stuff.mit.edu/afs/sipb/project/android/docs/training/displaying-bitmaps/process-bitmap.html

Maybe the process of decoding the 840*840 image should be moved to a background thread. At the same time, the image should not be decoded repeatedly.

Thanks.

sictiru commented 2 years ago

@struggggle There were updates on the initial screen loading in Oct 2021 as part of the Android 12 upgrade. More startup improvements will be merged soon from another initiative. I'm closing this ticket but feel free to reopen if the issue persists.