Closed Bug 1745318 Opened 2 years ago Closed 2 years ago

Add `MOZ_ASSERT_IF(XRE_IsParentProcess(), NS_IsMainThread())` in `StreamMetaJSCustomObject()`

Categories

(Core :: Gecko Profiler, task, P2)

task

Tracking

()

RESOLVED FIXED
97 Branch
Tracking Status
firefox97 --- fixed

People

(Reporter: mozbugz, Assigned: mozbugz)

Details

Attachments

(1 file)

If a developer tries to generate a profile from a non-main thread, it looks like it works fine, but the profile is actually incomplete, because we don't include all the necessary data in that case, which normally happens in child processes where such redundant data is not needed: https://searchfox.org/mozilla-central/rev/9028b0458cc1f432870d2996b186b0938dda734a/tools/profiler/core/platform.cpp#2640-2650

To avoid this confusing situation, it may be worth adding a hard check like MOZ_ASSERT_IF(XRE_IsParentProcess(), NS_IsMainThread()), with some explanations, so that it will be immediately obvious that this is the wrong thing to do, and such call should be dispatched to the main thread.

(This main-thread limitation is due to the need to call some APIs that only work from the main thread, like services::GetObserverService().)

This is to avoid situations where a developer may call this from another thread, and get a confusingly incomplete profile.

Assignee: nobody → gsquelart
Status: NEW → ASSIGNED
Pushed by gsquelart@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/23777ea03332
In the parent process, assert that profiles are only generated on the main thread - r=mstange
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 97 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: