Fix ANR in the trace code - TraceOrchestrator and TraceControl deadlock
Summary:
{F853107317}
TraceOrchestrator and TraceControl are locked in different sequence in two places.
We don't need to lock the TraceOrchestrator object when calling `tc.abortTraceWithReason` at L660.
@@ -651,7 +651,7 @@ public final class TraceOrchestrator
*
* @return true if the cleanup succeeded, false otherwise
*/
- public synchronized boolean clearConfigurationAndTraces() {
+ public boolean clearConfigurationAndTraces() {
setConfigProvider(new DefaultConfigProvider());
TraceControl tc = TraceControl.get();
if (tc != null) {
@@ -661,8 +661,10 @@ public final class TraceOrchestrator
ctx.controller, ctx.context, ctx.longContext, ProfiloConstants.ABORT_REASON_LOGOUT);
}
}
+ synchronized (this) {
return mFileManager.deleteAllFiles();
}
+ }
/** Returns all known trace files. Only use for crash reporting. */
public synchronized Iterable<File> getAllTraceFilesForCrashReport() {
