Giter Site home page Giter Site logo

audulus / realtimewatchdog Goto Github PK

View Code? Open in Web Editor NEW

This project forked from theamazingaudioengine/realtimewatchdog

0.0 3.0 0.0 22 KB

A library for iOS audio which acts as a watchdog for unsafe activity on the audio thread

License: Other

Ruby 8.48% Assembly 42.92% Objective-C 48.61%

realtimewatchdog's Introduction

Realtime Thread Safety Watchdog

This library for iOS acts as a watchdog for activities on the Core Audio thread that are considered unsafe:

  1. Taking locks
  2. Allocating memory
  3. Using Objective-C
  4. File or network IO

It works by overriding a number of system functions, including malloc, free, objc_storeStrong, objc_msgSend (for 64-bit devices and the 64-bit simulator only, for now), pthread_mutex_lock and objc_sync_enter, read, write, etc. When a call is intercepted, a warning is printed to the console. You can also put a breakpoint on AERealtimeWatchdogUnsafeActivityWarning.

It won’t catch everything, and it won’t catch anything in Apple’s own system code, but it’ll catch some locks, some memory allocation, all Objective-C use (but not Swift), all object retains, and some common IO tasks, in your code and that of any static libraries you’re using.

This library is also built into The Amazing Audio Engine 2.

Idea by Taylor Holliday, implemented by Michael Tyson.

Usage

With Cocoapods: add the "RealtimeWatchdog" pod to your Podfile, and call pod install. Done!

Without Cocoapods:

  1. Drag RealtimeWatchdog.xcodeproj into your project.
  2. Select your app target's Build Settings, open the "Link Binary With Libraries" item, click the "+" button and select libRealtimeWatchdog.a. Done.

If you get any errors about implicit depedencies, you may also need to open the "Target Dependencies" item, and add RealtimeWatchdog there.

You can easily disable the monitor by commenting out the #define REALTIME_WATCHDOG_ENABLED 1 line in AERealtimeWatchdog.h.

It will only be active for debug builds, so you can leave it on safely.

Note that for 64-bit devices and the 64-bit simulator, this library provides its own wrapper implementation of objc_msgSend, which means Objective-C method calls will be marginally slower.

For more discussion on realtime thread safety, see this article: Four common mistakes in audio development.

Realtime Thread Safety Watchdog License

Copyright (C) 2012-2016 A Tasty Pixel

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.

  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.

  3. This notice may not be removed or altered from any source distribution.

realtimewatchdog's People

Contributors

michaeltyson avatar wtholliday avatar gbevin avatar

Watchers

James Cloos avatar  avatar  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.