Changeset 276222 in webkit
- Timestamp:
- Apr 17, 2021, 10:23:02 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp (modified) (1 diff)
-
Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h (modified) (3 diffs)
-
Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm (modified) (7 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/GPUProcess.mm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r276221 r276222 1 2021-04-17 Chris Dumez <cdumez@apple.com> 2 3 GPUConnectionToWebProcess::allowsExitUnderMemoryPressure() should check if libWebRTCCodecsProxy is used 4 https://bugs.webkit.org/show_bug.cgi?id=224709 5 6 Reviewed by Darin Adler. 7 8 If the libWebRTCCodecsProxy has either encoders or decoders then the GPUProcess should not 9 exit under memory pressure, since it is not idle. 10 11 * GPUProcess/GPUConnectionToWebProcess.cpp: 12 (WebKit::GPUConnectionToWebProcess::allowsExitUnderMemoryPressure const): 13 * GPUProcess/webrtc/LibWebRTCCodecsProxy.h: 14 * GPUProcess/webrtc/LibWebRTCCodecsProxy.mm: 15 (WebKit::LibWebRTCCodecsProxy::createH264Decoder): 16 (WebKit::LibWebRTCCodecsProxy::createH265Decoder): 17 (WebKit::LibWebRTCCodecsProxy::createVP9Decoder): 18 (WebKit::LibWebRTCCodecsProxy::releaseDecoder): 19 (WebKit::LibWebRTCCodecsProxy::createEncoder): 20 (WebKit::LibWebRTCCodecsProxy::releaseEncoder): 21 (WebKit::LibWebRTCCodecsProxy::updateHasEncodersOrDecoders): 22 (WebKit::LibWebRTCCodecsProxy::allowsExitUnderMemoryPressure const): 23 Use a std::atomic<bool> to determine if the LibWebRTCCodecsProxy has encoders/decoders since 24 allowsExitUnderMemoryPressure() gets called on the main thread but m_encoders / m_decoders 25 get updated on a background thread. 26 1 27 2021-04-17 Kimmo Kinnunen <kkinnunen@apple.com> 2 28 -
trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp
r276148 r276222 308 308 return false; 309 309 #endif 310 #if PLATFORM(COCOA) && USE(LIBWEBRTC) 311 if (!m_libWebRTCCodecsProxy->allowsExitUnderMemoryPressure()) 312 return false; 313 #endif 310 314 return true; 311 315 } -
trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h
r270573 r276222 60 60 void close(); 61 61 62 bool allowsExitUnderMemoryPressure() const; 63 62 64 private: 63 65 explicit LibWebRTCCodecsProxy(GPUConnectionToWebProcess&); … … 81 83 void setEncodeRates(RTCEncoderIdentifier, uint32_t bitRate, uint32_t frameRate); 82 84 85 void updateHasEncodersOrDecoders(); 86 83 87 CFDictionaryRef ioSurfacePixelBufferCreationOptions(IOSurfaceRef); 84 88 … … 86 90 HashMap<RTCDecoderIdentifier, webrtc::LocalDecoder> m_decoders; 87 91 HashMap<RTCEncoderIdentifier, webrtc::LocalEncoder> m_encoders; 92 std::atomic<bool> m_hasEncodersOrDecoders; 88 93 89 94 Ref<WorkQueue> m_queue; -
trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm
r270905 r276222 79 79 connection->send(Messages::LibWebRTCCodecs::CompletedDecoding { identifier, timeStamp, *sample }, 0); 80 80 }).get())); 81 updateHasEncodersOrDecoders(); 81 82 } 82 83 … … 88 89 connection->send(Messages::LibWebRTCCodecs::CompletedDecoding { identifier, timeStamp, *sample }, 0); 89 90 }).get())); 91 updateHasEncodersOrDecoders(); 90 92 } 91 93 … … 97 99 connection->send(Messages::LibWebRTCCodecs::CompletedDecoding { identifier, timeStamp, *sample }, 0); 98 100 }).get())); 101 updateHasEncodersOrDecoders(); 99 102 } 100 103 … … 102 105 { 103 106 ASSERT(m_decoders.contains(identifier)); 104 if (auto decoder = m_decoders.take(identifier)) 107 if (auto decoder = m_decoders.take(identifier)) { 105 108 webrtc::releaseLocalDecoder(decoder); 109 updateHasEncodersOrDecoders(); 110 } 106 111 } 107 112 … … 140 145 webrtc::setLocalEncoderLowLatency(encoder, useLowLatency); 141 146 m_encoders.add(identifier, encoder); 147 updateHasEncodersOrDecoders(); 142 148 } 143 149 … … 145 151 { 146 152 ASSERT(m_encoders.contains(identifier)); 147 if (auto encoder = m_encoders.take(identifier)) 153 if (auto encoder = m_encoders.take(identifier)) { 148 154 webrtc::releaseLocalEncoder(encoder); 155 updateHasEncodersOrDecoders(); 156 } 149 157 } 150 158 … … 200 208 } 201 209 210 void LibWebRTCCodecsProxy::updateHasEncodersOrDecoders() 211 { 212 m_hasEncodersOrDecoders = !m_encoders.isEmpty() || !m_decoders.isEmpty(); 213 } 214 215 bool LibWebRTCCodecsProxy::allowsExitUnderMemoryPressure() const 216 { 217 return !m_hasEncodersOrDecoders; 218 } 219 202 220 } 203 221 -
trunk/Tools/ChangeLog
r276219 r276222 1 2021-04-17 Chris Dumez <cdumez@apple.com> 2 3 GPUConnectionToWebProcess::allowsExitUnderMemoryPressure() should check if libWebRTCCodecsProxy is used 4 https://bugs.webkit.org/show_bug.cgi?id=224709 5 6 Reviewed by Darin Adler. 7 8 Add API test coverage. 9 10 * TestWebKitAPI/Tests/WebKitCocoa/GPUProcess.mm: 11 (runMemoryPressureExitTest): 12 (waitUntilCaptureState): 13 (TEST): 14 1 15 2021-04-17 Wenson Hsieh <wenson_hsieh@apple.com> 2 16 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/GPUProcess.mm
r276189 r276222 29 29 #import "TestNavigationDelegate.h" 30 30 #import "TestWKWebView.h" 31 #import "UserMediaCaptureUIDelegate.h" 31 32 #import <WebKit/WKPreferencesPrivate.h> 32 33 #import <WebKit/WKPreferencesRefPrivate.h> … … 34 35 #import <WebKit/WKString.h> 35 36 #import <WebKit/WKWebViewConfiguration.h> 37 #import <WebKit/WKWebViewConfigurationPrivate.h> 36 38 #import <WebKit/WKWebViewPrivate.h> 37 39 #import <notify.h> … … 494 496 } 495 497 496 static void runMemoryPressureExitTest(Function<void(WKWebView *)>&& loadTestPageSynchronously )498 static void runMemoryPressureExitTest(Function<void(WKWebView *)>&& loadTestPageSynchronously, Function<void(WKWebViewConfiguration *)>&& updateConfiguration = [](WKWebViewConfiguration *) { }) 497 499 { 498 500 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 499 501 WKPreferencesSetBoolValueForKeyForTesting((__bridge WKPreferencesRef)[configuration preferences], true, WKStringCreateWithUTF8CString("UseGPUProcessForMediaEnabled")); 500 502 WKPreferencesSetBoolValueForKeyForTesting((__bridge WKPreferencesRef)[configuration preferences], true, WKStringCreateWithUTF8CString("CaptureVideoInGPUProcessEnabled")); 503 WKPreferencesSetBoolValueForKeyForTesting((__bridge WKPreferencesRef)[configuration preferences], true, WKStringCreateWithUTF8CString("CaptureAudioInGPUProcessEnabled")); 504 WKPreferencesSetBoolValueForKeyForTesting((__bridge WKPreferencesRef)[configuration preferences], true, WKStringCreateWithUTF8CString("WebRTCPlatformCodecsInGPUProcessEnabled")); 505 WKPreferencesSetBoolValueForKeyForTesting((__bridge WKPreferencesRef)[configuration preferences], false, WKStringCreateWithUTF8CString("CaptureAudioInUIProcessEnabled")); 501 506 WKPreferencesSetBoolValueForKeyForTesting((__bridge WKPreferencesRef)[configuration preferences], true, WKStringCreateWithUTF8CString("UseGPUProcessForCanvasRenderingEnabled")); 502 507 WKPreferencesSetBoolValueForKeyForTesting((__bridge WKPreferencesRef)[configuration preferences], false, WKStringCreateWithUTF8CString("UseGPUProcessForDOMRenderingEnabled")); 508 509 updateConfiguration(configuration.get()); 503 510 504 511 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 400, 400) configuration:configuration.get()]); … … 566 573 } 567 574 575 #if ENABLE(MEDIA_STREAM) 576 static bool waitUntilCaptureState(WKWebView *webView, _WKMediaCaptureStateDeprecated expectedState) 577 { 578 NSTimeInterval end = [[NSDate date] timeIntervalSinceReferenceDate] + 10; 579 do { 580 if ([webView _mediaCaptureState] == expectedState) 581 return true; 582 583 TestWebKitAPI::Util::spinRunLoop(1); 584 585 if ([[NSDate date] timeIntervalSinceReferenceDate] > end) 586 break; 587 } while (true); 588 589 return false; 590 } 591 592 TEST(GPUProcess, ExitsUnderMemoryPressureWebRTCCase) 593 { 594 runMemoryPressureExitTest([](WKWebView *webView) { 595 auto delegate = adoptNS([[UserMediaCaptureUIDelegate alloc] init]); 596 webView.UIDelegate = delegate.get(); 597 598 [webView loadTestPageNamed:@"getUserMedia"]; 599 EXPECT_TRUE(waitUntilCaptureState(webView, _WKMediaCaptureStateDeprecatedActiveCamera)); 600 [webView stringByEvaluatingJavaScript:@"captureAudioAndVideo(true)"]; 601 [webView stringByEvaluatingJavaScript:@"createConnection()"]; 602 }, [](WKWebViewConfiguration* configuration) { 603 auto preferences = configuration.preferences; 604 preferences._mediaCaptureRequiresSecureConnection = NO; 605 configuration._mediaCaptureEnabled = YES; 606 preferences._mockCaptureDevicesEnabled = YES; 607 }); 608 } 609 #endif // ENABLE(MEDIA_STREAM) 610 568 611 TEST(GPUProcess, ExitsUnderMemoryPressureWebAudioCase) 569 612 {
Note:
See TracChangeset
for help on using the changeset viewer.