android icon indicating copy to clipboard operation
android copied to clipboard

Possible causes of Hang-Bugs Found

Open brok85 opened this issue 9 years ago • 0 comments

Dear SageMath Developers, I am implementing a hang-bug detection tool and I am analyzing Sagemath with it (master version downloaded today). I tested the app with a Nexus 4 (Android 5.1) and Huawei P8 Lite (Android 4.4). I found that the main thread of SageMath calls:

  1. com.google.gson.Gson.toJson(Gson.java:509) and
  2. nl.qbusict.cupboard.DatabaseCompartment.put(DatabaseCompartment.java:331)

frequently when playing a script to plot a graph. In particular, the above APIs are called as consequence of the following call:

1) org.sagemath.droid.models.gson.InteractReply.toString(InteractReply.java:28) -> com.google.gson.Gson.toJson(Gson.java:509)

2) org.sagemath.droid.fragments.AsyncTaskFragment.query(AsyncTaskFragment.java:104) -> com.google.gson.Gson.toJson(Gson.java:509)

3) org.sagemath.droid.database.SageSQLiteOpenHelper.getCellbyID(SageSQLiteOpenHelper.java:390) -> nl.qbusict.cupboard.DatabaseCompartment.get(DatabaseCompartment.java:247)

In my experiments, the execution of those functions on the main thread may be the main cause of the eye-detectable delays (i.e., hang-bugs) experienced with SageMath.

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 those two operations off the main thread using background threads. Therefore, do you think that the smoothness of the app would improve by executing those functions off the main thread?

Thanks for any information, I hope I can help improve SageMath.

brok85 avatar May 03 '16 22:05 brok85