Changeset 247238 in webkit
- Timestamp:
- Jul 8, 2019 4:51:43 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r247232 r247238 1 2019-07-08 Youenn Fablet <youenn@apple.com> 2 3 Hop explicitly to the main thread after generating a frame in ScreenDisplayCaptureSourceMac 4 https://bugs.webkit.org/show_bug.cgi?id=199581 5 6 Reviewed by Eric Carlson. 7 8 Instead of locking and setting the current frame from a background thread, hop to the main thread. 9 This also makes sure the weakThis check is done in the main thread. 10 Manually tested. 11 12 * platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h: 13 (WebCore::ScreenDisplayCaptureSourceMac::DisplaySurface::DisplaySurface): 14 * platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm: 15 (WebCore::ScreenDisplayCaptureSourceMac::createDisplayStream): 16 (WebCore::ScreenDisplayCaptureSourceMac::generateFrame): 17 (WebCore::ScreenDisplayCaptureSourceMac::newFrame): 18 (WebCore::ScreenDisplayCaptureSourceMac::frameAvailable): Deleted. 19 1 20 2019-07-08 Daniel Bates <dabates@apple.com> 2 21 -
trunk/Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.h
r243033 r247238 55 55 void displayWasReconfigured(CGDirectDisplayID, CGDisplayChangeSummaryFlags); 56 56 57 void frameAvailable(CGDisplayStreamFrameStatus, uint64_t, IOSurfaceRef, CGDisplayStreamUpdateRef);58 59 57 DisplayCaptureSourceCocoa::DisplayFrameType generateFrame() final; 60 58 RealtimeMediaSourceSettings::DisplaySurfaceType surfaceType() const final { return RealtimeMediaSourceSettings::DisplaySurfaceType::Monitor; } … … 75 73 public: 76 74 DisplaySurface() = default; 75 explicit DisplaySurface(IOSurfaceRef surface) 76 : m_surface(surface) 77 { 78 if (m_surface) 79 IOSurfaceIncrementUseCount(m_surface.get()); 80 } 81 77 82 ~DisplaySurface() 78 83 { … … 97 102 }; 98 103 99 mutable Lock m_currentFrameMutex; 104 void newFrame(CGDisplayStreamFrameStatus, DisplaySurface&&); 105 100 106 DisplaySurface m_currentFrame; 101 107 RetainPtr<CGDisplayStreamRef> m_displayStream; -
trunk/Source/WebCore/platform/mediastream/mac/ScreenDisplayCaptureSourceMac.mm
r245216 r247238 155 155 auto weakThis = makeWeakPtr(*this); 156 156 auto frameAvailableBlock = ^(CGDisplayStreamFrameStatus status, uint64_t displayTime, IOSurfaceRef frameSurface, CGDisplayStreamUpdateRef updateRef) { 157 if (!weakThis) 157 158 if (!frameSurface || !displayTime) 158 159 return; 159 160 160 weakThis->frameAvailable(status, displayTime, frameSurface, updateRef); 161 size_t count; 162 auto* rects = CGDisplayStreamUpdateGetRects(updateRef, kCGDisplayStreamUpdateDirtyRects, &count); 163 if (!rects || !count) 164 return; 165 166 RunLoop::main().dispatch([weakThis, status, frame = DisplaySurface { frameSurface }]() mutable { 167 if (!weakThis) 168 return; 169 weakThis->newFrame(status, WTFMove(frame)); 170 }); 161 171 }; 162 172 … … 204 214 DisplayCaptureSourceCocoa::DisplayFrameType ScreenDisplayCaptureSourceMac::generateFrame() 205 215 { 206 DisplaySurface currentFrame; 207 { 208 LockHolder lock(m_currentFrameMutex); 209 currentFrame = m_currentFrame.ioSurface(); 210 } 211 212 return DisplayCaptureSourceCocoa::DisplayFrameType { RetainPtr<IOSurfaceRef> { currentFrame.ioSurface() } }; 216 return DisplayCaptureSourceCocoa::DisplayFrameType { RetainPtr<IOSurfaceRef> { m_currentFrame.ioSurface() } }; 213 217 } 214 218 … … 254 258 } 255 259 256 void ScreenDisplayCaptureSourceMac:: frameAvailable(CGDisplayStreamFrameStatus status, uint64_t displayTime, IOSurfaceRef frameSurface, CGDisplayStreamUpdateRef updateRef)260 void ScreenDisplayCaptureSourceMac::newFrame(CGDisplayStreamFrameStatus status, DisplaySurface&& newFrame) 257 261 { 258 262 switch (status) { … … 272 276 } 273 277 274 if (!frameSurface || !displayTime) 275 return; 276 277 size_t count; 278 auto* rects = CGDisplayStreamUpdateGetRects(updateRef, kCGDisplayStreamUpdateDirtyRects, &count); 279 if (!rects || !count) 280 return; 281 282 LockHolder lock(m_currentFrameMutex); 283 m_currentFrame = frameSurface; 278 m_currentFrame = WTFMove(newFrame); 284 279 } 285 280
Note: See TracChangeset
for help on using the changeset viewer.