Changeset 247525 in webkit


Ignore:
Timestamp:
Jul 17, 2019 11:32:23 AM (5 years ago)
Author:
youenn@apple.com
Message:

Hop to the main thread when doing logging in RealtimeIncomingVideoSourceCocoa
https://bugs.webkit.org/show_bug.cgi?id=199865

Reviewed by Darin Adler.

LoggerHelper routines allow logging messages in system console and inspector console.
These routines iterate through a Vector of log observers which is not thread safe.
Document, the main log observer, also expects to be called on the main thread.
Manually tested (writing a layout test for this would require more than 2 seconds).

  • platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm:

(WebCore::RealtimeIncomingVideoSourceCocoa::OnFrame):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r247523 r247525  
     12019-07-17  Youenn Fablet  <youenn@apple.com>
     2
     3        Hop to the main thread when doing logging in RealtimeIncomingVideoSourceCocoa
     4        https://bugs.webkit.org/show_bug.cgi?id=199865
     5
     6        Reviewed by Darin Adler.
     7
     8        LoggerHelper routines allow logging messages in system console and inspector console.
     9        These routines iterate through a Vector of log observers which is not thread safe.
     10        Document, the main log observer, also expects to be called on the main thread.
     11        Manually tested (writing a layout test for this would require more than 2 seconds).
     12
     13        * platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm:
     14        (WebCore::RealtimeIncomingVideoSourceCocoa::OnFrame):
     15
    1162019-07-17  Commit Queue  <commit-queue@webkit.org>
    217
  • trunk/Source/WebCore/platform/mediastream/mac/RealtimeIncomingVideoSourceCocoa.mm

    r246436 r247525  
    159159
    160160#if !RELEASE_LOG_DISABLED
    161     if (!(++m_numberOfFrames % 60))
    162         ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER, "frame ", m_numberOfFrames);
     161    if (!(++m_numberOfFrames % 60)) {
     162        callOnMainThread([this, protectedThis = makeRef(*this), numberOfFrames = m_numberOfFrames] {
     163            ALWAYS_LOG_IF(loggerPtr(), LOGIDENTIFIER, "frame ", numberOfFrames);
     164        });
     165    }
    163166#endif
    164167
    165168    auto pixelBuffer = pixelBufferFromVideoFrame(frame);
    166169    if (!pixelBuffer) {
    167         ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, "Failed to get a pixel buffer from a frame");
     170        callOnMainThread([this, protectedThis = makeRef(*this)] {
     171            ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, "Failed to get a pixel buffer from a frame");
     172        });
    168173        return;
    169174    }
     
    179184    OSStatus ostatus = CMVideoFormatDescriptionCreateForImageBuffer(kCFAllocatorDefault, (CVImageBufferRef)pixelBuffer, &formatDescription);
    180185    if (ostatus != noErr) {
    181         ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, "Failed to initialize CMVideoFormatDescription with error ", static_cast<int>(ostatus));
     186        callOnMainThread([this, protectedThis = makeRef(*this), ostatus] {
     187            ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, "Failed to initialize CMVideoFormatDescription with error ", static_cast<int>(ostatus));
     188        });
    182189        return;
    183190    }
     
    187194    CFRelease(formatDescription);
    188195    if (ostatus != noErr) {
    189         ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, "Failed to create the sample buffer with error ", static_cast<int>(ostatus));
     196        callOnMainThread([this, protectedThis = makeRef(*this), ostatus] {
     197            ERROR_LOG_IF(loggerPtr(), LOGIDENTIFIER, "Failed to create the sample buffer with error ", static_cast<int>(ostatus));
     198        });
    190199        return;
    191200    }
Note: See TracChangeset for help on using the changeset viewer.