Closed Bug 1681043 Opened 5 years ago Closed 5 years ago

mozilla::PDMFactory::Supported blocks the main thread when creating the first content process during startup

Categories

(Core :: Audio/Video: Playback, defect, P1)

defect

Tracking

()

VERIFIED FIXED
86 Branch
Performance Impact medium
Tracking Status
firefox-esr78 --- unaffected
firefox83 --- unaffected
firefox84 --- wontfix
firefox85 --- wontfix
firefox86 --- fixed

People

(Reporter: florian, Assigned: jya)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: perf, regression, Whiteboard: [fxperf:p2])

Attachments

(6 files)

Here is a startup profile captured on the Quantum 2018 reference hardware. The view is focused on the 2s when the main thread is blocked while creating the first content process: https://share.firefox.dev/39MADNB

This was seen on the Nightly from 2020 12 02.

From looking at bit at the code and bugzilla, this may be related to changes made in bug 1674043, but I'm really not sure, so I'm not marking this bug as a regression.

Flags: needinfo?(jyavenard)

All I can see in that profile is that the main thread is waiting on the EnsureMTA method; could you re-capture this profile and include the capture "COM MTA" ; please also include all the media threads (including media thread pool).

Thanks

Flags: needinfo?(jyavenard) → needinfo?(florian)
Keywords: regression
Regressed by: 1674043
Has Regression Range: --- → yes

Here's another profile showing the COM MTA thread: https://share.firefox.dev/3lT5af7

Flags: needinfo?(florian)

Here's another one after updating to today's nightly: https://share.firefox.dev/3lXe37B

Set release status flags based on info from the regressing bug 1674043

Are the profiles in comment 2 or comment 3 illuminating?

Flags: needinfo?(jyavenard)
Whiteboard: [fxperf][qf] → [fxperf:p2][qf]

(In reply to Mike Conley (:mconley) (:⚙️) from comment #5)

Are the profiles in comment 2 or comment 3 illuminating?

Well, we can see a 1.7s jank with the parent process blocking in nsFrameLoader::LoadContext. However, the PDMFactory initialisation introduced in bug 1674043, only takes 600ms of that.
In that blockage , WebRender initialization takes even more time

Initialising the PDMFactory and testing the capability of the system is something we must do early unfortunately.
What we could do for the time being is only run this code on first launch and cache it.

We can use the same logic as what gfx does which is to only test again once we have a new firefox version.
We could force the test if we didn't find the H264 decoder only; as on windows it would indicate we haven't installed the media package yet and we want to find it once it runs.

Flags: needinfo?(jyavenard)
Assignee: nobody → jyavenard
Whiteboard: [fxperf:p2][qf] → [fxperf:p2][qf:p2]

We can launch the RDD process now that it is a fully asynchronous process and doesn't block anything.

This will allow to retrieve the decoding capabilities of the RDD process right away.

When calling PDM::SupportsMimeType not enough information is provided for the PDM to categorically state that a codec isn't supported.

Only creating the decoder successfully matters and the PDMFactory only uses the value returned by Support as a hint to further query the PDM.

Without this change WMFDecoderModule::SupportsMimeType in the GPU process would always return false as it doesn't know yet the KnownCompositor.

Depends on D100304

Upon starting the RDD and GPU process; we check their decoding capabilities and send it to the parent process. It will then broadcast this information to all content children so that RemodeDecoderModule::Supports can return if a codec is supported or not.

Depends on D100305

gfxVars::CanUseHardwareVideoDecoding is often set after the first use of the PDMFactory; in this case this would disable HW VP9 decoding for the entire session of the browser.

This value will always end up being true on macOS, so ignore its value in the static Init method.

Depends on D100306

Not the most elegant, but reworking the PDMFactory to be fully re-initialized would be a significant change, as only the WMFDecoderModule requires it we take some shortcuts.

Depends on D100307

The WMFDecoderModule now uses a crash guard around the loading of the VP9/VP8 MFT. We don't want to always assume that we have a VPx decoder in the GPU process in particular, as it will only be true if a HW decoder is available.

Depends on D100308

Pushed by jyavenard@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e8fac91d4012 P1. Launch RDD process early. r=alwu https://hg.mozilla.org/integration/autoland/rev/25a015e84cc4 P2. Don't reject outright support for a GPU decoder if compositor isn't known. r=alwu,bryce https://hg.mozilla.org/integration/autoland/rev/9319fdd0389c P3. Retrieve decoding capabilities in GPU or RDD process and pass it to content. r=alwu,bryce https://hg.mozilla.org/integration/autoland/rev/5ecb208a85d3 P4. Stop checking on gfxVars::CanUseHardwareVideoDecoding on mac. r=alwu https://hg.mozilla.org/integration/autoland/rev/64d8abe2104d P5. Recalculate decoder capabilities if CanUseHardwareVideoDecoding changes. r=alwu,bryce https://hg.mozilla.org/integration/autoland/rev/ea075101dc94 P6. Remove no longer necessary workaround. r=alwu,bryce
See Also: → 1684991

I've split the P1 bit into bug 1684991 so that this series can land.

We would need to fix the tests and make the sandbox initialization lazy

Flags: needinfo?(jya-moz)
Severity: -- → S3
Priority: -- → P1
Blocks: RDD
Attachment #9194347 - Attachment description: Bug 1681043 - P1. Launch RDD process early. r=alwu!,mattwoodrow! → Bug 1681043 - P1. Create method to launch RDD process early. r=alwu!,mattwoodrow!
Pushed by jya-moz@avenard.org: https://hg.mozilla.org/integration/autoland/rev/21ea78b9dc84 P1. Create method to launch RDD process early. r=alwu https://hg.mozilla.org/integration/autoland/rev/44cbe16c5d9d P2. Don't reject outright support for a GPU decoder if compositor isn't known. r=alwu,bryce https://hg.mozilla.org/integration/autoland/rev/e7e3b8065eb7 P3. Retrieve decoding capabilities in GPU or RDD process and pass it to content. r=alwu,bryce https://hg.mozilla.org/integration/autoland/rev/195d164c5618 P4. Stop checking on gfxVars::CanUseHardwareVideoDecoding on mac. r=alwu https://hg.mozilla.org/integration/autoland/rev/487a070f4989 P5. Recalculate decoder capabilities if CanUseHardwareVideoDecoding changes. r=alwu,bryce https://hg.mozilla.org/integration/autoland/rev/50fb5b9343f6 P6. Remove no longer necessary workaround. r=alwu,bryce
Regressions: 1685364
Regressions: 1685436

In an attempt to verify the fix I've just done 2 startup profiles on the same hardware I used in comment 0.

On Nightly 20210106093742 (I think that's the last one before the patches landed), cold startup, where PDMFactory blocks the main thread for almost 14s, during which the COM MTA thread (started before first paint) is busy - https://share.firefox.dev/35mEAFU

On the current Nightly - https://share.firefox.dev/2LxHqkp I don't see the bug anymore. The COM MTA thread starts much later, and doesn't seem to do much during startup.

The second profile isn't captured in the exact same conditions; this is a first start after an update, not a cold startup, so the times are not comparable between the two profiles. But I think it's good enough to verify the behavior change.

== Change summary for alert #28352 (as of Thu, 07 Jan 2021 17:21:33 GMT) ==

Improvements:

Ratio Suite Test Platform Options Absolute values (old vs new)
36% glvideo Mean tick time across 100 ticks: windows10-64-shippable-qr e10s stylo webrender-sw 32.04 -> 20.63
3% ts_paint ts_paint windows10-64-shippable-qr e10s stylo webrender-sw 368.75 -> 358.67

For up to date results, see: https://treeherder.mozilla.org/perfherder/alerts?id=28352

(In reply to Florian Quèze [:florian] from comment #18)

On the current Nightly - https://share.firefox.dev/2LxHqkp I don't see the bug anymore. The COM MTA thread starts much later, and doesn't seem to do much during startup.

The second profile isn't captured in the exact same conditions; this is a first start after an update, not a cold startup, so the times are not comparable between the two profiles. But I think it's good enough to verify the behavior change.

Here's a cold startup profile that's comparable to my first profile in comment 18: https://share.firefox.dev/2Xk6Ggu
My observations in comment 18 still stand, I don't see the bug anymore. Thanks for fixing this Jean-Yves!

Status: RESOLVED → VERIFIED
Regressions: 1690688
Performance Impact: --- → P2
Whiteboard: [fxperf:p2][qf:p2] → [fxperf:p2]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: