Closed Bug 1133633 Opened 9 years ago Closed 9 years ago

Poor video decoding performance on mac when using VideoToolbox

Categories

(Core :: Audio/Video, defect, P2)

x86
macOS
defect

Tracking

()

RESOLVED FIXED
mozilla40
Tracking Status
firefox36 --- wontfix
firefox37 --- wontfix
firefox38 --- fixed
firefox39 --- fixed
firefox40 --- fixed

People

(Reporter: jya, Assigned: jya)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

There appears to be severe performance issue with the Apple VideoToolbox decoder even with hardware acceleration is enabled.

A 4K YouTube videos show lots of dropped frame when using VideoToolBox with Intel GPU.

On a late-2013 macbook air (Intel HD5000), the average time it takes to decode a 4K frame is:
- Software decode: 95ms average, max 469ms
- VideoToolbox with HW acceleration: 31ms average, max 326ms
- VDA (pure HW acceleration): .63ms average, max 97ms

To not have dropped frames, we must decode in less than 30ms a 4K @ 30Hz. As it is the VideoToolbox decoder is borderline in the average case, and way over at its worse.

This patch track the attempt to prefer the VDA decoder for higher resolution video.
Summary: Prefer VDA decoder for some videos. → Poor video decoding performance on mac when using VideoToolbox
Depends on: 1061525
Add detection if decoding is hardware accelerated and related log
Attachment #8565776 - Flags: review?(giles)
Assignee: nobody → jyavenard
Status: NEW → ASSIGNED
Comment on attachment 8565776 [details] [diff] [review]
Part1. Add logging reporting if we are using HW accelerated decode

Review of attachment 8565776 [details] [diff] [review]:
-----------------------------------------------------------------

r=me with question addressed.

::: dom/media/fmp4/apple/AppleVTDecoder.cpp
@@ +317,5 @@
> +    LOG("AppleVTDecoder: %s hardware accelerated decoding",
> +        (rv == noErr && isUsingHW == kCFBooleanTrue) ? "using" : "not using");
> +  } else {
> +    LOG("AppleVTDecoder: using software decoding "
> +        "(platform doesn't support HW acceleration)");

Is this true? Do we know MacOS X 10.8 and earlier won't use hardware acceleration, despite the property key not being defined in the API?
Attachment #8565776 - Flags: review?(giles) → review+
As far as I can say, is that there's no way to tell.
Even the doc about kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder are confusing at best as the only guaranteed behaviour is when you set it to false, in which case HW acceleration will be disabled.

It is suggested that the VT decoder will, when it's true or not set decide what to use and when.
However, reports like bug 1132994, indicates to me that unless it's set to true, we won't get HW acceleration (as that's the only difference between 35 and 36)

On my mac pro, while the key exist, I can't query it, and when requesting all VTSession keys anything related to HW is missing (and VDA always return an error)
Priority: -- → P1
Who knows then. I just wanted to make sure we didn't leave a confusing message in the log. How about "Couldn't determine hardware acceleration status."?
Comment on attachment 8565776 [details] [diff] [review]
Part1. Add logging reporting if we are using HW accelerated decode

Requestint 36 uplift of teh initial logging patch.

Approval Request Comment
[Feature/regressing bug #]: MSE and mp4 playback on Mac.
[User impact if declined]: Slow video decoding on some systems.
[Describe test coverage new/current, TreeHerder]: Landed on m-c.
[Risks and why]: This just adds logging plumbing. Risk should be low.
[String/UUID change made/needed]: None.
Attachment #8565776 - Flags: approval-mozilla-aurora?
Comment on attachment 8565776 [details] [diff] [review]
Part1. Add logging reporting if we are using HW accelerated decode

Looks like this may do a bit more than just logging but we definitely want the change in 37 Beta 1 in which we're testing MSE on OSX. 37 is now Beta so clearing Aurora request and approving for Beta.

Beta+
Attachment #8565776 - Flags: approval-mozilla-aurora? → approval-mozilla-beta+
Depends on: 1137529
Priority: P1 → P2
Depends on: 1141349
enable async decoding on apple VT.
Attachment #8585883 - Flags: review?(matt.woodrow)
Attachment #8585883 - Flags: review?(matt.woodrow) → review+
Comment on attachment 8585883 [details] [diff] [review]
Part2. Enable async decoding on mac

Approval Request Comment
[Feature/regressing bug #]: 1133633
[User impact if declined]: stuttering playback, dropped frames
[Describe test coverage new/current, TreeHerder]: This patch significantly improve the performance of the decoder on mac, a 4K video will go from 60% dropped frames to 0%. Patch will have to be rebase for beta.
[Risks and why]: Low.
[String/UUID change made/needed]: None
Attachment #8585883 - Flags: approval-mozilla-beta?
Attachment #8585883 - Flags: approval-mozilla-aurora?
Jean-Yves, are you planning to provide the beta patch?
Flags: needinfo?(jyavenard)
Attachment #8585883 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Comment on attachment 8585883 [details] [diff] [review]
Part2. Enable async decoding on mac

I remove the request for beta uplift.

MSE isn't enabled on mac in beta, so let's urgent there.
Flags: needinfo?(jyavenard)
Attachment #8585883 - Flags: approval-mozilla-beta?
Keywords: leave-open
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
Comment on attachment 8585883 [details] [diff] [review]
Part2. Enable async decoding on mac

We may enable MSE in 38.. So we would want that in as well.
Attachment #8585883 - Flags: approval-mozilla-beta?
Comment on attachment 8585883 [details] [diff] [review]
Part2. Enable async decoding on mac

Taking it in case we decide to do something with MSE under Mac.
Should be in 38 beta 4.
Attachment #8585883 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: