Bug 213369 - Add logging to WebRTC video pipeline to check for frame rate stability
Summary: Add logging to WebRTC video pipeline to check for frame rate stability
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-06-19 02:58 PDT by youenn fablet
Modified: 2020-06-24 07:08 PDT (History)
11 users (show)

See Also:


Attachments
Patch (5.92 KB, patch)
2020-06-19 03:24 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (6.03 KB, patch)
2020-06-19 03:27 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (18.27 KB, patch)
2020-06-22 01:14 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (19.93 KB, patch)
2020-06-22 05:38 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (20.47 KB, patch)
2020-06-23 04:57 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (21.93 KB, patch)
2020-06-24 02:08 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (20.69 KB, patch)
2020-06-24 05:27 PDT, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description youenn fablet 2020-06-19 02:58:24 PDT
Add logging to RealtimeIncomingVideoSource to check for frame rate stability
Comment 1 youenn fablet 2020-06-19 03:24:01 PDT
Created attachment 402272 [details]
Patch
Comment 2 youenn fablet 2020-06-19 03:27:53 PDT
Created attachment 402273 [details]
Patch
Comment 3 Eric Carlson 2020-06-19 09:05:08 PDT
Comment on attachment 402273 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=402273&action=review

> Source/WebCore/platform/mediastream/RealtimeIncomingVideoSource.cpp:120
> +        callOnMainThread([identifier = LOGIDENTIFIER, this, protectedThis = makeRef(*this), frameTime,  lastFrameTime, observedFrameRate = m_observedFrameRate] {

Nit: extra space before "lastFrameTime"
Comment 4 youenn fablet 2020-06-22 01:14:31 PDT
Created attachment 402449 [details]
Patch
Comment 5 youenn fablet 2020-06-22 05:38:17 PDT
Created attachment 402465 [details]
Patch
Comment 6 youenn fablet 2020-06-22 06:04:10 PDT
I migrated from one log point (decoder output) to two (renderer and encoded frame receiver).
Comment 7 Darin Adler 2020-06-22 08:20:02 PDT
Comment on attachment 402465 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=402465&action=review

> Source/WebCore/platform/FrameRateMonitor.cpp:31
> +void FrameRateMonitor::newFrame()

This function is full of unexplained magic numbers. 5, 3, and 2. I have no idea how we selected those.

> Source/WebCore/platform/FrameRateMonitor.h:34
> +    using Callback = Function<void(double frameTime, double lastFrameTime)>;

Why do these use double rather than one of our time types? Seems a missed opportunity to be clear on what units these times are in.

> Source/WebCore/platform/FrameRateMonitor.h:35
> +    explicit FrameRateMonitor(Callback&&);

I suggest making the type name clear, explaining what the callback is for. Presumably the callback is about periods of time with many dropped frames. There’s probably some simple term of art for that.

> Source/WebCore/platform/FrameRateMonitor.h:37
> +    void newFrame();

It’s not ideal to have a function name be a noun “frame”, when it doesn’t return a frame object. We can probably come up with a better name for this.

> Source/WebCore/platform/FrameRateMonitor.h:40
> +    size_t frameCount() const { return m_frameCount; }

size_t is a strange choice for the integer type of a frame count. It’s only appropriate when this is somehow related to the size of some in-memory data structure. I suggest either unsigned/uint32_t or uint64_t.
Comment 8 youenn fablet 2020-06-23 04:57:41 PDT
Created attachment 402544 [details]
Patch
Comment 9 youenn fablet 2020-06-23 06:15:40 PDT
Thanks for review.

(In reply to Darin Adler from comment #7)
> Comment on attachment 402465 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=402465&action=review
> 
> > Source/WebCore/platform/FrameRateMonitor.cpp:31
> > +void FrameRateMonitor::newFrame()
> 
> This function is full of unexplained magic numbers. 5, 3, and 2. I have no
> idea how we selected those.

I added static members to improve readability.
And removed 5 since burst of callbacks is not a big issue here.

> > Source/WebCore/platform/FrameRateMonitor.h:34
> > +    using Callback = Function<void(double frameTime, double lastFrameTime)>;
> 
> Why do these use double rather than one of our time types? Seems a missed
> opportunity to be clear on what units these times are in.

Went with a struct of MonotonicTime and LateFrameCallback as a name.

> > Source/WebCore/platform/FrameRateMonitor.h:35
> > +    explicit FrameRateMonitor(Callback&&);
> 
> I suggest making the type name clear, explaining what the callback is for.
> Presumably the callback is about periods of time with many dropped frames.
> There’s probably some simple term of art for that.
> 
> > Source/WebCore/platform/FrameRateMonitor.h:37
> > +    void newFrame();
> 
> It’s not ideal to have a function name be a noun “frame”, when it doesn’t
> return a frame object. We can probably come up with a better name for this.

Changed to update.
 
> > Source/WebCore/platform/FrameRateMonitor.h:40
> > +    size_t frameCount() const { return m_frameCount; }
> 
> size_t is a strange choice for the integer type of a frame count. It’s only
> appropriate when this is somehow related to the size of some in-memory data
> structure. I suggest either unsigned/uint32_t or uint64_t.

OK, changed to uint64_t
Comment 10 Eric Carlson 2020-06-23 11:11:20 PDT
Comment on attachment 402544 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=402544&action=review

> Source/ThirdParty/libwebrtc/Source/webrtc/video/rtp_video_stream_receiver.cc:745
> +    static const unsigned MaxFrameDelayCount = 3;

Why is this const and the constants below are constexpr?

> Source/ThirdParty/libwebrtc/Source/webrtc/video/rtp_video_stream_receiver.cc:746
> +    static constexpr unsigned TimeStampStorageDurationInMs = 2000;

Maybe TimeStampQueueDurationInMs?

> Source/ThirdParty/libwebrtc/Source/webrtc/video/rtp_video_stream_receiver.cc:764
> +    auto interval = frameTime - observedFrameTimeStamps_.front();

Maybe "queueDuration" instead of "interval"?

> Source/WebCore/platform/FrameRateMonitor.h:44
> +    double frameRate() const { return m_observedFrameRate; }

Should this be "observedFrameRate"?

> Source/WebCore/platform/FrameRateMonitor.h:50
> +    static constexpr Seconds MinimumAverageDuration = 1_s;
> +    static constexpr Seconds TimeStampStorageDuration = 2_s;
> +    static constexpr unsigned MaxFrameDelayCount = 3;

Is there a benefit to declaring these here rather than where they are used as you do with the constants in RtpVideoStreamReceiver?
Comment 11 youenn fablet 2020-06-24 02:08:26 PDT
Created attachment 402629 [details]
Patch for landing
Comment 12 youenn fablet 2020-06-24 05:27:08 PDT
Created attachment 402638 [details]
Patch for landing
Comment 13 EWS 2020-06-24 07:07:37 PDT
Committed r263453: <https://trac.webkit.org/changeset/263453>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 402638 [details].
Comment 14 Radar WebKit Bug Importer 2020-06-24 07:08:20 PDT
<rdar://problem/64700061>