From 3d8bc1cf8bb7c797d847487683cd9ab4c20fa705 Mon Sep 17 00:00:00 2001 From: Pascal Muetschard Date: Fri, 5 Apr 2019 16:02:53 -0700 Subject: [PATCH] Allow Perfetto traces without specifying an application. --- .../com/google/gapid/views/TracerDialog.java | 7 ++-- gapis/service/service.proto | 2 ++ gapis/trace/android/trace.go | 32 ++++++++++--------- .../trace/tracer/default_api_trace_options.go | 3 ++ 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/gapic/src/main/com/google/gapid/views/TracerDialog.java b/gapic/src/main/com/google/gapid/views/TracerDialog.java index c8baa56aba..cb588b6e56 100644 --- a/gapic/src/main/com/google/gapid/views/TracerDialog.java +++ b/gapic/src/main/com/google/gapid/views/TracerDialog.java @@ -582,9 +582,10 @@ protected String formatTraceName(String name) { } public boolean isReady() { - return getSelectedDevice() != null && getSelectedApi() != null && - !traceTarget.getText().isEmpty() && !directory.getText().isEmpty() && - !file.getText().isEmpty(); + TraceTypeCapabilities config = getSelectedApi(); + return getSelectedDevice() != null && config != null && + (!config.getRequiresApplication() || !traceTarget.getText().isEmpty()) && + !directory.getText().isEmpty() && !file.getText().isEmpty(); } public void addModifyListener(Listener listener) { diff --git a/gapis/service/service.proto b/gapis/service/service.proto index 86c4e1efa4..f9144a73be 100644 --- a/gapis/service/service.proto +++ b/gapis/service/service.proto @@ -1235,6 +1235,8 @@ message TraceTypeCapabilities { FeatureStatus mid_execution_capture_support = 3; // Whether unsupported extensions can be enabled. bool can_enable_unsupported_extensions = 4; + // Does this trace require starting an application. + bool requires_application = 6; } // GetTimestampsRequest is the request send to server to get the timestamps for diff --git a/gapis/trace/android/trace.go b/gapis/trace/android/trace.go index b9b220616d..ecbb015296 100644 --- a/gapis/trace/android/trace.go +++ b/gapis/trace/android/trace.go @@ -449,26 +449,28 @@ func (t *androidTracer) SetupTrace(ctx context.Context, o *service.TraceOptions) match[1], match[3], strings.Join(lines, "\n ")) } - } else { + } else if o.Type != service.TraceType_Perfetto || len(o.GetUri()) != 0 { return ret, nil, fmt.Errorf("Could not find package matching %s", o.GetUri()) } - if !pkg.Debuggable { - err = t.b.Root(ctx) - switch err { - case nil: - case adb.ErrDeviceNotRooted: - return ret, cleanup.Invoke(ctx), err - default: - return ret, cleanup.Invoke(ctx), fmt.Errorf("Failed to restart ADB as root: %v", err) + if pkg != nil { + if !pkg.Debuggable { + err = t.b.Root(ctx) + switch err { + case nil: + case adb.ErrDeviceNotRooted: + return ret, cleanup.Invoke(ctx), err + default: + return ret, cleanup.Invoke(ctx), fmt.Errorf("Failed to restart ADB as root: %v", err) + } + log.I(ctx, "Device is rooted") } - log.I(ctx, "Device is rooted") - } - if o.ClearCache { - log.I(ctx, "Clearing package cache") - if err := pkg.ClearCache(ctx); err != nil { - return ret, nil, err + if o.ClearCache { + log.I(ctx, "Clearing package cache") + if err := pkg.ClearCache(ctx); err != nil { + return ret, nil, err + } } } diff --git a/gapis/trace/tracer/default_api_trace_options.go b/gapis/trace/tracer/default_api_trace_options.go index 578a797048..6d4695a2bc 100644 --- a/gapis/trace/tracer/default_api_trace_options.go +++ b/gapis/trace/tracer/default_api_trace_options.go @@ -26,6 +26,7 @@ func VulkanTraceOptions() *service.TraceTypeCapabilities { CanDisablePcs: false, MidExecutionCaptureSupport: service.FeatureStatus_Supported, CanEnableUnsupportedExtensions: true, + RequiresApplication: true, } } @@ -37,6 +38,7 @@ func GLESTraceOptions() *service.TraceTypeCapabilities { CanDisablePcs: true, MidExecutionCaptureSupport: service.FeatureStatus_Experimental, CanEnableUnsupportedExtensions: false, + RequiresApplication: true, } } @@ -47,5 +49,6 @@ func PerfettoTraceOptions() *service.TraceTypeCapabilities { CanDisablePcs: false, MidExecutionCaptureSupport: service.FeatureStatus_Supported, CanEnableUnsupportedExtensions: false, + RequiresApplication: false, } }