Diff
Modified: trunk/Source/WebCore/ChangeLog (279185 => 279186)
--- trunk/Source/WebCore/ChangeLog 2021-06-23 20:44:00 UTC (rev 279185)
+++ trunk/Source/WebCore/ChangeLog 2021-06-23 21:21:48 UTC (rev 279186)
@@ -1,3 +1,18 @@
+2021-06-23 Jer Noble <[email protected]>
+
+ [Cocoa] Make the hostTime parameter to playSession a Monotonic time
+ https://bugs.webkit.org/show_bug.cgi?id=226515
+
+ Reviewed by Youenn Fablet.
+
+ Fire the playSession action handler at approximately the hostTime indicated by the MediaSessionCoordinatorPrivate.
+
+ * Modules/mediasession/MediaSessionCoordinator.cpp:
+ (WebCore::MediaSessionCoordinator::playSession):
+ * Modules/mediasession/MediaSessionCoordinator.h:
+ * Modules/mediasession/MediaSessionCoordinatorPrivate.h:
+ (WebCore::MediaSessionCoordinatorClient::playSession):
+
2021-06-23 Mark Lam <[email protected]>
Remove unneeded explicit exception checks in ScriptModuleLoader::evaluate().
Modified: trunk/Source/WebCore/Modules/mediasession/MediaSessionCoordinator.cpp (279185 => 279186)
--- trunk/Source/WebCore/Modules/mediasession/MediaSessionCoordinator.cpp 2021-06-23 20:44:00 UTC (rev 279185)
+++ trunk/Source/WebCore/Modules/mediasession/MediaSessionCoordinator.cpp 2021-06-23 21:21:48 UTC (rev 279186)
@@ -362,10 +362,11 @@
completionHandler(true);
}
-void MediaSessionCoordinator::playSession(std::optional<double> atTime, std::optional<double> hostTime, CompletionHandler<void(bool)>&& completionHandler)
+void MediaSessionCoordinator::playSession(std::optional<double> atTime, std::optional<MonotonicTime> hostTime, CompletionHandler<void(bool)>&& completionHandler)
{
- UNUSED_PARAM(hostTime);
- ALWAYS_LOG(LOGIDENTIFIER, m_state);
+ auto now = MonotonicTime::now();
+ auto delta = hostTime ? *hostTime - now : Seconds::nan();
+ ALWAYS_LOG(LOGIDENTIFIER, m_state, " time: ", atTime ? *atTime : -1, " hostTime: ", (hostTime ? *hostTime : MonotonicTime::nan()).secondsSinceEpoch().value(), " delta: ", delta.value());
if (m_state != MediaSessionCoordinatorState::Joined) {
completionHandler(false);
@@ -375,8 +376,20 @@
if (atTime && !currentPositionApproximatelyEqualTo(*atTime))
m_session->callActionHandler({ .action = "" .seekTime = *atTime });
- m_session->callActionHandler({ .action = "" });
- completionHandler(true);
+ if (!std::isfinite(delta) || delta <= 0_s) {
+ m_session->callActionHandler({ .action = "" });
+ completionHandler(true);
+ return;
+ }
+
+ RunLoop::main().dispatchAfter(delta, [weakThis = makeWeakPtr(this), completionHandler = WTFMove(completionHandler)] () mutable {
+ if (!weakThis || !weakThis->m_session) {
+ completionHandler(false);
+ return;
+ }
+ weakThis->m_session->callActionHandler({ .action = "" });
+ completionHandler(true);
+ });
}
void MediaSessionCoordinator::pauseSession(CompletionHandler<void(bool)>&& completionHandler)
Modified: trunk/Source/WebCore/Modules/mediasession/MediaSessionCoordinator.h (279185 => 279186)
--- trunk/Source/WebCore/Modules/mediasession/MediaSessionCoordinator.h 2021-06-23 20:44:00 UTC (rev 279185)
+++ trunk/Source/WebCore/Modules/mediasession/MediaSessionCoordinator.h 2021-06-23 21:21:48 UTC (rev 279186)
@@ -92,7 +92,7 @@
// MediaSessionCoordinatorClient
void seekSessionToTime(double, CompletionHandler<void(bool)>&&) final;
- void playSession(std::optional<double> atTime, std::optional<double> hostTime, CompletionHandler<void(bool)>&&) final;
+ void playSession(std::optional<double> atTime, std::optional<MonotonicTime> hostTime, CompletionHandler<void(bool)>&&) final;
void pauseSession(CompletionHandler<void(bool)>&&) final;
void setSessionTrack(const String&, CompletionHandler<void(bool)>&&) final;
void coordinatorStateChanged(WebCore::MediaSessionCoordinatorState) final;
Modified: trunk/Source/WebCore/Modules/mediasession/MediaSessionCoordinatorPrivate.h (279185 => 279186)
--- trunk/Source/WebCore/Modules/mediasession/MediaSessionCoordinatorPrivate.h 2021-06-23 20:44:00 UTC (rev 279185)
+++ trunk/Source/WebCore/Modules/mediasession/MediaSessionCoordinatorPrivate.h 2021-06-23 21:21:48 UTC (rev 279186)
@@ -32,6 +32,8 @@
#include "MediaSessionCoordinatorState.h"
#include "MediaSessionPlaybackState.h"
#include "MediaSessionReadyState.h"
+#include <wtf/MonotonicTime.h>
+#include <wtf/Optional.h>
#include <wtf/WeakPtr.h>
namespace WTF {
@@ -45,7 +47,7 @@
virtual ~MediaSessionCoordinatorClient() = default;
virtual void seekSessionToTime(double, CompletionHandler<void(bool)>&&) = 0;
- virtual void playSession(std::optional<double> atTime, std::optional<double> hostTime, CompletionHandler<void(bool)>&&) = 0;
+ virtual void playSession(std::optional<double> atTime, std::optional<MonotonicTime> hostTime, CompletionHandler<void(bool)>&&) = 0;
virtual void pauseSession(CompletionHandler<void(bool)>&&) = 0;
virtual void setSessionTrack(const String&, CompletionHandler<void(bool)>&&) = 0;
virtual void coordinatorStateChanged(WebCore::MediaSessionCoordinatorState) = 0;
Modified: trunk/Source/WebCore/PAL/ChangeLog (279185 => 279186)
--- trunk/Source/WebCore/PAL/ChangeLog 2021-06-23 20:44:00 UTC (rev 279185)
+++ trunk/Source/WebCore/PAL/ChangeLog 2021-06-23 21:21:48 UTC (rev 279186)
@@ -1,3 +1,15 @@
+2021-06-23 Jer Noble <[email protected]>
+
+ [Cocoa] Make the hostTime parameter to playSession a Monotonic time
+ https://bugs.webkit.org/show_bug.cgi?id=226515
+
+ Reviewed by Youenn Fablet.
+
+ SoftLink CMClockConvertHostTimeToSystemUnits.
+
+ * pal/cf/CoreMediaSoftLink.cpp:
+ * pal/cf/CoreMediaSoftLink.h:
+
2021-06-22 Jer Noble <[email protected]>
[Cocoa] iOS device steals BT headphones from other devices during silent playback
Modified: trunk/Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.cpp (279185 => 279186)
--- trunk/Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.cpp 2021-06-23 20:44:00 UTC (rev 279185)
+++ trunk/Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.cpp 2021-06-23 21:21:48 UTC (rev 279186)
@@ -183,6 +183,8 @@
SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMAudioFormatDescriptionGetRichestDecodableFormat, const AudioFormatListItem *, (CMAudioFormatDescriptionRef desc), (desc), PAL_EXPORT)
SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMClockGetHostTimeClock, CMClockRef, (void), (), PAL_EXPORT)
SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMClockGetTime, CMTime, (CMClockRef clock), (clock), PAL_EXPORT)
+SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMClockConvertHostTimeToSystemUnits, uint64_t, (CMTime hostTime), (hostTime), PAL_EXPORT)
+
SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMSampleBufferCallForEachSample, OSStatus, (CMSampleBufferRef sbuf, OSStatus (* CMSAMPLEBUFFERCALL_NOESCAPE callback)( CMSampleBufferRef sampleBuffer, CMItemCount index, void *refcon), void *refcon), (sbuf, callback, refcon), PAL_EXPORT)
SOFT_LINK_FUNCTION_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, CMSampleBufferCallBlockForEachSample, OSStatus, (CMSampleBufferRef sbuf, OSStatus (^ CMSAMPLEBUFFERCALL_NOESCAPE handler)(CMSampleBufferRef, CMItemCount)), (sbuf, handler), PAL_EXPORT)
SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE_WITH_EXPORT(PAL, CoreMedia, kCMFormatDescriptionExtension_ProtectedContentOriginalFormat, CFStringRef, PAL_EXPORT)
Modified: trunk/Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.h (279185 => 279186)
--- trunk/Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.h 2021-06-23 20:44:00 UTC (rev 279185)
+++ trunk/Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.h 2021-06-23 21:21:48 UTC (rev 279186)
@@ -322,6 +322,8 @@
#define CMClockGetHostTimeClock softLink_CoreMedia_CMClockGetHostTimeClock
SOFT_LINK_FUNCTION_FOR_HEADER(PAL, CoreMedia, CMClockGetTime, CMTime, (CMClockRef clock), (clock))
#define CMClockGetTime softLink_CoreMedia_CMClockGetTime
+SOFT_LINK_FUNCTION_FOR_HEADER(PAL, CoreMedia, CMClockConvertHostTimeToSystemUnits, uint64_t, (CMTime hostTime), (hostTime))
+#define CMClockConvertHostTimeToSystemUnits softLink_CoreMedia_CMClockConvertHostTimeToSystemUnits
SOFT_LINK_FUNCTION_FOR_HEADER(PAL, CoreMedia, CMSampleBufferCallForEachSample, OSStatus, (CMSampleBufferRef sbuf, OSStatus (* CMSAMPLEBUFFERCALL_NOESCAPE callback)(CMSampleBufferRef sampleBuffer, CMItemCount index, void *refcon), void *refcon), (sbuf, callback, refcon))
#define CMSampleBufferCallForEachSample softLink_CoreMedia_CMSampleBufferCallForEachSample
Modified: trunk/Source/WebKit/ChangeLog (279185 => 279186)
--- trunk/Source/WebKit/ChangeLog 2021-06-23 20:44:00 UTC (rev 279185)
+++ trunk/Source/WebKit/ChangeLog 2021-06-23 21:21:48 UTC (rev 279186)
@@ -1,3 +1,21 @@
+2021-06-23 Jer Noble <[email protected]>
+
+ [Cocoa] Make the hostTime parameter to playSession a Monotonic time
+ https://bugs.webkit.org/show_bug.cgi?id=226515
+
+ Reviewed by Youenn Fablet.
+
+ * UIProcess/API/Cocoa/WKWebViewTesting.mm:
+ (-[WKWebView _createMediaSessionCoordinatorForTesting:completionHandler:]):
+ (-[WKMediaSessionCoordinatorHelper playSessionWithCompletion:]):
+ * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp:
+ (WebKit::RemoteMediaSessionCoordinatorProxy::playSession):
+ * UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h:
+ * WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp:
+ (WebKit::RemoteMediaSessionCoordinator::playSession):
+ * WebProcess/MediaSession/RemoteMediaSessionCoordinator.h:
+ * WebProcess/MediaSession/RemoteMediaSessionCoordinator.messages.in:
+
2021-06-23 Kate Cheney <[email protected]>
Migrate App Privacy Report code from WebKitAdditions
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm (279185 => 279186)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm 2021-06-23 20:44:00 UTC (rev 279185)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewTesting.mm 2021-06-23 21:21:48 UTC (rev 279186)
@@ -421,7 +421,7 @@
callback(false);
}
- void playSession(std::optional<double> atTime, std::optional<double> hostTime, CompletionHandler<void(bool)>&& callback) final
+ void playSession(std::optional<double> atTime, std::optional<MonotonicTime> hostTime, CompletionHandler<void(bool)>&& callback) final
{
if (auto coordinatorClient = client())
coordinatorClient->playSession(WTFMove(atTime), WTFMove(hostTime), WTFMove(callback));
@@ -610,7 +610,7 @@
- (void)playSessionWithCompletion:(void(^)(BOOL))completionHandler
{
- m_coordinatorClient->playSession({ }, { }, makeBlockPtr(completionHandler));
+ m_coordinatorClient->playSession({ }, std::optional<MonotonicTime>(), makeBlockPtr(completionHandler));
}
- (void)pauseSessionWithCompletion:(void(^)(BOOL))completionHandler
Modified: trunk/Source/WebKit/UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp (279185 => 279186)
--- trunk/Source/WebKit/UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp 2021-06-23 20:44:00 UTC (rev 279185)
+++ trunk/Source/WebKit/UIProcess/Media/RemoteMediaSessionCoordinatorProxy.cpp 2021-06-23 21:21:48 UTC (rev 279186)
@@ -159,7 +159,7 @@
m_webPageProxy.sendWithAsyncReply(Messages::RemoteMediaSessionCoordinator::SeekSessionToTime { time }, callback);
}
-void RemoteMediaSessionCoordinatorProxy::playSession(std::optional<double> atTime, std::optional<double> hostTime, CompletionHandler<void(bool)>&& callback)
+void RemoteMediaSessionCoordinatorProxy::playSession(std::optional<double> atTime, std::optional<MonotonicTime> hostTime, CompletionHandler<void(bool)>&& callback)
{
m_webPageProxy.sendWithAsyncReply(Messages::RemoteMediaSessionCoordinator::PlaySession { WTFMove(atTime), WTFMove(hostTime) }, callback);
}
Modified: trunk/Source/WebKit/UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h (279185 => 279186)
--- trunk/Source/WebKit/UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h 2021-06-23 20:44:00 UTC (rev 279185)
+++ trunk/Source/WebKit/UIProcess/Media/RemoteMediaSessionCoordinatorProxy.h 2021-06-23 21:21:48 UTC (rev 279186)
@@ -77,7 +77,7 @@
// MediaSessionCoordinatorClient
void seekSessionToTime(double, CompletionHandler<void(bool)>&&) final;
- void playSession(std::optional<double> atTime, std::optional<double> hostTime, CompletionHandler<void(bool)>&&) final;
+ void playSession(std::optional<double> atTime, std::optional<MonotonicTime> hostTime, CompletionHandler<void(bool)>&&) final;
void pauseSession(CompletionHandler<void(bool)>&&) final;
void setSessionTrack(const String&, CompletionHandler<void(bool)>&&) final;
void coordinatorStateChanged(WebCore::MediaSessionCoordinatorState) final;
Modified: trunk/Source/WebKit/WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp (279185 => 279186)
--- trunk/Source/WebKit/WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp 2021-06-23 20:44:00 UTC (rev 279185)
+++ trunk/Source/WebKit/WebProcess/MediaSession/RemoteMediaSessionCoordinator.cpp 2021-06-23 21:21:48 UTC (rev 279186)
@@ -190,7 +190,7 @@
completionHandler(false);
}
-void RemoteMediaSessionCoordinator::playSession(std::optional<double> atTime, std::optional<double> hostTime, CompletionHandler<void(bool)>&& completionHandler)
+void RemoteMediaSessionCoordinator::playSession(std::optional<double> atTime, std::optional<MonotonicTime> hostTime, CompletionHandler<void(bool)>&& completionHandler)
{
ALWAYS_LOG_IF_POSSIBLE(LOGIDENTIFIER);
if (auto coordinatorClient = client())
Modified: trunk/Source/WebKit/WebProcess/MediaSession/RemoteMediaSessionCoordinator.h (279185 => 279186)
--- trunk/Source/WebKit/WebProcess/MediaSession/RemoteMediaSessionCoordinator.h 2021-06-23 20:44:00 UTC (rev 279185)
+++ trunk/Source/WebKit/WebProcess/MediaSession/RemoteMediaSessionCoordinator.h 2021-06-23 21:21:48 UTC (rev 279186)
@@ -55,7 +55,7 @@
// MessageReceivers.
void seekSessionToTime(double, CompletionHandler<void(bool)>&&);
- void playSession(std::optional<double>, std::optional<double>, CompletionHandler<void(bool)>&&);
+ void playSession(std::optional<double>, std::optional<MonotonicTime>, CompletionHandler<void(bool)>&&);
void pauseSession(CompletionHandler<void(bool)>&&);
void setSessionTrack(const String&, CompletionHandler<void(bool)>&&);
void coordinatorStateChanged(WebCore::MediaSessionCoordinatorState);
Modified: trunk/Source/WebKit/WebProcess/MediaSession/RemoteMediaSessionCoordinator.messages.in (279185 => 279186)
--- trunk/Source/WebKit/WebProcess/MediaSession/RemoteMediaSessionCoordinator.messages.in 2021-06-23 20:44:00 UTC (rev 279185)
+++ trunk/Source/WebKit/WebProcess/MediaSession/RemoteMediaSessionCoordinator.messages.in 2021-06-23 21:21:48 UTC (rev 279186)
@@ -29,7 +29,7 @@
SeekSessionToTime(double time) -> (bool result) Async
- PlaySession(std::optional<double> atTime, std::optional<double> hostTime) -> (bool result) Async
+ PlaySession(std::optional<double> atTime, std::optional<MonotonicTime> hostTime) -> (bool result) Async
PauseSession() -> (bool result) Async