Closed Bug 1914388 Opened 2 years ago Closed 1 year ago

On Windows, profiler doesn't capture gecko log properly in MFCDM process

Categories

(Core :: Gecko Profiler, defect, P2)

defect

Tracking

()

RESOLVED FIXED
141 Branch
Tracking Status
firefox141 --- fixed

People

(Reporter: alwu, Assigned: alwu)

References

(Blocks 1 open bug)

Details

(Whiteboard: [fp])

Attachments

(2 external files, 1 obsolete file)

When opening about:support on Widows Nightly, you can see a section called "Content Decryption Modules Information". That triggers this part of code, which should result in printing logs in the BackgroundThreadPool thread. But if you use media playback in about:logging to profile this behavior, there is NO log at all on that thread.

STR.

  1. go to about:logging
  2. select media playback preset and start profiling
  3. go to about:support and wait until Content Decryption Modules Information shows some results
  4. stop profiling

Expected.
5. log should be captured on BackgroundThreadPool in the MFCDM process

Actual.
5. no log at all

FYI we also received different several profiled results from Windows users before, and also no the log message in their profiled result. There must be something wrong on Windows.

Severity: -- → S3
Priority: -- → P2
Whiteboard: [fxp]
Flags: needinfo?(felash)

I started debugging this and saw the prefs are propagated to the child process, and everything seemed fine, but then then logging I saw the level at 0 (disabled), and got confused and had to switch to something else.

On today's Nightly, this bug still persists and I still can't see any log in BackgroundThreadPool. However, another user captured a profile on build id 20241024094434, his profile can capture logs successfully, not sure why...

There is a race somewhere, this needs more debugging.

Alastor I don't see any log message on the main thread either, but maybe that's expected because there's no moz_log call there, can you please confirm?

Also can you confirm you see these logs in the console even when they're not showing up in the profile?
Thanks

Registering the modules is done in LogModulePrefWatcher.cpp:
https://searchfox.org/mozilla-central/rev/a547d790fa7facb8d0addb9197797dc52b31e8f2/xpcom/base/LogModulePrefWatcher.cpp#158-170
Adding the marker is done in https://searchfox.org/mozilla-central/rev/a547d790fa7facb8d0addb9197797dc52b31e8f2/xpcom/base/Logging.cpp#675-681

Adding a breakpoint with printing at these locations could maybe help debugging?

Flags: needinfo?(felash)

Alastor I don't see any log message on the main thread either, but maybe that's expected because there's no moz_log call there, can you please confirm?

Yes, logs are not in the main thread. They are mostly on BackgroundThreadPool, MediaSupervisor and MediaPDecoder.

Also can you confirm you see these logs in the console even when they're not showing up in the profile?

No.


After doing some more testing, it seems like the issue with missing logs only occurs when the MFCDM process hasn't been started before starting the profiler. Once the MFCDM process has already been created, the profiler is able to capture logs normally.

This suggests that when the MFCDM process is created after profiling starts, the profiler might not be registering the log modules correctly within that process.

You can reproduce the issue using the following STR (on Windows):

  1. Start Firefox
  2. Go to about:logging, select the Media Playback preset, and start capturing
  3. Visit about:support
  4. Once the page finishes loading, stop profiling
  5. In the profile, you should see the MF Media Engine CDM process, but no logs in the BackgroundThreadPool thread
  6. Start a new profiling via about:logging again
  7. Refresh the about:support page
  8. Once it finishes loading, stop profiling
  9. In the new profile, you should now see the MF Media Engine CDM process with logs under BackgroundThreadPool
Flags: needinfo?(felash)

(In reply to Alastor Wu [:alwu] from comment #6)

Alastor I don't see any log message on the main thread either, but maybe that's expected because there's no moz_log call there, can you please confirm?

Yes, logs are not in the main thread. They are mostly on BackgroundThreadPool, MediaSupervisor and MediaPDecoder.

Also can you confirm you see these logs in the console even when they're not showing up in the profile?

No.

Then I think it's not related to the profiler at all, but to the more generic log system.

All about:logging does is setting some preferences.

Does that all work when you use the MOZ_LOG env variable?

Flags: needinfo?(felash)

(In reply to Julien Wajsberg [:julienw] from comment #7)

Then I think it's not related to the profiler at all, but to the more generic log system.

All about:logging does is setting some preferences.

Does that all work when you use the MOZ_LOG env variable?

Yes, using MOZ_LOG works, but adding logging.XXX doesn't. It does sound like a MOZLOG problem, do you know who the right person is to ask for checking this issue? Thanks!

Flags: needinfo?(felash)

More or less me. I would set breakpoints around here: https://searchfox.org/mozilla-central/source/xpcom/base/LogModulePrefWatcher.cpp#175. This is the code that is responsible for catching any modification to logging.xxx and set the log module appropriately.

Yeah, I would do exactly this.

Flags: needinfo?(felash)

Okay, I found the issue. The log modules are correctly created and initialized with the appropriate log level when the MFCDM process is launched. However, the log level gets cleared by this code afterward. The subsequent code that sets the log level only considers the MOZ_LOG environment variable and the preference, and doesn’t reapply the levels set via about:logging. As a result, any modules configured through about:logging aren't properly restored.

This issue might also explain why we sometimes don’t see media logs from users, even when they’ve reported capturing the profile using the media preset.

Assignee: nobody → alwu

If the logging.config.modules preference is empty, we should avoid clearing
the existing log modules. Resetting them unnecessarily can result in losing log
levels previously set via about:logging.

ah right, good find!

Moving forward I'd like to make about:logging use logging.config.modules directly, which would also prevent the issue.
But developers might still use the individual prefs for reasons so I think this fix makes sense anyway, even in the long run.

See Also: → 1894703
Attachment #9487184 - Attachment is obsolete: true

These prefs are removed:

  • logging.config.modules
Blocks: old-prefs
Pushed by alwu@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/13e4579e8765 https://hg.mozilla.org/integration/autoland/rev/4a6f86123276 part1 : revert changes from D209249 in order to remove the support of 'logging.config.modules'. r=julienw https://github.com/mozilla-firefox/firefox/commit/298b54b3ec31 https://hg.mozilla.org/integration/autoland/rev/bd4a1034914b part2 : remove related prefs and modify documentations. r=geckoview-reviewers,julienw,owlish
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 141 Branch
QA Whiteboard: [qa-triage-done-c142/b141]
See Also: → 2083000
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: