Realtime Thread Safety Watchdog
This library for iOS acts as a watchdog for activities on the Core Audio thread that are considered unsafe:
- Taking locks
- Allocating memory
- Using Objective-C
- File or network IO
It works by overriding a number of system functions, including
objc_msgSend (for 64-bit devices and the 64-bit simulator only, for now),
write, etc. When a call is intercepted, a warning is printed to the console. You can also put a breakpoint on
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.
With Cocoapods: add the "
RealtimeWatchdog" pod to your Podfile, and call
pod install. Done!
- Drag RealtimeWatchdog.xcodeproj into your project.
- 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
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:
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.
Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
This notice may not be removed or altered from any source distribution.