Title: [176471] trunk/Source/WebCore
- Revision
- 176471
- Author
- eric.carl...@apple.com
- Date
- 2014-11-21 13:22:47 -0800 (Fri, 21 Nov 2014)
Log Message
[iOS] allocate volume view on the main thread
https://bugs.webkit.org/show_bug.cgi?id=138971
rdar://problem/18016958
Reviewed by Jer Noble.
* platform/audio/ios/MediaSessionManagerIOS.mm:
(-[WebMediaSessionHelper allocateVolumeView]): New, dispatch to the main thread if necessary before allocating
the volume view.
(-[WebMediaSessionHelper initWithCallback:]): Call allocateVolumeView.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (176470 => 176471)
--- trunk/Source/WebCore/ChangeLog 2014-11-21 21:08:55 UTC (rev 176470)
+++ trunk/Source/WebCore/ChangeLog 2014-11-21 21:22:47 UTC (rev 176471)
@@ -1,3 +1,16 @@
+2014-11-21 Eric Carlson <eric.carl...@apple.com>
+
+ [iOS] allocate volume view on the main thread
+ https://bugs.webkit.org/show_bug.cgi?id=138971
+ rdar://problem/18016958
+
+ Reviewed by Jer Noble.
+
+ * platform/audio/ios/MediaSessionManagerIOS.mm:
+ (-[WebMediaSessionHelper allocateVolumeView]): New, dispatch to the main thread if necessary before allocating
+ the volume view.
+ (-[WebMediaSessionHelper initWithCallback:]): Call allocateVolumeView.
+
2014-11-21 Zalan Bujtas <za...@apple.com>
REGRESSION(r175259) Simple line layout text measuring behavior changed.
Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (176470 => 176471)
--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm 2014-11-21 21:08:55 UTC (rev 176470)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm 2014-11-21 21:22:47 UTC (rev 176471)
@@ -95,6 +95,7 @@
}
- (id)initWithCallback:(MediaSessionManageriOS*)callback;
+- (void)allocateVolumeView;
- (void)clearCallback;
- (void)interruption:(NSNotification *)notification;
- (void)applicationWillEnterForeground:(NSNotification *)notification;
@@ -228,6 +229,23 @@
@implementation WebMediaSessionHelper
+- (void)allocateVolumeView
+{
+ if (!isMainThread()) {
+ // Call synchronously to the main thread so that _volumeView will be completely setup before the constructor completes
+ // because hasWirelessTargetsAvailable is synchronous and can be called on the WebThread.
+ RetainPtr<WebMediaSessionHelper> strongSelf = self;
+ dispatch_sync(dispatch_get_main_queue(), [strongSelf]() {
+ [strongSelf allocateVolumeView];
+ return;
+ });
+ }
+
+ _volumeView = adoptNS([[getMPVolumeViewClass() alloc] init]);
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wirelessRoutesAvailableDidChange:) name:MPVolumeViewWirelessRoutesAvailableDidChangeNotification object:_volumeView.get()];
+
+}
+
- (id)initWithCallback:(MediaSessionManageriOS*)callback
{
LOG(Media, "-[WebMediaSessionHelper initWithCallback]");
@@ -236,7 +254,6 @@
return nil;
_callback = callback;
- _volumeView = adoptNS([[getMPVolumeViewClass() alloc] init]);
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self selector:@selector(interruption:) name:AVAudioSessionInterruptionNotification object:[AVAudioSession sharedInstance]];
@@ -247,8 +264,9 @@
[center addObserver:self selector:@selector(applicationDidBecomeActive:) name:WebUIApplicationDidBecomeActiveNotification object:nil];
[center addObserver:self selector:@selector(applicationWillResignActive:) name:UIApplicationWillResignActiveNotification object:nil];
[center addObserver:self selector:@selector(applicationWillResignActive:) name:WebUIApplicationWillResignActiveNotification object:nil];
- [center addObserver:self selector:@selector(wirelessRoutesAvailableDidChange:) name:MPVolumeViewWirelessRoutesAvailableDidChangeNotification object:_volumeView.get()];
+ [self allocateVolumeView];
+
// Now playing won't work unless we turn on the delivery of remote control events.
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes