excelPanel icon indicating copy to clipboard operation
excelPanel copied to clipboard

Performance Issues

Open Appilog opened this issue 7 years ago • 6 comments

Hello, first, thank you very much for sharing your work here!

I have some serious performance problems on tablets where there are e.g. 20 columns and 10 rows.

Is this normal? Do other users also have this issue? Is there something I can do about, or is it a principal problem with the large number of RecyclerViews?

Thanks!

Appilog avatar Jun 23 '17 19:06 Appilog

There are some performance problems in low-end devices, but 20 columns and 10 rows in my nexus5 is also have a good performance.What kind of mobile phone do you use to test?

zhouchaoyuan avatar Jun 28 '17 07:06 zhouchaoyuan

Thanks for your answer! I don't have the problem on smartphones! On smartphones the performance is relatively ok. The problem is on tablets, where much more cells are visible at the same time. I use a Galaxy Note 10.1 2014 for testing.

In the meantime I have solved the issues. It works now much more fluent on smartphones AND tablets.

In initWidget() I added the following settings for each RecyclerView:

    .setDrawingCacheEnabled(true);
    .setItemViewCacheSize(itemViewCacheSize);
    .setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);

In my case I could also add:

    .setHasFixedSize(true);

Then there were to many calls to the onScrollListeners. To reduce that I added the following lines:

For the horizontal listener (to avoid vertical handling):

    @Override
    public void onScrolled(RecyclerView recyclerView, int dx, int dy)
    {
        if (dy == 0 || Math.abs(dx) > Math.abs(dy))
        {
            return;
        }

...

and at the end of the method:

        for (int i = 0; i < mRecyclerView.getChildCount(); i++)
        {
            //Correct old Y-Positions of previously invisible recycler views while scrolling them in sight
            //from left or right side. Only correct first and last column because this is sufficient and
            //leads to a smoother scrolling
            if ((i == 0 || i == mRecyclerView.getChildCount() - 1) && mRecyclerView.getChildAt(i) instanceof RecyclerView)
            {
                RecyclerView recyclerView1 = (RecyclerView) mRecyclerView.getChildAt(i);
                fastScrollVertical(amountAxisY, recyclerView1);
            }
        }

for the vertical listener (to avoid horizontal handling):

    @Override
    public void onScrolled(RecyclerView recyclerView, int dx, int dy)
    {
        if (dy == 0 || Math.abs(dx) > Math.abs(dy))
        {
            return;
        }

Hope that helps! Thanks again for sharing your work!!

I'll send you an eMail with some off-topic questions concerning my app!

Thanks!

Appilog avatar Jul 05 '17 10:07 Appilog

性能确实有问题, 20行20列 还好 一但大几十行和列 就卡得不行, 检测内存看到快满了。 是不是单元格一直新建,没有替换。 导致我有多少行列就创相应的单元格呢? @zhouchaoyuan

dysen2014 avatar Jul 06 '17 02:07 dysen2014

@dysen2014 性能问题在数据大的时候不可避免,这里View肯定是复用的,但是data并没有复用,假如说 50 * 50 的数据,那么就需要有2500个对象(每个单元格需要一个data,这个暂时认为data是一个object),对于这么大的数据内存占用肯定就很大了,这种情况就好比一个listView有2500条数据,这样肯定会遇到性能瓶颈。

对于上面Appilog说的给ExcelPanel里面的每个RecyclerView使用下面的代码

.setDrawingCacheEnabled(true); .setItemViewCacheSize(itemViewCacheSize); .setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);

这个时候就可能导致大量的view缓存,内存立马就会爆炸,出现ANR 不过不得不否认Appilog的做法在内存允许的情况下是有性能优化的,但是数据一旦超过一个临界值,后果会比较严重

zhouchaoyuan avatar Jul 07 '17 09:07 zhouchaoyuan

@dysen2014 I'm very glad to hear that you have solved the issues mentioned above using the settings below:

    .setDrawingCacheEnabled(true);
    .setItemViewCacheSize(itemViewCacheSize);
    .setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);

So I try the codes like you do, but I found memory is increasing rapidly.

Monitors show the datas below: image

And here is the datas before configing: image

I guess that this may have a good performance when the data in some scale. But there are may have some issues(e.g. ARN or crash) when you reach the threshold.

zhouchaoyuan avatar Jul 07 '17 09:07 zhouchaoyuan

这里的 data 能不能用recyclerview 来做? 数据item用recyclerview替换textview?

Sent from Windows Mail

From: zhouchaoyuanmailto:[email protected] Sent: ‎Friday‎, ‎July‎ ‎7‎, ‎2017 ‎5‎:‎57‎ ‎PM To: zhouchaoyuan/excelPanelmailto:[email protected] Cc: dysenmailto:[email protected], Mentionmailto:[email protected]

@dysen2014https://github.com/dysen2014 I'm very glad to hear that you have solved the issues mentioned above using the settings below:

.setDrawingCacheEnabled(true);
.setItemViewCacheSize(itemViewCacheSize);
.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);

So I try the codes like you do, but I found memory is increasing rapidly.

Monitors show the datas below: [image]https://user-images.githubusercontent.com/7615900/27953091-21be35ca-633d-11e7-9049-198dee4327ab.png

And here is the datas before configing: [image]https://user-images.githubusercontent.com/7615900/27952633-951409a2-633b-11e7-93fa-e37877fd8c28.png

I guess that this may have a good performance when the data in some scale. But there are may have some issues(e.g. ARN or crash) when you reach the threshold.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/zhouchaoyuan/excelPanel/issues/22#issuecomment-313640166, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMKvxYtQcenj6nuhJon2cNNxGQvKltz8ks5sLgEMgaJpZM4OD8EZ.

dysen2014 avatar Jul 09 '17 23:07 dysen2014