Bug 1754781 - Change the Android JVM thread id to 1 r=gerald

Differential Revision: https://phabricator.services.mozilla.com/D138769
This commit is contained in:
Nazım Can Altınova 2022-02-16 10:27:44 +00:00
Родитель 9c0c0c1f16
Коммит 22f86b74fe
3 изменённых файлов: 38 добавлений и 4 удалений

Просмотреть файл

@ -2888,7 +2888,7 @@ static void CollectJavaThreadProfileData(ProfileBuffer& aProfileBuffer) {
// Pass the samples
// FIXME(bug 1618560): We are currently only profiling the Android UI thread.
constexpr ProfilerThreadId threadId;
constexpr ProfilerThreadId threadId = ProfilerThreadId::FromNumber(1);
int sampleId = 0;
while (true) {
// Gets the data from the Android UI thread only.
@ -3150,9 +3150,9 @@ static void locked_profiler_stream_json_for_this_process(
// tid that doesn't conflict with it for the Java side. So we just use 0.
// Once we add support for profiling of other java threads, we'll have to
// get their thread id and name via JNI.
ProfiledThreadData profiledThreadData(
ThreadRegistrationInfo{"AndroidUI (JVM)", ProfilerThreadId{}, false,
CorePS::ProcessStartTime()});
ProfiledThreadData profiledThreadData(ThreadRegistrationInfo{
"AndroidUI (JVM)", ProfilerThreadId::FromNumber(1), false,
CorePS::ProcessStartTime()});
profiledThreadData.StreamJSON(
javaBuffer, nullptr, aWriter, CorePS::ProcessName(aLock),
CorePS::ETLDplus1(aLock), CorePS::ProcessStartTime(), aSinceTime,

Просмотреть файл

@ -0,0 +1,31 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* Test that Java capturing works as expected.
*/
add_task(async () => {
info("Test that Android Java sampler works as expected.");
const entries = 10000;
const interval = 1;
const threads = [];
const features = ["java"];
Services.profiler.StartProfiler(entries, interval, features, threads);
Assert.ok(Services.profiler.IsActive());
await captureAtLeastOneJsSample();
info(
"Stop the profiler and check that we have successfully captured a profile" +
" with the AndroidUI thread."
);
const profile = await stopAndGetProfile();
Assert.notEqual(profile, null);
const androidUiThread = profile.threads.find(
thread => thread.name == "AndroidUI (JVM)"
);
Assert.notEqual(androidUiThread, null);
Assert.ok(!Services.profiler.IsActive());
});

Просмотреть файл

@ -90,3 +90,6 @@ skip-if =
[test_assertion_helper.js]
skip-if = toolkit == 'android'
[test_feature_java.js]
skip-if = toolkit != 'android'