commit ca7c85a6c4897f7ab525b8c1b1a07bd942e1f686
parent e17e5e436c530d58d1ffd24b5c69f70b40d1a11f
Author: Nazım Can Altınova <canaltinova@gmail.com>
Date: Tue, 21 Oct 2025 15:41:03 +0000
Bug 1994995 - Add the 'java' feature to the debug preset and make sure that every preset has it r=mleclair,android-reviewers,nalexander
This preset was added in bug 1992009, but it was missing the 'java'
feature. It's crucial to have this for two things:
1. We should always make sure to profile Android code when profiling on
Android.
2. The profiler start logic actually doesn't work when this feature is
missing.
The profiler start logic doesn't work because GeckoJavaSampler.isProfilerActive
method checks if the JVM sampler has started or not. We could call the
native profiler function using a JNI call but this brings an additional
overhead and this method needs to run very quickly.
Differential Revision: https://phabricator.services.mozilla.com/D269228
Diffstat:
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/perf/ProfilerUtils.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/perf/ProfilerUtils.kt
@@ -99,6 +99,7 @@ private val networking_threads = arrayOf(
private val debug_features = arrayOf(
"cpu",
+ "java",
"ipcmessages",
"js",
"markersallthreads",
@@ -122,6 +123,13 @@ enum class ProfilerSettings(val threads: Array<String>, val features: Array<Stri
Media(media_threads, media_features),
Networking(networking_threads, networking_features),
Debug(debug_threads, debug_features),
+ ;
+
+ init {
+ require(features.contains("java")) {
+ "ProfilerSettings.$name must include the 'java' feature."
+ }
+ }
}
/**
diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/perf/ProfilerViewModelTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/perf/ProfilerViewModelTest.kt
@@ -457,4 +457,18 @@ class ProfilerViewModelTest {
assertEquals(listOf(false, true, false), collectedStates)
}
+
+ @Test
+ fun `GIVEN all profiler presets THEN they must include the java feature for polling to work`() {
+ // This test ensures that all ProfilerSettings presets include the "java" feature.
+ // The "java" feature is required for GeckoJavaSampler to start, which makes
+ // isProfilerActive() return true. Without it, the polling mechanism in
+ // pollUntilProfilerActiveAndThen() will timeout and fail (see bug 1994995).
+ ProfilerSettings.entries.forEach { setting ->
+ assertTrue(
+ "ProfilerSettings.${setting.name} must include 'java' feature for isProfilerActive() to work",
+ setting.features.contains("java"),
+ )
+ }
+ }
}