Investigation of Battery Consumption by Using Accelerometer Sensor in Android: a Comparative Study Between Unity and Unreal Engine 4
Total Page:16
File Type:pdf, Size:1020Kb
Bachelor of Science in Computer Science May 2020 Investigation of battery consumption by using Accelerometer sensor in Android: A comparative study between Unity and Unreal Engine 4 Sesha Sai Kaushik, Upadhyayula Faculty of Computing, Blekinge Institute of Technology, 371 79 Karlskrona, Sweden This thesis is submitted to the Faculty of Computing at Blekinge Institute of Technology in partial fulfilment of the requirements for the degree of Bachelor of Science in Computer Science. The thesis is equivalent to 20 weeks of full time studies. The authors declare that they are the sole authors of this thesis and that they have not used any sources other than those listed in the bibliography and identified as references. They further declare that they have not submitted this thesis at any other institution to obtain a degree. Contact Information: Author(s): Sesha Sai Kaushik, Upadhyayula [email protected] University Advisor: Anwar, Mahwish [email protected] Department of Compter Science Faculty of Computing Internet : www.bth.se Blekinge Institute of Technology Phone : +46 455 38 50 00 SE–371 79 Karlskrona, Sweden Fax : +46 455 38 50 57 Abstract Smartphones consist of various applications and their development has increased in the past years. Several applications that are developed using game engines rely upon sensors that use plenty of battery life. This study evaluates the battery performance of two popular game engines by developing applications with usage of Accelerometer sensor and to find the most battery friendly engine. Unity and Unreal Engine 4 were selected for this study. It aims to fill how Game Engines performance differs when integrated with Accelerometer usage. Two similar test applications were developed in each game engine for the experiment and the battery values were recorded by AccuBattery. All these tests were performed to find out which game engine is battery friendly when integrated with the sensor and also compares how battery consumption differs in the game engines with and without sensor integration. The results show that Unity consumed 5.4 %(243 mAh) battery and Unreal Engine consumed 6.6 %(297.5 mAh) battery when applications were run at a frame lock of 60 FPS. When the tests were conducted at a frame lock of 30 FPS Unity consumed 1.84 % (82.8 mAh) battery and the Unreal Engine consumed 1.29 % (58.05 mAh) battery. These test results were analyzed with a previous study that compared Unity and Unreal Engine battery performance without any sensor integration. This test resulted in the Unreal Engine being battery-friendly when integrated sensor usage. Keywords: Unreal Engine, Unity, Android, Accelerometer, Sensors, Engine performance Acknowledgments I would like to express my sincere gratitude to my supervisor Mahwish Anwar for her valuable guidance and support during my Bachelor Thesis. This work would not be possible without her guidance and support. I would like to thank my parents for their everlasting love and blessings. I would like to thank my siblings and friends for their moral support through tough times. ii Contents Abstract i Acknowledgments ii 1 Introduction 2 2 Background and Related Work 3 2.1Unity.................................... 3 2.2 Unreal Engine 4 .............................. 4 2.3 Related Work ............................... 4 3 Research Questions and Method 5 3.1 Research Questions ............................ 5 3.1.1 Research Method ......................... 5 3.1.2 Development Environment and Settings ............ 5 3.1.3 Test Application Implementation ................ 6 3.1.4 Test Device ............................ 8 4 Results and Analysis 9 4.1 Results ................................... 9 5 Discussion 12 5.1 Limitations ................................ 13 6 Conclusions and Future Work 14 7 Appendix 15 References 18 iii List of Figures 3.1 Mapping input in Unity ......................... 6 3.2 Mapping input in Unreal ......................... 7 3.3 Blueprint in Unreal ............................ 7 4.1 Test results for applications run at 60 FPS ............... 9 4.2 Test results for applications run at 30 FPS ............... 10 4.3 Test results for applications ....................... 11 7.1 Unity camera ............................... 15 7.2 Unreal camera ............................... 15 7.3 Unreal application quality ........................ 16 7.4 Unity application quality . ..................... 16 7.5 Unity FPS control ............................ 16 7.6 Unreal FPS control ............................ 17 7.7 Unity accelerometer code ........................ 17 iv List of Tables 3.1 Specifications . ............................ 8 1 Chapter 1 Introduction Android has become one of the most used platforms in smartphones. There are over two billion smartphones that run on Android [1]. Android offers the play store which houses millions of applications, ranging from social applications such as Facebook, Instagram, to games such as PUBG, Sky, etc. In recent years there has been an increase in the number of applications released in play store [2] of which approximately 0.3% new games are added each quarter [3]. Android games are developed using game engines that are optimised for Android development. One of the major compromises of Android games is that they consume substantial battery [4]. There are many games available for Android, the level of optimisation and battery consumption might be different for each game, respectively. Most of the games are designed by using game engines that provide a basic template to design an application in Android. Unreal Engine and Unity are two of the most used game engines for Android game development. Each game engine provides different kinds of optimisations, some of which are built in the engine while some can be set by the developer. Accelerometer is used to measure the linear acceleration of the device [5]. It is widely used in developing games which track movements of the device in the developed application environment. The level of optimisations can be of several types such as graphical, level, build, and compile optimisations. Developers use sensors in an Android application to create an interaction between the user and the application. Sensor integrations lead to an increase in battery consumption. Sensor integrated applications should contain optimisations for typical usage and graphical inputs by adding extra layers to the existing Android optimisations, which can increase the battery life of the smartphone. Battery optimisations are frequently done for hand-held devices because applica- tions tend to consume as much power it receives in any other platform. So, battery optimisations must be done and it plays an essential role in smartphone performance as it leads to longer battery life. This study is inspired by [6] where the research was conducted on the battery performance of Unity and Unreal Engine on Android with limitation to sensor usage. This work will overcome the identified limitation by investigating the impact on battery consumption when the Accelerometer sensor is integrated with the application. 2 Chapter 2 Background and Related Work Android is an operating system developed for hand-held devices. The first Android phone was released in 2008. All the smartphones launched in this period were prone to short battery life [7]. Optimisations were made to decrease the battery consumption in the software that extended the battery life of the devices. Smartphones now last for around 5-8 hours with heavy usage. More and more optimisations are being developed to increase the functionality, privacy of the smartphones which are rolled out in the form of updates. Android games tend to use hefty amounts of battery to provide the best quality and performance to the user. Specific optimisations can decrease battery consumption such as lower graphical input, frame rate, etc. The battery optimisation can increase the screen time of the device but compromises the performance of the application and vice versa. Another factor that influences battery consumption is its background applications. Certain applications such as UI, Android Web View, etc. run in the background and results to battery consumption. Games downloaded from the play store also consume battery until they are loaded in the memory of the phone. Games are developed for Android by using game engines where Unreal Engine and Unity are popular choices for game development. 2.1 Unity Unity game engine was launched in the year 2005 in Mac OS X. In the year 2008 when the App Store was launched for the iPhone, Unity added support for iPhones. In 2010, Unity was released for development in Android, PC, and Consoles. It provides developers with API(Application Program Interface) and frameworks. Fractal was the first game to be developed in Unity for iOS and Android [8][9]. Key Features of Unity connected to this thesis are: • All-in-One Editor and configured 3D objects and shapes. • Native C++ which can be used for multi-platform support. • Easy control over design and placing objects and scaling. • Control over Android sensors with coding using Android development API. • Real-time graphics rendering. 3 Chapter 2. Background and Related Work 4 2.2 Unreal Engine 4 Unreal Engine was launched in 1998. It was initially developed for first-person shooters but also used in other genres of development. Unreal Engine 2, released in 2008 added features like skeletal animation and physical simulations. Unreal Engine 3 was released in 2004 with fully programmable shader hardware, lighting, and shadowing