Giter Club home page Giter Club logo

unitysystraceplugin's Introduction

Unity Systrace Plugin for Android

Systrace screenshot

Unity profiler has a nice timeline view with named sections. It may be very helpful to have these sections displayed on a system-wide trace collected from an Android device using systrace tool, as it gives information about scheduling, CPU status, other processes running in the system etc. In version 2018.2, Unity introduced a profiler native plugin API; used together with Android tracing API, it allows to develop an integration plugin.

IMPORTANT NOTE: In Unity 2019.1, native systrace support has been introduced (with same functionality as this plugin). It means that starting from 2019.1, there is no need to use this plugin - everything should just work out of the box.

Few comments on the implementation:

  • Android tracing API works on Marshmallow and later; but since Unity supports older devices, I used dynamic linking. On older devices, a warning is printed, and the Unity profiler integration is disabled.
  • To load a native plugin in Android, Unity requires a P/Invoke call to an imported native method. Because of this a script was added; make sure to attach it to a game object in your scene!
  • Due to optimization (the plugin checks if systrace is connected every frame, and if it is - registers callbacks for profiler markers; if no systrace is connected - no callbacks are happening for every profiler marker) Unity markers can show up from the next frame after starting the systrace capture.

System Requirements

  • Unity 2018.2 or later (NOTE: systrace support is integrated into Unity 2019.1, so starting from this version there is no need to use this plugin)
  • Android device with Android 6.0 Marshmallow or later

Usage

  1. Copy the contents of Assets directory to your project (it will be easier if you retain the path, then the plugin importer will set CPU architecture for the .so's correctly)
  2. Attach the Assets/Scripts/SystracePlugin.cs script to a game object of your choice in your first scene to make sure the plugin is loaded as early as possible
  3. Enjoy

How to Build

Run ndk-build in src/ directory of the repo. Grab the libraries in src/libs/

Useful Links

License

Licensed under Apache 2.0.

Unity Native Plugin API headers licensed under Unity Companion License, please see the header contents for details.

unitysystraceplugin's People

Contributors

over17 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.