ricknout / lens-launcher

A unique, efficient way to browse and launch your apps
https://experiments.withgoogle.com/lens-launcher
Apache License 2.0
216 stars 61 forks source link

Possible cause of Hang-Bugs Found #15

Open brok85 opened 8 years ago

brok85 commented 8 years ago

Dear Developers,

I am implementing a hang-bug detection tool and I am analyzing lens-launcher with it (commit number e41e6c6). I found that the main thread of lens-launcher frequently calls:

com.orm.SugarRecord.save(SugarRecord.java:416)

In particular, the above API is called as consequence of the following call:

nickrout.lenslauncher.model.AppPersistent.incrementAppCount(AppPersistent.java:108) -> com.orm.SugarRecord.save(SugarRecord.java:416)

which then performs a database operation by calling

android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1469)

In my experiments, the execution of that function on the main thread may be the main cause of the eye-detectable delays (i.e., hang-bugs) experienced with lens-launcher .

As the developers guide of Android suggests, moving work off the main thread leads to higher responsiveness of the app. It is actually possible to move that operation off the main thread using background threads.

Therefore, do you think that the smoothness of the app would improve by executing the com.orm.SugarRecord.save API off the main thread?

Thanks for any information, I hope I can help improve lens-launcher.