Investigating Performance Issues in Mobile Apps
Total Page:16
File Type:pdf, Size:1020Kb
Doctoral Thesis Investigating Performance Issues in Mobile Apps PhD Program in Computer Science: XXX cycle Supervisor Prof Massimiliano Di Penta Author: [email protected] Teerath Das [email protected] Co-supervisor Ivano Malavolta [email protected] February 2020 GSSI Gran Sasso Science Institute Viale Francesco Crispi, 7 - 67100 L'Aquila - Italy Abstract The world is moving at a dynamic pace, and this has led to the technological advance- ment of mobile applications. This rise in the advancement of the mobile application comes with critical concerns to end-users in terms of the performance, especially when implementing high intensive features. Moreover, enjoyable user experience in terms of performance is often considered as the main parameter to measure the success of any app. Poor implementation of source code, lack of developers knowledge, and time con- straints on resolving performance issues are few of the major potential performance drawbacks in Android applications. To overcome these performance issues, in this dissertation, we focus on investigating the performance-related issues in open-source Android application (mainly apps from GitHub). Our thesis can be divided into four key research objectives: (i) initially we investigate on the extent to which developers consider performance issues in their com- mits (while maintaining their apps) and how they document it, (ii) to complement this study, we conduct an experiment to study the evolution of Android specific performance issues detected by Android Lint, and based on the obtained results, (iii) we introduce an Eclipse plugin that can be used to automatically resolve seven types of performance- related issues detected by Android Lint; in addition to this, we performed a survey-based study to analyze the self assessed performance refactoring code of the proposed tool from the developers' perspective; and (iv) we design and conduct a measurement-based study to examine the impact of performance violations at run-time. The key contributions of this thesis are (i) a taxonomy of developers' concerns about performance, obtained by applying card sorting technique on a dataset of commit mes- sages extracted from GitHub, (ii) the empirical research considering seven types of per- formance issues identified by Lint tool resulted: (a) a taxonomy for different kinds of evolution patterns of Android performance issues emerged by tracing the history of Android apps, (b) a catalog of documented performance issues resolved by Android de- velopers, (iii) an automatic refactoring tool to address the seven types of performance- related issues of Android Lint, (iv) developers perspective related to refactoring and non-refactoring code in the form of survey responses, and (v) a measurement-based study to analyze run-time performance of Android apps. These results provide develop- ers a base to take the next leap in solving performance-related issues in the mobile apps of the future. Acknowledgements With utmost respect, I would like to thanks Gran Sasso Science Institute (GSSI) and IMT Lucca for providing me an opportuinity to purse my doctoral studies. I would like to express all my gratitude to my PhD Supervisors, Prof. Massimiliano Di Penta, from University of Sannio, Benevento (Italy) and Ivano Malavolta from Vrije Universiteit Amsterdam (The Netherlands). Their continuous guidance, support and advices throughtout the course of my research made my thesis work possible. I am deeply thankful to them. I am highly indebted to Prof. Luca Aceto and Prof. Michele Flammini, the coordinators of the PhD program in Computer Science at GSSI for their kindness and willingness to help me at every stage, I needed. I am also very grateful to Prof. Rocco De Nicola for helping me in the initial days of my PhD. Further, I would like to extend my thanks to the reviewers, who gave their precious time to review the thesis. I am also grateful to dissertation committee members, for devoting their time for my dissertation defense. I am very much thankful to Prof. Mika Mantayla, M3S Research Unit, University of Oulu (Finland) for providing me work space and all the necessary help during my research visit. I would also like to thanks Prof. Patricia Lago from Vrije Universiteit Amsterdam (The Netherlands) for providing me working place during my research stay. I am extermly grateful to my brother Tanesh Kumar (and his wife), who helped me finanicially and morally throughout the extension period of my PhD. During the time of PhD, I feel bless to have friends who had been very supportive, specially Atith Sagar, Sagar Kumar, Rajinder Kumar, Syed M. Yasoob Bukhari and many more. I am also thankful to all the participants (developers), who took their time to participated in the survey. Last but not least, I am grateful to my family specially my wife and parents, without their love, support, and patience, this journey will not be easy. I would like to dedicate this thesis work to my wife, family and all the sath sangat. ii Contents Abstract i Acknowledgements ii List of Figures vi List of Tables viii 1 Introduction1 1.1 Mobile Applications and Performance....................1 1.2 Challenges....................................2 1.3 Research Questions...............................3 1.4 Research approach and method........................4 1.5 Contributions..................................5 1.6 Structure of this dissertation.........................6 2 Background8 2.1 Mobile Applications (apps)..........................8 2.1.1 Types of mobile apps.........................9 2.2 The Android Programming Model...................... 10 2.3 Static analysis and refactoring tools for Android apps........... 12 2.3.1 Static analysis tools.......................... 12 2.3.2 Automated Refactoring Tools..................... 14 3 State of the Art 16 3.1 Performance issues in mobile apps...................... 16 3.2 Evolution of statically-detectable issues................... 19 3.3 Studies using Linters.............................. 23 4 An Investigation of Performance-Related Commits in Android Apps 26 4.1 Study Design.................................. 27 4.2 Results...................................... 29 4.2.1 RQ1.1 - To what extent developers consider performance issues of Android apps?............................. 29 4.2.2 RQ1.2 - What are the concerns that developers have when dealing with performance issues of Android apps?.............. 31 4.3 Threats to Validity............................... 33 4.4 Conclusion................................... 34 iii Contents iv 5 Characterizing the evolution of statically-detectable performance is- sues of Android apps 35 5.1 Study Design.................................. 36 5.1.1 Goal and Research Questions..................... 36 5.1.2 Context Selection............................ 38 5.1.3 Data Extraction............................ 43 5.2 RQ2.0 Results { Performance issues identified by Android Lint...... 47 5.2.1 Data Analysis (RQ2.0)......................... 47 5.2.2 Results (RQ2.0)............................ 48 5.3 RQ2.1 Results { Evolution of the Number of Android Performance Issues over Time.................................... 54 5.3.1 Data Analysis (RQ2.1)......................... 54 5.3.2 Results (RQ2.1)............................ 56 5.4 RQ2.2 { Performance Issues remaining in Android Apps over Time.... 61 5.4.1 Data Analysis (RQ2.2)......................... 61 5.4.2 Results (RQ2.2)............................ 61 5.5 RQ2.3 Results { The Lifetime of Android Performance issues....... 63 5.5.1 Data Analysis (RQ2.3)......................... 63 5.5.2 Results (RQ2.3)............................ 64 5.6 RQ2.4 Results { Documented Resolutions of Android Performance Issues 67 5.6.1 Data Analysis (RQ2.4)......................... 67 5.6.2 Results (RQ2.4)............................ 70 5.7 Discussion.................................... 78 5.7.1 Summary of the study results..................... 78 5.7.2 Implications for Developers...................... 79 5.7.3 Implications for Researchers...................... 81 5.8 Threats to Validity............................... 88 5.9 Conclusions................................... 92 6 Automatic resolution of statically-detectable performance issues in An- droid apps 93 6.1 The Proposed Tool............................... 94 6.2 Performance Refactoring Rules........................ 96 6.2.1 DrawAllocation: Allocations within drawing code.......... 96 6.2.2 FloatMath: Using FloatMath instead of Math............ 98 6.2.3 HandlerLeak: Handler reference leaks................ 100 6.2.4 Recycle: Missing recycle() calls.................... 101 6.2.5 UseSparseArrays: HashMap can be replaced with SparseArray.. 103 6.2.6 UseValueOf: Should use valueOf instead of new.......... 105 6.2.7 ViewHolder: View Holder Candidates................ 106 6.3 Evaluation.................................... 109 6.3.1 Experiment 1 - Survey-based study.................. 110 6.3.2 Experiment 2 - Measurement-based study.............. 119 6.4 Discussion.................................... 125 6.5 Conclusions................................... 126 7 Conclusions 128 Contents v 7.1 Main Contributions............................... 128 7.2 Future Research Directions.......................... 131 List of Figures 1.1 Number of hours spent by different age groups on mobile apps [78].....2 1.2 Structure of this dissertation..........................6 2.1 Life-cycle of an Activity............................. 11 4.1 Apps identification process........................... 28 5.1 The dataset