Diagnostics
Tracking down audio issues can be quite challenging, since they are hard to reproduce. We developed the diagnostics feature in order to mitigate this issue. By enabling the diagnostics feature it's possible to export a zip file which contains the recordings from different processing states.
For example, if we want to record audio using the RecorderNode
and also apply noise filtering through the NoiseFilterNode
, then the exported diagnostics will contain two recordings: one raw audio file without the noise filter applied, and one audio file with the noise filter enabled. The recordings are by default 30 seconds long, but this can be customized. Device information and logs are also part of the diagnostic data.
Enabling Diagnostics Data Collection
Diagnostics collection can be enabled and disabled through the AudioGraph
:
- Swift
- Kotlin
audioGraph.enableDiagnosticsDataCollection(true)
audioGraph.enableDiagnosticsDataCollection(true)
Exporting the Diagnostics Package
Upon encountering an audio problem during app operation, a diagnostics package can be created and exported with the following call, while passing in an arbitrary string that identifies the export file:
- Swift
- Kotlin
audioGraph.exportDiagnosticData(id: String) { diagnosticFileURL in
// Diagnostic file is ready. This callback is called on the main thread.
let activityItems: [URL] = [diagnosticFileURL]
let activityViewController = UIActivityViewController(activityItems: activityItems, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view
self.present(activityViewController, animated: true, completion: nil)
}
audioGraph.exportDiagnosticData(id: String) { diagnosticFilePath: String ->
// Diagnostic file is ready. This callback is called on the main thread.
val uri: Uri = FileProvider.getUriForFile(
getApplicationContext(),
myActivityContext.packageName + ".provider",
File(diagnosticFilePath)
val intent: Intent = ShareCompat.IntentBuilder.from(myActivityContext)
.setType("application/zip")
.setStream(uri)
.createChooserIntent()
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
myActivity.startActivity(intent)
}
Export time and memory usage is affected by the total number of connections between nodes in the audio graph.