Bug 195823

Summary: Add media stream release logging
Product: WebKit Reporter: Eric Carlson <eric.carlson>
Component: WebRTCAssignee: Eric Carlson <eric.carlson>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, ews-watchlist, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=196517
Attachments:
Description Flags
Patch
youennf: review+
Patch for landing.
none
Patch for landing. none

Description Eric Carlson 2019-03-15 14:45:21 PDT
Add media stream release logging and update some WebRTC logging.
Comment 1 Radar WebKit Bug Importer 2019-03-15 14:50:21 PDT
<rdar://problem/48939406>
Comment 2 Eric Carlson 2019-03-15 14:57:40 PDT
Created attachment 364851 [details]
Patch
Comment 3 EWS Watchlist 2019-03-15 15:00:38 PDT
Attachment 364851 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/IntSize.h:29:  Alphabetical sorting problem.  [build/include_order] [4]
ERROR: Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp:1085:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
ERROR: Source/WebCore/platform/mediastream/RealtimeMediaSource.h:188:  Inline functions should not be in classes annotated with WEBCORE_EXPORT. Remove the macro from the class and apply it to each appropriate method, or move the inline function definition out-of-line.  [build/webcore_export] [4]
ERROR: Source/WebCore/platform/mediastream/RealtimeMediaSource.h:189:  Inline functions should not be in classes annotated with WEBCORE_EXPORT. Remove the macro from the class and apply it to each appropriate method, or move the inline function definition out-of-line.  [build/webcore_export] [4]
ERROR: Source/WebCore/platform/mediastream/RealtimeMediaSource.h:190:  Inline functions should not be in classes annotated with WEBCORE_EXPORT. Remove the macro from the class and apply it to each appropriate method, or move the inline function definition out-of-line.  [build/webcore_export] [4]
ERROR: Source/WebCore/platform/mediastream/RealtimeMediaSource.h:191:  Inline functions should not be in classes annotated with WEBCORE_EXPORT. Remove the macro from the class and apply it to each appropriate method, or move the inline function definition out-of-line.  [build/webcore_export] [4]
ERROR: Source/WebCore/platform/mediastream/RealtimeMediaSourceSettings.cpp:176:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
Total errors found: 7 in 39 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 youenn fablet 2019-03-15 15:28:17 PDT
Comment on attachment 364851 [details]
Patch

LGTM.

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

> Source/WebCore/Modules/mediastream/MediaStream.cpp:311
>          LOG(Media, "MediaStream::startProducingData(%p) - not allowed to start in background, waiting", this);

Move to release logging?

> Source/WebCore/Modules/mediastream/MediaStream.cpp:502
> +    ALWAYS_LOG(LOGIDENTIFIER);

Do we need this one, it seems endCaptureTracks) will do these things anyway.

> Source/WebCore/html/HTMLMediaElement.h:564
> +    const void* logIdentifier() const final { return m_logIdentifier; }

We could simply return 'this' pointer here and maybe elsewhere.
That would remove the need for m_logIdentifier.

> Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h:43
> +class MediaStreamTrackPrivate

final here and maybe some other classes.

> Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h:122
> +    const void* logIdentifier() const final { return m_logIdentifier; }

Can these two final be private?

> Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h:147
> +#endif

This class and some others do not log right now.
Is this code to make it happen in the future or is it allow getting the logger for some other classes?

> Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp:176
> +            INFO_LOG_IF(loggerPtr(), LOGIDENTIFIER, m_frameCount, " frames sent in ", delta.value(), " seconds");

Is it safe to log from a background thread?

> Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm:368
> +                    return;

Maybe document this change in log, this seems unrelated to adding logging.

> Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp:272
> +        RELEASE_LOG_ERROR(Media, "CoreAudioSharedUnit::setupAudioUnit(%p) unable to find vpio unit component", this);

Should we go with WebRTC here?
Comment 5 Eric Carlson 2019-03-15 15:57:44 PDT
Comment on attachment 364851 [details]
Patch

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

>> Source/WebCore/Modules/mediastream/MediaStream.cpp:311
>>          LOG(Media, "MediaStream::startProducingData(%p) - not allowed to start in background, waiting", this);
> 
> Move to release logging?

Oops, thanks.

>> Source/WebCore/Modules/mediastream/MediaStream.cpp:502
>> +    ALWAYS_LOG(LOGIDENTIFIER);
> 
> Do we need this one, it seems endCaptureTracks) will do these things anyway.

OK

>> Source/WebCore/html/HTMLMediaElement.h:564
>> +    const void* logIdentifier() const final { return m_logIdentifier; }
> 
> We could simply return 'this' pointer here and maybe elsewhere.
> That would remove the need for m_logIdentifier.

We aren't supposed to log addresses.

>> Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h:43
>> +class MediaStreamTrackPrivate
> 
> final here and maybe some other classes.

OK

>> Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h:122
>> +    const void* logIdentifier() const final { return m_logIdentifier; }
> 
> Can these two final be private?

They are both used by the RealtimeOutgoing sources.

>> Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h:147
>> +#endif
> 
> This class and some others do not log right now.
> Is this code to make it happen in the future or is it allow getting the logger for some other classes?

It sets the RealtimeMediaSource logger/log identifier.

>> Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp:176
>> +            INFO_LOG_IF(loggerPtr(), LOGIDENTIFIER, m_frameCount, " frames sent in ", delta.value(), " seconds");
> 
> Is it safe to log from a background thread?

No, but this is always called on the main thread.

>> Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp:272
>> +        RELEASE_LOG_ERROR(Media, "CoreAudioSharedUnit::setupAudioUnit(%p) unable to find vpio unit component", this);
> 
> Should we go with WebRTC here?

Good idea, changed.
Comment 6 Eric Carlson 2019-03-15 16:00:50 PDT
Created attachment 364867 [details]
Patch for landing.
Comment 7 youenn fablet 2019-03-15 16:01:25 PDT
> >> Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp:176
> >> +            INFO_LOG_IF(loggerPtr(), LOGIDENTIFIER, m_frameCount, " frames sent in ", delta.value(), " seconds");
> > 
> > Is it safe to log from a background thread?
> 
> No, but this is always called on the main thread.

I am not sure we always log from the main thread, videoSampleAvailable might be called from the capture thread. This might be a preexisting issue in fact.
Comment 8 Eric Carlson 2019-03-15 16:15:36 PDT
> > >> Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp:176
> > >> +            INFO_LOG_IF(loggerPtr(), LOGIDENTIFIER, m_frameCount, " frames sent in ", delta.value(), " seconds");
> > > 
> > > Is it safe to log from a background thread?
> > 
> > No, but this is always called on the main thread.
> 
> I am not sure we always log from the main thread, videoSampleAvailable might
> be called from the capture thread. This might be a preexisting issue in fact.

As we discussed on irc, this should only be called on the main thread. I'll add an ASSERT in a new patch.
Comment 9 EWS Watchlist 2019-03-15 16:17:05 PDT
Attachment 364867 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/IntSize.h:29:  Alphabetical sorting problem.  [build/include_order] [4]
ERROR: Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp:1085:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
ERROR: Source/WebCore/platform/mediastream/RealtimeMediaSource.h:188:  Inline functions should not be in classes annotated with WEBCORE_EXPORT. Remove the macro from the class and apply it to each appropriate method, or move the inline function definition out-of-line.  [build/webcore_export] [4]
ERROR: Source/WebCore/platform/mediastream/RealtimeMediaSource.h:189:  Inline functions should not be in classes annotated with WEBCORE_EXPORT. Remove the macro from the class and apply it to each appropriate method, or move the inline function definition out-of-line.  [build/webcore_export] [4]
ERROR: Source/WebCore/platform/mediastream/RealtimeMediaSource.h:190:  Inline functions should not be in classes annotated with WEBCORE_EXPORT. Remove the macro from the class and apply it to each appropriate method, or move the inline function definition out-of-line.  [build/webcore_export] [4]
ERROR: Source/WebCore/platform/mediastream/RealtimeMediaSource.h:191:  Inline functions should not be in classes annotated with WEBCORE_EXPORT. Remove the macro from the class and apply it to each appropriate method, or move the inline function definition out-of-line.  [build/webcore_export] [4]
ERROR: Source/WebCore/platform/mediastream/RealtimeMediaSourceSettings.cpp:176:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
Total errors found: 7 in 39 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 10 Eric Carlson 2019-03-15 20:34:54 PDT
Created attachment 364904 [details]
Patch for landing.
Comment 11 EWS Watchlist 2019-03-15 20:37:32 PDT
Attachment 364904 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/IntSize.h:29:  Alphabetical sorting problem.  [build/include_order] [4]
ERROR: Source/WebCore/platform/mediastream/RealtimeMediaSource.cpp:1085:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
ERROR: Source/WebCore/platform/mediastream/RealtimeMediaSource.h:188:  Inline functions should not be in classes annotated with WEBCORE_EXPORT. Remove the macro from the class and apply it to each appropriate method, or move the inline function definition out-of-line.  [build/webcore_export] [4]
ERROR: Source/WebCore/platform/mediastream/RealtimeMediaSource.h:189:  Inline functions should not be in classes annotated with WEBCORE_EXPORT. Remove the macro from the class and apply it to each appropriate method, or move the inline function definition out-of-line.  [build/webcore_export] [4]
ERROR: Source/WebCore/platform/mediastream/RealtimeMediaSource.h:190:  Inline functions should not be in classes annotated with WEBCORE_EXPORT. Remove the macro from the class and apply it to each appropriate method, or move the inline function definition out-of-line.  [build/webcore_export] [4]
ERROR: Source/WebCore/platform/mediastream/RealtimeMediaSource.h:191:  Inline functions should not be in classes annotated with WEBCORE_EXPORT. Remove the macro from the class and apply it to each appropriate method, or move the inline function definition out-of-line.  [build/webcore_export] [4]
ERROR: Source/WebCore/platform/mediastream/RealtimeMediaSourceSettings.cpp:176:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
Total errors found: 7 in 40 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 12 WebKit Commit Bot 2019-03-15 22:21:49 PDT
Comment on attachment 364904 [details]
Patch for landing.

Clearing flags on attachment: 364904

Committed r243033: <https://trac.webkit.org/changeset/243033>