NightWhistler / PageTurner

Android e-book reader with cloud synchronization
pageturner-reader.org
GNU General Public License v3.0
466 stars 222 forks source link

perf #583

Open kangyu opened 9 years ago

kangyu commented 9 years ago

We are working on a project called PersisDroid (http://www.cudroid.com/PersisDroid/) for detecting potential performance issues. Our tool could find performance degradation caused by improper usage of asynchronous executions. We find that in some cases your app may suffer a long processing delay.

Case 1: Related source code Class: LoadOPDSTask Method: doInBackground Circumstance Sometimes the network condition is poor. The user may switch activity before the OPDSfeed is obtained. The operation of request the feed should be cancelled as soon as possible. Problem Some network request AsyncTasks are already cancelled but they are not stop immediately. These tasks may consume unnecessary network resource. Suggested modification Check one more time whether the task is cancelled after the second network request via isCancelled() method.

Case 2: Related source code Class: ReadingFragment Method: sendProgressUpdateToServer Circumstance The progress update sometimes delays too long to send to the server, which may cause the progress incorrect on next loading. Problem All the background works share one handler (_backgroundHandler). The background tasks are posted on one handler which means they have to run sequentially if multiple tasks are invoked simultaneously. _Suggested modification* Use a separate handler for progress updating.