Changeset 280840 in webkit
- Timestamp:
- Aug 10, 2021, 7:31:51 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/ios/PlaybackSessionInterfaceAVKit.mm (modified) (1 diff)
-
Source/WebCore/platform/ios/WebAVPlayerController.h (modified) (1 diff)
-
Source/WebCore/platform/ios/WebAVPlayerController.mm (modified) (4 diffs)
-
Source/WebCore/platform/mac/PlaybackSessionInterfaceMac.mm (modified) (1 diff)
-
Source/WebCore/platform/mac/WebPlaybackControlsManager.h (modified) (1 diff)
-
Source/WebCore/platform/mac/WebPlaybackControlsManager.mm (modified) (5 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/VideoControlsManager.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r280826 r280840 1 2021-08-10 Devin Rousso <drousso@apple.com> 2 3 [macOS] REGRESSION(r278850): modifying `playbackRate` via JS on a TouchBar mac only sometimes works and also causes the `defaultPlaybackRate` to change 4 https://bugs.webkit.org/show_bug.cgi?id=228939 5 <rdar://problem/80427578> 6 7 Reviewed by Eric Carlson. 8 9 Test: VideoControlsManager.VideoControlsManagerDoesNotChangeValuesExposedToJavaScript 10 11 * platform/mac/PlaybackSessionInterfaceMac.mm: 12 (WebCore::PlaybackSessionInterfaceMac::rateChanged): 13 Make sure to change the `defaultPlaybackRate` before the `rate` as otherwise the former will 14 override changes made to the latter (see r278850 (and r277203) for details as to why). 15 16 * platform/mac/WebPlaybackControlsManager.h: 17 * platform/mac/WebPlaybackControlsManager.mm: 18 (-[WebPlaybackControlsManager setDefaultPlaybackRate:]): 19 (-[WebPlaybackControlsManager setDefaultPlaybackRate:fromJavaScript:]): Added. 20 (-[WebPlaybackControlsManager setRate:]): 21 (-[WebPlaybackControlsManager setRate:fromJavaScript:]): Added. 22 Add a way to distinguish whether the change to the `rate`/`defaultPlaybackRate` came from JS 23 or some native call (e.g. AVKit). If the former, don't propagate the change to the playback 24 model (which eventually is the `HTMLMediaElement` in the WebProcess) as that's where the 25 value came from in the first place. Note that we still want to propagate the `rate` to the 26 `defaultPlaybackRate` (and vice versa when `isPlaying`) in the UIProcess for the reasons 27 described in r278850 (and r277203), but we don't want to expose it to JS. 28 29 * platform/ios/PlaybackSessionInterfaceAVKit.mm: 30 (WebCore::PlaybackSessionInterfaceAVKit::rateChanged): 31 * platform/ios/WebAVPlayerController.h: 32 * platform/ios/WebAVPlayerController.mm: 33 (-[WebAVPlayerController setDefaultPlaybackRate:]): 34 (-[WebAVPlayerController setDefaultPlaybackRate:fromJavaScript:]): Added. 35 (-[WebAVPlayerController setRate:]): 36 (-[WebAVPlayerController setRate:fromJavaScript:]): Added. 37 Drive-by: r278850 was based r277203 (which added the above), so fix that code now too. 38 1 39 2021-08-09 Yusuke Suzuki <ysuzuki@apple.com> 2 40 -
trunk/Source/WebCore/platform/ios/PlaybackSessionInterfaceAVKit.mm
r279335 r280840 131 131 void PlaybackSessionInterfaceAVKit::rateChanged(OptionSet<PlaybackSessionModel::PlaybackState> playbackState, double playbackRate, double defaultPlaybackRate) 132 132 { 133 [m_playerController setDefaultPlaybackRate:defaultPlaybackRate ];133 [m_playerController setDefaultPlaybackRate:defaultPlaybackRate fromJavaScript:YES]; 134 134 if (!playbackState.contains(PlaybackSessionModel::PlaybackState::Stalled)) 135 [m_playerController setRate:playbackState.contains(PlaybackSessionModel::PlaybackState::Playing) ? playbackRate : 0. ];135 [m_playerController setRate:playbackState.contains(PlaybackSessionModel::PlaybackState::Playing) ? playbackRate : 0. fromJavaScript:YES]; 136 136 } 137 137 -
trunk/Source/WebCore/platform/ios/WebAVPlayerController.h
r274249 r280840 104 104 @property (NS_NONATOMIC_IOSONLY, retain, readwrite) AVValueTiming *minTiming; 105 105 @property (NS_NONATOMIC_IOSONLY, retain, readwrite) AVValueTiming *maxTiming; 106 107 - (void)setDefaultPlaybackRate:(double)defaultPlaybackRate fromJavaScript:(BOOL)fromJavaScript; 108 - (void)setRate:(double)rate fromJavaScript:(BOOL)fromJavaScript; 106 109 @end 107 110 -
trunk/Source/WebCore/platform/ios/WebAVPlayerController.mm
r277203 r280840 166 166 - (void)setDefaultPlaybackRate:(double)defaultPlaybackRate 167 167 { 168 [self setDefaultPlaybackRate:defaultPlaybackRate fromJavaScript:NO]; 169 } 170 171 - (void)setDefaultPlaybackRate:(double)defaultPlaybackRate fromJavaScript:(BOOL)fromJavaScript 172 { 168 173 if (defaultPlaybackRate == _defaultPlaybackRate) 169 174 return; … … 171 176 _defaultPlaybackRate = defaultPlaybackRate; 172 177 173 if ( self.delegate && self.delegate->defaultPlaybackRate() != _defaultPlaybackRate)178 if (!fromJavaScript && self.delegate && self.delegate->defaultPlaybackRate() != _defaultPlaybackRate) 174 179 self.delegate->setDefaultPlaybackRate(_defaultPlaybackRate); 175 180 176 181 if ([self isPlaying]) 177 [self setRate:_defaultPlaybackRate ];182 [self setRate:_defaultPlaybackRate fromJavaScript:fromJavaScript]; 178 183 } 179 184 … … 184 189 185 190 - (void)setRate:(double)rate 191 { 192 [self setRate:rate fromJavaScript:NO]; 193 } 194 195 - (void)setRate:(double)rate fromJavaScript:(BOOL)fromJavaScript 186 196 { 187 197 if (rate == _rate) … … 202 212 // resuming after pausing. As such, WebKit should return the `playbackRate` instead of the 203 213 // `defaultPlaybackRate` in these cases when communicating with AVKit. 204 [self setDefaultPlaybackRate:_rate ];205 206 if ( self.delegate && self.delegate->playbackRate() != _rate)214 [self setDefaultPlaybackRate:_rate fromJavaScript:fromJavaScript]; 215 216 if (!fromJavaScript && self.delegate && self.delegate->playbackRate() != _rate) 207 217 self.delegate->setPlaybackRate(_rate); 208 218 } -
trunk/Source/WebCore/platform/mac/PlaybackSessionInterfaceMac.mm
r279043 r280840 98 98 auto isPlaying = playbackState.contains(PlaybackSessionModel::PlaybackState::Playing); 99 99 WebPlaybackControlsManager* controlsManager = playBackControlsManager(); 100 [controlsManager set Rate:isPlaying ? playbackRate : 0.];101 [controlsManager set DefaultPlaybackRate:defaultPlaybackRate];100 [controlsManager setDefaultPlaybackRate:defaultPlaybackRate fromJavaScript:YES]; 101 [controlsManager setRate:isPlaying ? playbackRate : 0. fromJavaScript:YES]; 102 102 [controlsManager setPlaying:isPlaying]; 103 103 updatePlaybackControlsManagerTiming(m_playbackSessionModel ? m_playbackSessionModel->currentTime() : 0, [[NSProcessInfo processInfo] systemUptime], playbackRate, isPlaying); -
trunk/Source/WebCore/platform/mac/WebPlaybackControlsManager.h
r275100 r280840 85 85 - (void)setAudioMediaSelectionIndex:(NSUInteger)selectedIndex; 86 86 - (void)setLegibleMediaSelectionIndex:(NSUInteger)selectedIndex; 87 88 - (void)setDefaultPlaybackRate:(double)defaultPlaybackRate fromJavaScript:(BOOL)fromJavaScript; 89 - (void)setRate:(double)rate fromJavaScript:(BOOL)fromJavaScript; 87 90 @end 88 91 -
trunk/Source/WebCore/platform/mac/WebPlaybackControlsManager.mm
r278850 r280840 337 337 - (void)setDefaultPlaybackRate:(double)defaultPlaybackRate 338 338 { 339 [self setDefaultPlaybackRate:defaultPlaybackRate fromJavaScript:NO]; 340 } 341 342 - (void)setDefaultPlaybackRate:(double)defaultPlaybackRate fromJavaScript:(BOOL)fromJavaScript 343 { 339 344 if (defaultPlaybackRate == _defaultPlaybackRate) 340 345 return; … … 342 347 _defaultPlaybackRate = defaultPlaybackRate; 343 348 344 if ( _playbackSessionInterfaceMac) {349 if (!fromJavaScript && _playbackSessionInterfaceMac) { 345 350 if (auto* model = _playbackSessionInterfaceMac->playbackSessionModel(); model && model->defaultPlaybackRate() != _defaultPlaybackRate) 346 351 model->setDefaultPlaybackRate(_defaultPlaybackRate); … … 348 353 349 354 if ([self isPlaying]) 350 [self setRate:_defaultPlaybackRate ];355 [self setRate:_defaultPlaybackRate fromJavaScript:fromJavaScript]; 351 356 } 352 357 … … 357 362 358 363 - (void)setRate:(float)rate 364 { 365 [self setRate:rate fromJavaScript:NO]; 366 } 367 368 - (void)setRate:(double)rate fromJavaScript:(BOOL)fromJavaScript 359 369 { 360 370 if (rate == _rate) … … 375 385 // resuming after pausing. As such, WebKit should return the `playbackRate` instead of the 376 386 // `defaultPlaybackRate` in these cases when communicating with AVKit. 377 [self setDefaultPlaybackRate:_rate ];378 379 if ( _playbackSessionInterfaceMac) {387 [self setDefaultPlaybackRate:_rate fromJavaScript:fromJavaScript]; 388 389 if (!fromJavaScript && _playbackSessionInterfaceMac) { 380 390 if (auto* model = _playbackSessionInterfaceMac->playbackSessionModel(); model && model->playbackRate() != _rate) 381 391 model->setPlaybackRate(_rate); -
trunk/Tools/ChangeLog
r280767 r280840 1 2021-08-10 Devin Rousso <drousso@apple.com> 2 3 [macOS] REGRESSION(r278850): modifying `playbackRate` via JS on a TouchBar mac only sometimes works and also causes the `defaultPlaybackRate` to change 4 https://bugs.webkit.org/show_bug.cgi?id=228939 5 <rdar://problem/80427578> 6 7 Reviewed by Eric Carlson. 8 9 * TestWebKitAPI/Tests/WebKitCocoa/VideoControlsManager.mm: 10 (TestWebKitAPI::TEST.VideoControlsManager.VideoControlsManagerDoesNotChangeValuesExposedToJavaScript): Added. 11 1 12 2021-08-08 Wenson Hsieh <wenson_hsieh@apple.com> 2 13 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/VideoControlsManager.mm
r272919 r280840 29 29 #import "TestWKWebView.h" 30 30 #import <WebKit/WKWebViewConfigurationPrivate.h> 31 #import <WebKit/WKWebViewPrivate.h> 31 32 #import <WebKit/WKWebViewPrivateForTesting.h> 32 33 #import <wtf/RetainPtr.h> … … 465 466 } 466 467 468 TEST(VideoControlsManager, VideoControlsManagerDoesNotChangeValuesExposedToJavaScript) 469 { 470 RetainPtr<VideoControlsManagerTestWebView> webView = setUpWebViewForTestingVideoControlsManager(NSMakeRect(0, 0, 500, 500)); 471 472 // A large video with audio should have a controls manager even if it is played via script like this video. 473 // So the expectation is YES. 474 [webView loadTestPageNamed:@"large-video-with-audio"]; 475 [webView waitForMediaControlsToShow]; 476 [webView _updateMediaPlaybackControlsManager]; 477 478 EXPECT_EQ(1.0, [[webView objectByEvaluatingJavaScript:@"document.getElementsByTagName('video')[0].playbackRate"] doubleValue]); 479 EXPECT_EQ(1.0, [[webView objectByEvaluatingJavaScript:@"document.getElementsByTagName('video')[0].defaultPlaybackRate"] doubleValue]); 480 481 [webView objectByEvaluatingJavaScript:@"document.getElementsByTagName('video')[0].playbackRate = 2.0;"]; 482 483 EXPECT_EQ(2.0, [[webView objectByEvaluatingJavaScript:@"document.getElementsByTagName('video')[0].playbackRate"] doubleValue]); 484 EXPECT_EQ(1.0, [[webView objectByEvaluatingJavaScript:@"document.getElementsByTagName('video')[0].defaultPlaybackRate"] doubleValue]); 485 } 486 467 487 } // namespace TestWebKitAPI 468 488
Note:
See TracChangeset
for help on using the changeset viewer.