Add android.sdk_sysprop_guard data source
This will be used to control the system properties that guard
initialization of the Perfetto SDK and track_event data source in
Skia, in both HWUI and SurfaceFlinger/RenderEngine.
Kept separate from code/logic changes to allow for reverts of logic.
Test: existing presubmits, proto and build only change.
Bug: 279614916
Change-Id: I5025925039fcaa37a1208c658dfbc995389333f3
diff --git a/Android.bp b/Android.bp
index 1d880c5..b944c04 100644
--- a/Android.bp
+++ b/Android.bp
@@ -2644,6 +2644,7 @@
"protos/perfetto/config/android/android_game_intervention_list_config.proto",
"protos/perfetto/config/android/android_log_config.proto",
"protos/perfetto/config/android/android_polled_state_config.proto",
+ "protos/perfetto/config/android/android_sdk_sysprop_guard_config.proto",
"protos/perfetto/config/android/android_system_property_config.proto",
"protos/perfetto/config/android/network_trace_config.proto",
"protos/perfetto/config/android/packages_list_config.proto",
@@ -2659,6 +2660,7 @@
"external/perfetto/protos/perfetto/config/android/android_game_intervention_list_config.gen.cc",
"external/perfetto/protos/perfetto/config/android/android_log_config.gen.cc",
"external/perfetto/protos/perfetto/config/android/android_polled_state_config.gen.cc",
+ "external/perfetto/protos/perfetto/config/android/android_sdk_sysprop_guard_config.gen.cc",
"external/perfetto/protos/perfetto/config/android/android_system_property_config.gen.cc",
"external/perfetto/protos/perfetto/config/android/network_trace_config.gen.cc",
"external/perfetto/protos/perfetto/config/android/packages_list_config.gen.cc",
@@ -2674,6 +2676,7 @@
"protos/perfetto/config/android/android_game_intervention_list_config.proto",
"protos/perfetto/config/android/android_log_config.proto",
"protos/perfetto/config/android/android_polled_state_config.proto",
+ "protos/perfetto/config/android/android_sdk_sysprop_guard_config.proto",
"protos/perfetto/config/android/android_system_property_config.proto",
"protos/perfetto/config/android/network_trace_config.proto",
"protos/perfetto/config/android/packages_list_config.proto",
@@ -2689,6 +2692,7 @@
"external/perfetto/protos/perfetto/config/android/android_game_intervention_list_config.gen.h",
"external/perfetto/protos/perfetto/config/android/android_log_config.gen.h",
"external/perfetto/protos/perfetto/config/android/android_polled_state_config.gen.h",
+ "external/perfetto/protos/perfetto/config/android/android_sdk_sysprop_guard_config.gen.h",
"external/perfetto/protos/perfetto/config/android/android_system_property_config.gen.h",
"external/perfetto/protos/perfetto/config/android/network_trace_config.gen.h",
"external/perfetto/protos/perfetto/config/android/packages_list_config.gen.h",
@@ -2708,6 +2712,7 @@
"protos/perfetto/config/android/android_game_intervention_list_config.proto",
"protos/perfetto/config/android/android_log_config.proto",
"protos/perfetto/config/android/android_polled_state_config.proto",
+ "protos/perfetto/config/android/android_sdk_sysprop_guard_config.proto",
"protos/perfetto/config/android/android_system_property_config.proto",
"protos/perfetto/config/android/network_trace_config.proto",
"protos/perfetto/config/android/packages_list_config.proto",
@@ -2722,6 +2727,7 @@
"external/perfetto/protos/perfetto/config/android/android_game_intervention_list_config.pb.cc",
"external/perfetto/protos/perfetto/config/android/android_log_config.pb.cc",
"external/perfetto/protos/perfetto/config/android/android_polled_state_config.pb.cc",
+ "external/perfetto/protos/perfetto/config/android/android_sdk_sysprop_guard_config.pb.cc",
"external/perfetto/protos/perfetto/config/android/android_system_property_config.pb.cc",
"external/perfetto/protos/perfetto/config/android/network_trace_config.pb.cc",
"external/perfetto/protos/perfetto/config/android/packages_list_config.pb.cc",
@@ -2737,6 +2743,7 @@
"protos/perfetto/config/android/android_game_intervention_list_config.proto",
"protos/perfetto/config/android/android_log_config.proto",
"protos/perfetto/config/android/android_polled_state_config.proto",
+ "protos/perfetto/config/android/android_sdk_sysprop_guard_config.proto",
"protos/perfetto/config/android/android_system_property_config.proto",
"protos/perfetto/config/android/network_trace_config.proto",
"protos/perfetto/config/android/packages_list_config.proto",
@@ -2751,6 +2758,7 @@
"external/perfetto/protos/perfetto/config/android/android_game_intervention_list_config.pb.h",
"external/perfetto/protos/perfetto/config/android/android_log_config.pb.h",
"external/perfetto/protos/perfetto/config/android/android_polled_state_config.pb.h",
+ "external/perfetto/protos/perfetto/config/android/android_sdk_sysprop_guard_config.pb.h",
"external/perfetto/protos/perfetto/config/android/android_system_property_config.pb.h",
"external/perfetto/protos/perfetto/config/android/network_trace_config.pb.h",
"external/perfetto/protos/perfetto/config/android/packages_list_config.pb.h",
@@ -2770,6 +2778,7 @@
"protos/perfetto/config/android/android_game_intervention_list_config.proto",
"protos/perfetto/config/android/android_log_config.proto",
"protos/perfetto/config/android/android_polled_state_config.proto",
+ "protos/perfetto/config/android/android_sdk_sysprop_guard_config.proto",
"protos/perfetto/config/android/android_system_property_config.proto",
"protos/perfetto/config/android/network_trace_config.proto",
"protos/perfetto/config/android/packages_list_config.proto",
@@ -2785,6 +2794,7 @@
"external/perfetto/protos/perfetto/config/android/android_game_intervention_list_config.pbzero.cc",
"external/perfetto/protos/perfetto/config/android/android_log_config.pbzero.cc",
"external/perfetto/protos/perfetto/config/android/android_polled_state_config.pbzero.cc",
+ "external/perfetto/protos/perfetto/config/android/android_sdk_sysprop_guard_config.pbzero.cc",
"external/perfetto/protos/perfetto/config/android/android_system_property_config.pbzero.cc",
"external/perfetto/protos/perfetto/config/android/network_trace_config.pbzero.cc",
"external/perfetto/protos/perfetto/config/android/packages_list_config.pbzero.cc",
@@ -2800,6 +2810,7 @@
"protos/perfetto/config/android/android_game_intervention_list_config.proto",
"protos/perfetto/config/android/android_log_config.proto",
"protos/perfetto/config/android/android_polled_state_config.proto",
+ "protos/perfetto/config/android/android_sdk_sysprop_guard_config.proto",
"protos/perfetto/config/android/android_system_property_config.proto",
"protos/perfetto/config/android/network_trace_config.proto",
"protos/perfetto/config/android/packages_list_config.proto",
@@ -2815,6 +2826,7 @@
"external/perfetto/protos/perfetto/config/android/android_game_intervention_list_config.pbzero.h",
"external/perfetto/protos/perfetto/config/android/android_log_config.pbzero.h",
"external/perfetto/protos/perfetto/config/android/android_polled_state_config.pbzero.h",
+ "external/perfetto/protos/perfetto/config/android/android_sdk_sysprop_guard_config.pbzero.h",
"external/perfetto/protos/perfetto/config/android/android_system_property_config.pbzero.h",
"external/perfetto/protos/perfetto/config/android/network_trace_config.pbzero.h",
"external/perfetto/protos/perfetto/config/android/packages_list_config.pbzero.h",
@@ -2910,6 +2922,7 @@
"protos/perfetto/config/android/android_game_intervention_list_config.proto",
"protos/perfetto/config/android/android_log_config.proto",
"protos/perfetto/config/android/android_polled_state_config.proto",
+ "protos/perfetto/config/android/android_sdk_sysprop_guard_config.proto",
"protos/perfetto/config/android/android_system_property_config.proto",
"protos/perfetto/config/android/network_trace_config.proto",
"protos/perfetto/config/android/packages_list_config.proto",
@@ -5019,6 +5032,7 @@
"protos/perfetto/config/android/android_game_intervention_list_config.proto",
"protos/perfetto/config/android/android_log_config.proto",
"protos/perfetto/config/android/android_polled_state_config.proto",
+ "protos/perfetto/config/android/android_sdk_sysprop_guard_config.proto",
"protos/perfetto/config/android/android_system_property_config.proto",
"protos/perfetto/config/android/network_trace_config.proto",
"protos/perfetto/config/android/packages_list_config.proto",
@@ -11790,6 +11804,7 @@
"protos/perfetto/config/android/android_game_intervention_list_config.proto",
"protos/perfetto/config/android/android_log_config.proto",
"protos/perfetto/config/android/android_polled_state_config.proto",
+ "protos/perfetto/config/android/android_sdk_sysprop_guard_config.proto",
"protos/perfetto/config/android/android_system_property_config.proto",
"protos/perfetto/config/android/network_trace_config.proto",
"protos/perfetto/config/android/packages_list_config.proto",
diff --git a/BUILD b/BUILD
index 3d9316d..a33b35f 100644
--- a/BUILD
+++ b/BUILD
@@ -3528,6 +3528,7 @@
"protos/perfetto/config/android/android_game_intervention_list_config.proto",
"protos/perfetto/config/android/android_log_config.proto",
"protos/perfetto/config/android/android_polled_state_config.proto",
+ "protos/perfetto/config/android/android_sdk_sysprop_guard_config.proto",
"protos/perfetto/config/android/android_system_property_config.proto",
"protos/perfetto/config/android/network_trace_config.proto",
"protos/perfetto/config/android/packages_list_config.proto",
diff --git a/protos/perfetto/config/android/BUILD.gn b/protos/perfetto/config/android/BUILD.gn
index ed1d9ea..898f4b2 100644
--- a/protos/perfetto/config/android/BUILD.gn
+++ b/protos/perfetto/config/android/BUILD.gn
@@ -21,6 +21,7 @@
"android_game_intervention_list_config.proto",
"android_log_config.proto",
"android_polled_state_config.proto",
+ "android_sdk_sysprop_guard_config.proto",
"android_system_property_config.proto",
"network_trace_config.proto",
"packages_list_config.proto",
diff --git a/protos/perfetto/config/android/android_sdk_sysprop_guard_config.proto b/protos/perfetto/config/android/android_sdk_sysprop_guard_config.proto
new file mode 100644
index 0000000..4bacd58
--- /dev/null
+++ b/protos/perfetto/config/android/android_sdk_sysprop_guard_config.proto
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+syntax = "proto2";
+
+package perfetto.protos;
+
+// Data source that controls the system properties used to guard initialization
+// of track_event producers (i.e. Skia) in apps using HWUI, and certain
+// processes like SurfaceFlinger.
+//
+// This data source only tells Skia to initialized the Perfetto SDK and start
+// routing data to the Track Event system instead of ATrace. For those events
+// to actually show up in a trace, the track_event data source must be used as
+// well. The Perfetto SDK cannot be de-initialized, so some long-lived apps and
+// processes may need to be restarted for Skia to revert to using ATrace if
+// Track Events are no longer desired.
+//
+// In addition to switching Skia to use Perfetto's track_event data source,
+// this "guard" also controls Skia's "broad tracing", which removes Skia's
+// internal tracing constraints and allows the track_event config to specify
+// which categories should be traced. Filtering to the "skia.always" category
+// *tag* in a track_event config can be used to re-enable the standard
+// constraints typically used with ATrace.
+//
+// Data source name: android.sdk_sysprop_guard
+// Introduced in Android 14 (U) QPR1.
+// Next id: 4
+message AndroidSdkSyspropGuardConfig {
+ // If true, configures SurfaceFlinger to initialize Skia's Perfetto
+ // integration with the track_event data source in RenderEngine.
+ // If false or omitted, the simpler ATrace fallback is used.
+ //
+ // NOTE: once enabled, Skia will only revert to ATrace if SurfaceFlinger is
+ // restarted.
+ //
+ // Specifically this sets the following system properties:
+ // - debug.renderengine.skia_tracing_enabled
+ // - debug.renderengine.skia_use_perfetto_track_events
+ //
+ // Does not affect actual track_event data *collection*, which must be
+ // configured seperately.
+ optional bool surfaceflinger_skia_track_events = 1;
+
+ // If true, configures HWUI apps to initialize Skia's Perfetto integration
+ // with the track_event data source. hwui_package_name_filter
+ // can be used to control which apps are affected.
+ // If false or omitted, the simpler ATrace fallback is used.
+ //
+ // NOTE: once enabled, Skia will only revert to ATrace if the app is
+ // restarted.
+ //
+ // ATTENTION: affects ALL HWUI APPS if hwui_package_name_filter is not set!
+ // If filtering is NOT set, this controls these GLOBAL system properties:
+ // - debug.hwui.skia_tracing_enabled
+ // - debug.hwui.skia_use_perfetto_track_events
+ // If filtering IS set, this controls these APP-SPECIFIC system properties,
+ // for each package listed in the filter:
+ // - debug.hwui.skia_tracing_enabled.<package.name>
+ // - debug.hwui.skia_use_perfetto_track_events.<package.name>
+ //
+ // Does not affect actual track_event data *collection*, which must be
+ // configured seperately.
+ optional bool hwui_skia_track_events = 2;
+
+ // If non-empty, hwui_skia_track_events applies to only the packages listed.
+ // Otherwise, hwui_skia_track_events applies globally to all HWUI apps.
+ repeated string hwui_package_name_filter = 3;
+}
diff --git a/protos/perfetto/config/data_source_config.proto b/protos/perfetto/config/data_source_config.proto
index 25b340e..d0f8bbf 100644
--- a/protos/perfetto/config/data_source_config.proto
+++ b/protos/perfetto/config/data_source_config.proto
@@ -22,6 +22,7 @@
import "protos/perfetto/config/android/android_log_config.proto";
import "protos/perfetto/config/android/android_polled_state_config.proto";
import "protos/perfetto/config/android/android_system_property_config.proto";
+import "protos/perfetto/config/android/android_sdk_sysprop_guard_config.proto";
import "protos/perfetto/config/android/network_trace_config.proto";
import "protos/perfetto/config/android/packages_list_config.proto";
import "protos/perfetto/config/android/surfaceflinger_layers_config.proto";
@@ -44,7 +45,7 @@
import "protos/perfetto/config/system_info/system_info.proto";
// The configuration that is passed to each data source when starting tracing.
-// Next id: 124
+// Next id: 125
message DataSourceConfig {
enum SessionInitiator {
SESSION_INITIATOR_UNSPECIFIED = 0;
@@ -175,6 +176,11 @@
optional SurfaceFlingerTransactionsConfig surfaceflinger_transactions_config =
123 [lazy = true];
+ // Data source name: android.sdk_sysprop_guard
+ // Introduced in Android 14 (U) QPR1.
+ optional AndroidSdkSyspropGuardConfig android_sdk_sysprop_guard_config = 124
+ [lazy = true];
+
// This is a fallback mechanism to send a free-form text config to the
// producer. In theory this should never be needed. All the code that
// is part of the platform (i.e. traced service) is supposed to *not* truncate
diff --git a/protos/perfetto/config/perfetto_config.proto b/protos/perfetto/config/perfetto_config.proto
index acd5ca5..f457976 100644
--- a/protos/perfetto/config/perfetto_config.proto
+++ b/protos/perfetto/config/perfetto_config.proto
@@ -404,6 +404,73 @@
// End of protos/perfetto/config/android/android_polled_state_config.proto
+// Begin of protos/perfetto/config/android/android_sdk_sysprop_guard_config.proto
+
+// Data source that controls the system properties used to guard initialization
+// of track_event producers (i.e. Skia) in apps using HWUI, and certain
+// processes like SurfaceFlinger.
+//
+// This data source only tells Skia to initialized the Perfetto SDK and start
+// routing data to the Track Event system instead of ATrace. For those events
+// to actually show up in a trace, the track_event data source must be used as
+// well. The Perfetto SDK cannot be de-initialized, so some long-lived apps and
+// processes may need to be restarted for Skia to revert to using ATrace if
+// Track Events are no longer desired.
+//
+// In addition to switching Skia to use Perfetto's track_event data source,
+// this "guard" also controls Skia's "broad tracing", which removes Skia's
+// internal tracing constraints and allows the track_event config to specify
+// which categories should be traced. Filtering to the "skia.always" category
+// *tag* in a track_event config can be used to re-enable the standard
+// constraints typically used with ATrace.
+//
+// Data source name: android.sdk_sysprop_guard
+// Introduced in Android 14 (U) QPR1.
+// Next id: 4
+message AndroidSdkSyspropGuardConfig {
+ // If true, configures SurfaceFlinger to initialize Skia's Perfetto
+ // integration with the track_event data source in RenderEngine.
+ // If false or omitted, the simpler ATrace fallback is used.
+ //
+ // NOTE: once enabled, Skia will only revert to ATrace if SurfaceFlinger is
+ // restarted.
+ //
+ // Specifically this sets the following system properties:
+ // - debug.renderengine.skia_tracing_enabled
+ // - debug.renderengine.skia_use_perfetto_track_events
+ //
+ // Does not affect actual track_event data *collection*, which must be
+ // configured seperately.
+ optional bool surfaceflinger_skia_track_events = 1;
+
+ // If true, configures HWUI apps to initialize Skia's Perfetto integration
+ // with the track_event data source. hwui_package_name_filter
+ // can be used to control which apps are affected.
+ // If false or omitted, the simpler ATrace fallback is used.
+ //
+ // NOTE: once enabled, Skia will only revert to ATrace if the app is
+ // restarted.
+ //
+ // ATTENTION: affects ALL HWUI APPS if hwui_package_name_filter is not set!
+ // If filtering is NOT set, this controls these GLOBAL system properties:
+ // - debug.hwui.skia_tracing_enabled
+ // - debug.hwui.skia_use_perfetto_track_events
+ // If filtering IS set, this controls these APP-SPECIFIC system properties,
+ // for each package listed in the filter:
+ // - debug.hwui.skia_tracing_enabled.<package.name>
+ // - debug.hwui.skia_use_perfetto_track_events.<package.name>
+ //
+ // Does not affect actual track_event data *collection*, which must be
+ // configured seperately.
+ optional bool hwui_skia_track_events = 2;
+
+ // If non-empty, hwui_skia_track_events applies to only the packages listed.
+ // Otherwise, hwui_skia_track_events applies globally to all HWUI apps.
+ repeated string hwui_package_name_filter = 3;
+}
+
+// End of protos/perfetto/config/android/android_sdk_sysprop_guard_config.proto
+
// Begin of protos/perfetto/config/android/android_system_property_config.proto
// Data source that polls for system properties.
@@ -2619,7 +2686,7 @@
// Begin of protos/perfetto/config/data_source_config.proto
// The configuration that is passed to each data source when starting tracing.
-// Next id: 124
+// Next id: 125
message DataSourceConfig {
enum SessionInitiator {
SESSION_INITIATOR_UNSPECIFIED = 0;
@@ -2750,6 +2817,11 @@
optional SurfaceFlingerTransactionsConfig surfaceflinger_transactions_config =
123 [lazy = true];
+ // Data source name: android.sdk_sysprop_guard
+ // Introduced in Android 14 (U) QPR1.
+ optional AndroidSdkSyspropGuardConfig android_sdk_sysprop_guard_config = 124
+ [lazy = true];
+
// This is a fallback mechanism to send a free-form text config to the
// producer. In theory this should never be needed. All the code that
// is part of the platform (i.e. traced service) is supposed to *not* truncate
diff --git a/protos/perfetto/trace/perfetto_trace.proto b/protos/perfetto/trace/perfetto_trace.proto
index 3dc5854..554413f 100644
--- a/protos/perfetto/trace/perfetto_trace.proto
+++ b/protos/perfetto/trace/perfetto_trace.proto
@@ -404,6 +404,73 @@
// End of protos/perfetto/config/android/android_polled_state_config.proto
+// Begin of protos/perfetto/config/android/android_sdk_sysprop_guard_config.proto
+
+// Data source that controls the system properties used to guard initialization
+// of track_event producers (i.e. Skia) in apps using HWUI, and certain
+// processes like SurfaceFlinger.
+//
+// This data source only tells Skia to initialized the Perfetto SDK and start
+// routing data to the Track Event system instead of ATrace. For those events
+// to actually show up in a trace, the track_event data source must be used as
+// well. The Perfetto SDK cannot be de-initialized, so some long-lived apps and
+// processes may need to be restarted for Skia to revert to using ATrace if
+// Track Events are no longer desired.
+//
+// In addition to switching Skia to use Perfetto's track_event data source,
+// this "guard" also controls Skia's "broad tracing", which removes Skia's
+// internal tracing constraints and allows the track_event config to specify
+// which categories should be traced. Filtering to the "skia.always" category
+// *tag* in a track_event config can be used to re-enable the standard
+// constraints typically used with ATrace.
+//
+// Data source name: android.sdk_sysprop_guard
+// Introduced in Android 14 (U) QPR1.
+// Next id: 4
+message AndroidSdkSyspropGuardConfig {
+ // If true, configures SurfaceFlinger to initialize Skia's Perfetto
+ // integration with the track_event data source in RenderEngine.
+ // If false or omitted, the simpler ATrace fallback is used.
+ //
+ // NOTE: once enabled, Skia will only revert to ATrace if SurfaceFlinger is
+ // restarted.
+ //
+ // Specifically this sets the following system properties:
+ // - debug.renderengine.skia_tracing_enabled
+ // - debug.renderengine.skia_use_perfetto_track_events
+ //
+ // Does not affect actual track_event data *collection*, which must be
+ // configured seperately.
+ optional bool surfaceflinger_skia_track_events = 1;
+
+ // If true, configures HWUI apps to initialize Skia's Perfetto integration
+ // with the track_event data source. hwui_package_name_filter
+ // can be used to control which apps are affected.
+ // If false or omitted, the simpler ATrace fallback is used.
+ //
+ // NOTE: once enabled, Skia will only revert to ATrace if the app is
+ // restarted.
+ //
+ // ATTENTION: affects ALL HWUI APPS if hwui_package_name_filter is not set!
+ // If filtering is NOT set, this controls these GLOBAL system properties:
+ // - debug.hwui.skia_tracing_enabled
+ // - debug.hwui.skia_use_perfetto_track_events
+ // If filtering IS set, this controls these APP-SPECIFIC system properties,
+ // for each package listed in the filter:
+ // - debug.hwui.skia_tracing_enabled.<package.name>
+ // - debug.hwui.skia_use_perfetto_track_events.<package.name>
+ //
+ // Does not affect actual track_event data *collection*, which must be
+ // configured seperately.
+ optional bool hwui_skia_track_events = 2;
+
+ // If non-empty, hwui_skia_track_events applies to only the packages listed.
+ // Otherwise, hwui_skia_track_events applies globally to all HWUI apps.
+ repeated string hwui_package_name_filter = 3;
+}
+
+// End of protos/perfetto/config/android/android_sdk_sysprop_guard_config.proto
+
// Begin of protos/perfetto/config/android/android_system_property_config.proto
// Data source that polls for system properties.
@@ -2619,7 +2686,7 @@
// Begin of protos/perfetto/config/data_source_config.proto
// The configuration that is passed to each data source when starting tracing.
-// Next id: 124
+// Next id: 125
message DataSourceConfig {
enum SessionInitiator {
SESSION_INITIATOR_UNSPECIFIED = 0;
@@ -2750,6 +2817,11 @@
optional SurfaceFlingerTransactionsConfig surfaceflinger_transactions_config =
123 [lazy = true];
+ // Data source name: android.sdk_sysprop_guard
+ // Introduced in Android 14 (U) QPR1.
+ optional AndroidSdkSyspropGuardConfig android_sdk_sysprop_guard_config = 124
+ [lazy = true];
+
// This is a fallback mechanism to send a free-form text config to the
// producer. In theory this should never be needed. All the code that
// is part of the platform (i.e. traced service) is supposed to *not* truncate