Kiss: Performance improvement suggestion

Created on 10 Dec 2016  路  14Comments  路  Source: Neamar/KISS

Dear developers,
I found a bitmap displaying issues in Kiss. These issues could affect performance.
In the position of Kiss:
fr.neamar.kiss.IconsHandler.java cacheGetDrawable()
the bitmap object is created with the invocation of decodeStream().

I found cacheGetDrawable() is invoked indirectly by:
fr.neamar.kiss.adapter.RecordAdapter.java getView()
getView() callbacks are frequently invoked in the UI thread and this means that there will be many bitmap objects being created.

Maybe we can define memory cache to store the bitmap objects. Then app can reuse them instead of creating new bitmap objects continuously. Also, we can use the Option.inbitmap to reuse the memory space of existing bitmap objects, which will greatly reduce the memory consumption and improves app's performance.

By the way, for bitmap displaying, I was also wondering why you do not use third-party libraries such as picasso, glide? Would you mind sharing some thoughts?

Looking forward to your response and hope I can help improve Kiss.
Thanks.

References:
https://developer.android.com/training/displaying-bitmaps/cache-bitmap.html
the use of inbitmap: https://www.youtube.com/watch?v=_ioFW3cyRV0&list=PLWz5rJ2EKKc9CBxr3BVjPTPoDPLdPIFCE&index=54
https://developer.android.com/training/displaying-bitmaps/manage-memory.html

Most helpful comment

I agree we should put some more time on that, sometimes icon can take a lot of time to show. There must be a way that other launchers use to efficiently cache other drawables. We should draw inspiration from them!

@Neamar care to re-open?

All 14 comments

If I understood this correctly, we avoid using third-party libraries to keep KISS' size under one MB. The purpose of this launcher is to be very, very light and effective, nonetheless.

Hello DMSalesman,
Thanks for your reply.
I found you have implemented disk cache in Kiss, but memory cache is faster than disk cache, maybe memory cache can make Kiss run more smoothly. Also, the use of Option.inbitmap can make you use an existing memory chip to load bitmap, rather than consume new memory chip.
Do you think these additional optimization will improve Kiss?

Any data on memory usage difference?

Sorry, @licaon-kter ,I didn't quite understand what you mean. Could you explain it more clearly ?

You need to store those bitmaps somewhere, right? So, you'll use RAM space.

@licaon-kter , Yes, we can use some RAM space to avoid the repeated decoding operation for the repeated use of the same image. If we need to minimize the use of RAM space, maybe the use of BitmapFactory.Options.inBitmap is another choice.

Ok, so, how much more RAM you'd use for 50 apps? For 100? For 200? Since this is a lightweight launcher you might bog it down by using too much RAM.

@licaon-kter , Yes, I agree with you. Memory cache is memory consuming and hinders the achievement of our goal.
By the way, the use of BitmapFactory.Options.inBitmap will not consume additional RAM space, and it can reuse the RAM space that occupied by existing bitmap objects. Do you think it will make Kiss more lightweight ?

Hey! Didn't see this discussion going on.

We're currently in the process of reviewing/testing #533, which implements a memory + fs cache for the drawables. I didn't know about BitmapFactory.Options.inBitmap, but it does look good!

Interesting discussion, when I developed the icon support I thought to persist generated icons to filesystem to reduce the load on CPU.
I have not thought about the RAM because a smartphone is not like a computer, and RAM and storage share the same technology (NAND cells) and the overead of a filesystem like ext4 or f2fs is not really a bottlenek compared to traditional hard disk vs RAM.
Another thing to keep in mind is that an app like KISS (that is often in background) after a while are subject to garbage collection and the resources used could be set free, specially on a low budget phone. So a cache in RAM don't know what can help (personally I don't spend much time to scroll history)

It would be nice to do most extensive tests

Cheers
Michele

A new way to display icons was merged recently into master.

Closing this issue

On my Moto E Gen 2 4G I'm seeing icons not loaded (transparent) when I scroll for the first time, something that would never happen with Glide (so this can be fixed). I think this issue should be reopened.

I agree we should put some more time on that, sometimes icon can take a lot of time to show. There must be a way that other launchers use to efficiently cache other drawables. We should draw inspiration from them!

@Neamar care to re-open?

@saveman71 would you mind creating a new issue instead? This one is already quite long and talks about various things that are not relevant in KISS anymore. Might be worth starting from scratch :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  5Comments

EmmanuelMess picture EmmanuelMess  路  7Comments

Wilker-a picture Wilker-a  路  7Comments

cfytrok picture cfytrok  路  7Comments

NikhilSudhakaranVG picture NikhilSudhakaranVG  路  5Comments