Diff
Modified: branches/safari-609-branch/Source/WebCore/ChangeLog (257036 => 257037)
--- branches/safari-609-branch/Source/WebCore/ChangeLog 2020-02-20 03:36:53 UTC (rev 257036)
+++ branches/safari-609-branch/Source/WebCore/ChangeLog 2020-02-20 03:48:09 UTC (rev 257037)
@@ -1,5 +1,83 @@
2020-02-19 Russell Epstein <repst...@apple.com>
+ Apply patch. rdar://problem/59611915
+
+ 2020-02-19 Eric Carlson <eric.carl...@apple.com>
+
+ Captions sometimes render at the wrong size when in fullscreen and PiP
+ https://bugs.webkit.org/show_bug.cgi?id=207389
+ <rdar://problem/58677864>
+
+ The TextTrackRepresentation, used to render captions when in fullscreen and PiP on
+ iOS and and in PiP on macOS, frequently rendered captions before layout completed
+ immediately after it was created. Fix this by having it not render until a layout
+ happens. Additionally, make the code more efficient by hiding the TextTrackRepresentation's
+ backing layer when cues are not visible instead of destroying the whole object.
+ Drive by: RELEASE_LOG_DISABLED is always defined for PLATFORM(COCOA), so remove it
+ from the macOS/iOS media players to make it easier to add logging to VideoFullscreenLayerManagerObjC.
+
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::convertEnumerationToString):
+ (WebCore::HTMLMediaElement::configureTextTrackDisplay):
+ * html/HTMLMediaElementEnums.h:
+ (WTF::LogArgument<WebCore::HTMLMediaElementEnums::TextTrackVisibilityCheckType>::toString):
+ * html/shadow/MediaControlElements.cpp:
+ (WebCore::MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement):
+ (WebCore::MediaControlTextTrackContainerElement::updateDisplay):
+ (WebCore::MediaControlTextTrackContainerElement::updateTextTrackRepresentation):
+ (WebCore::MediaControlTextTrackContainerElement::clearTextTrackRepresentation):
+ (WebCore::MediaControlTextTrackContainerElement::updateTextTrackRepresentationStyle):
+ (WebCore::MediaControlTextTrackContainerElement::layoutIfNecessary):
+ (WebCore::MediaControlTextTrackContainerElement::updateVideoDisplaySize):
+ (WebCore::MediaControlTextTrackContainerElement::updateSizes):
+ (WebCore::MediaControlTextTrackContainerElement::updateCueStyles):
+ (WebCore::MediaControlTextTrackContainerElement::logger const):
+ (WebCore::MediaControlTextTrackContainerElement::logIdentifier const):
+ (WebCore::MediaControlTextTrackContainerElement::updateTimerFired): Deleted.
+ (WebCore::MediaControlTextTrackContainerElement::updateStyleForTextTrackRepresentation): Deleted.
+ * platform/graphics/TextTrackRepresentation.h:
+ * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
+ (WebCore::MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation):
+ (WebCore::MediaPlayerPrivateAVFoundation::logChannel const):
+ * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenFrame):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::createImageForTimeInRect):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::updateAudioTracks):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::updateVideoTracks):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::updateLastImage):
+ (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]):
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::mediaPlayerLogger):
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::logChannel const):
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+ (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::MediaPlayerPrivateMediaStreamAVFObjC):
+ (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::logChannel const):
+ * platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.h:
+ * platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.mm:
+ (WebCore::VideoFullscreenLayerManagerObjC::VideoFullscreenLayerManagerObjC):
+ (WebCore::VideoFullscreenLayerManagerObjC::setVideoLayer):
+ (WebCore::VideoFullscreenLayerManagerObjC::setVideoFullscreenLayer):
+ (WebCore::VideoFullscreenLayerManagerObjC::setVideoFullscreenFrame):
+ (WebCore::VideoFullscreenLayerManagerObjC::didDestroyVideoLayer):
+ (WebCore::VideoFullscreenLayerManagerObjC::syncTextTrackBounds):
+ (WebCore::VideoFullscreenLayerManagerObjC::setTextTrackRepresentation):
+ (WebCore::VideoFullscreenLayerManagerObjC::logChannel const):
+ * platform/graphics/cocoa/TextTrackRepresentationCocoa.h:
+ * platform/graphics/cocoa/TextTrackRepresentationCocoa.mm:
+ (-[WebCoreTextTrackRepresentationCocoaHelper observeValueForKeyPath:ofObject:change:context:]):
+ (TextTrackRepresentationCocoa::setHidden const):
+ (TextTrackRepresentationCocoa::boundsChanged):
+ * rendering/RenderMediaControlElements.cpp:
+ (WebCore::RenderTextTrackContainerElement::layout):
+
+2020-02-19 Russell Epstein <repst...@apple.com>
+
Cherry-pick r256859. rdar://problem/59576018
[macOS] Web process may crash under ServicesOverlayController::buildPotentialHighlightsIfNeeded
Modified: branches/safari-609-branch/Source/WebCore/html/HTMLMediaElement.cpp (257036 => 257037)
--- branches/safari-609-branch/Source/WebCore/html/HTMLMediaElement.cpp 2020-02-20 03:36:53 UTC (rev 257036)
+++ branches/safari-609-branch/Source/WebCore/html/HTMLMediaElement.cpp 2020-02-20 03:48:09 UTC (rev 257037)
@@ -274,6 +274,18 @@
return values[static_cast<size_t>(enumerationValue)];
}
+String convertEnumerationToString(HTMLMediaElement::TextTrackVisibilityCheckType enumerationValue)
+{
+ static const NeverDestroyed<String> values[] = {
+ MAKE_STATIC_STRING_IMPL("CheckTextTrackVisibility"),
+ MAKE_STATIC_STRING_IMPL("AssumeTextTrackVisibilityChanged"),
+ };
+ static_assert(static_cast<size_t>(HTMLMediaElement::TextTrackVisibilityCheckType::CheckTextTrackVisibility) == 0, "TextTrackVisibilityCheckType::CheckTextTrackVisibility is not 0 as expected");
+ static_assert(static_cast<size_t>(HTMLMediaElement::TextTrackVisibilityCheckType::AssumeTextTrackVisibilityChanged) == 1, "TextTrackVisibilityCheckType::AssumeTextTrackVisibilityChanged is not 1 as expected");
+ ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
+ return values[static_cast<size_t>(enumerationValue)];
+}
+
#if ENABLE(VIDEO_TRACK)
class TrackDisplayUpdateScope {
@@ -6535,7 +6547,7 @@
#if ENABLE(VIDEO_TRACK)
void HTMLMediaElement::configureTextTrackDisplay(TextTrackVisibilityCheckType checkType)
{
- ALWAYS_LOG(LOGIDENTIFIER);
+ ALWAYS_LOG(LOGIDENTIFIER, checkType);
ASSERT(m_textTracks);
if (m_processingPreferenceChange)
Modified: branches/safari-609-branch/Source/WebCore/html/HTMLMediaElementEnums.h (257036 => 257037)
--- branches/safari-609-branch/Source/WebCore/html/HTMLMediaElementEnums.h 2020-02-20 03:36:53 UTC (rev 257036)
+++ branches/safari-609-branch/Source/WebCore/html/HTMLMediaElementEnums.h 2020-02-20 03:48:09 UTC (rev 257037)
@@ -47,6 +47,7 @@
String convertEnumerationToString(HTMLMediaElementEnums::ReadyState);
String convertEnumerationToString(HTMLMediaElementEnums::NetworkState);
+String convertEnumerationToString(HTMLMediaElementEnums::TextTrackVisibilityCheckType);
} // namespace WebCore
@@ -71,5 +72,13 @@
}
};
+template <>
+struct LogArgument<WebCore::HTMLMediaElementEnums::TextTrackVisibilityCheckType> {
+ static String toString(const WebCore::HTMLMediaElementEnums::TextTrackVisibilityCheckType type)
+ {
+ return convertEnumerationToString(type);
+ }
+};
+
}; // namespace WTF
Modified: branches/safari-609-branch/Source/WebCore/html/shadow/MediaControlElements.cpp (257036 => 257037)
--- branches/safari-609-branch/Source/WebCore/html/shadow/MediaControlElements.cpp 2020-02-20 03:36:53 UTC (rev 257036)
+++ branches/safari-609-branch/Source/WebCore/html/shadow/MediaControlElements.cpp 2020-02-20 03:48:09 UTC (rev 257037)
@@ -1092,10 +1092,6 @@
MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement(Document& document)
: MediaControlDivElement(document, MediaTextTrackDisplayContainer)
- , m_updateTimer(*this, &MediaControlTextTrackContainerElement::updateTimerFired)
- , m_fontSize(0)
- , m_fontSizeIsImportant(false)
- , m_updateTextTrackRepresentationStyle(false)
{
setPseudo(AtomString("-webkit-media-text-track-container", AtomString::ConstructFromLiteral));
}
@@ -1204,13 +1200,13 @@
}
// 11. Return output.
- if (hasChildNodes()) {
+ if (hasChildNodes())
show();
+ else
+ hide();
+
+ if (m_textTrackRepresentation || video.requiresTextTrackRepresentation())
updateTextTrackRepresentation();
- } else {
- hide();
- clearTextTrackRepresentation();
- }
}
void MediaControlTextTrackContainerElement::processActiveVTTCue(VTTCue& cue)
@@ -1292,26 +1288,6 @@
setInlineStyleProperty(CSSPropertyStrokeWidth, strokeWidth, CSSUnitType::CSS_PX, important);
}
-void MediaControlTextTrackContainerElement::updateTimerFired()
-{
- if (!document().page())
- return;
-
- auto mediaElement = parentMediaElement(this);
- if (!mediaElement)
- return;
-
- for (auto& activeCue : mediaElement->currentlyActiveCues())
- activeCue.data()->recalculateStyles();
-
- if (m_textTrackRepresentation)
- updateStyleForTextTrackRepresentation();
-
- updateActiveCuesFontSize();
- updateDisplay();
- updateTextStrokeStyle();
-}
-
void MediaControlTextTrackContainerElement::updateTextTrackRepresentation()
{
auto mediaElement = parentMediaElement(this);
@@ -1318,24 +1294,33 @@
if (!mediaElement)
return;
- if (!mediaElement->requiresTextTrackRepresentation()) {
+ auto requiresTextTrackRepresentation = mediaElement->requiresTextTrackRepresentation();
+ if (!hasChildNodes() || !requiresTextTrackRepresentation) {
if (m_textTrackRepresentation) {
- clearTextTrackRepresentation();
- updateSizes(ForceUpdate::Yes);
+ if (!requiresTextTrackRepresentation) {
+ clearTextTrackRepresentation();
+ updateSizes(ForceUpdate::Yes);
+ } else
+ m_textTrackRepresentation->setHidden(true);
}
return;
}
if (!m_textTrackRepresentation) {
+ ALWAYS_LOG(LOGIDENTIFIER);
+
+ m_waitingForFirstLayout = true;
m_textTrackRepresentation = TextTrackRepresentation::create(*this);
if (document().page())
m_textTrackRepresentation->setContentScale(document().page()->deviceScaleFactor());
- m_updateTextTrackRepresentationStyle = true;
mediaElement->setTextTrackRepresentation(m_textTrackRepresentation.get());
+ updateSizes();
+ updateTextTrackRepresentationStyle();
}
- m_textTrackRepresentation->update();
- updateStyleForTextTrackRepresentation();
+ m_textTrackRepresentation->setHidden(false);
+ if (!m_waitingForFirstLayout)
+ m_textTrackRepresentation->update();
}
void MediaControlTextTrackContainerElement::clearTextTrackRepresentation()
@@ -1343,21 +1328,18 @@
if (!m_textTrackRepresentation)
return;
+ ALWAYS_LOG(LOGIDENTIFIER);
+
+ m_waitingForFirstLayout = true;
m_textTrackRepresentation = nullptr;
- m_updateTextTrackRepresentationStyle = true;
if (auto mediaElement = parentMediaElement(this))
mediaElement->setTextTrackRepresentation(nullptr);
- updateStyleForTextTrackRepresentation();
+ updateTextTrackRepresentationStyle();
updateActiveCuesFontSize();
}
-void MediaControlTextTrackContainerElement::updateStyleForTextTrackRepresentation()
+void MediaControlTextTrackContainerElement::updateTextTrackRepresentationStyle()
{
- if (!m_updateTextTrackRepresentationStyle)
- return;
-
- m_updateTextTrackRepresentationStyle = false;
-
if (m_textTrackRepresentation) {
setInlineStyleProperty(CSSPropertyWidth, m_videoDisplaySize.size().width(), CSSUnitType::CSS_PX);
setInlineStyleProperty(CSSPropertyHeight, m_videoDisplaySize.size().height(), CSSUnitType::CSS_PX);
@@ -1387,15 +1369,32 @@
updateSizes(ForceUpdate::Yes);
}
-void MediaControlTextTrackContainerElement::updateSizes(ForceUpdate force)
+void MediaControlTextTrackContainerElement::layoutIfNecessary()
{
- auto mediaElement = parentMediaElement(this);
- if (!mediaElement)
+ m_waitingForFirstLayout = false;
+
+ auto sizeChanged = updateVideoDisplaySize();
+ if (m_textTrackRepresentation)
+ m_textTrackRepresentation->update();
+
+ if (!sizeChanged)
return;
+ // FIXME (121170): This function is called during layout, and should lay out the text tracks immediately.
+ m_taskQueue.enqueueTask([this] () {
+ updateCueStyles();
+ });
+}
+
+bool MediaControlTextTrackContainerElement::updateVideoDisplaySize()
+{
if (!document().page())
- return;
+ return false;
+ auto mediaElement = parentMediaElement(this);
+ if (!mediaElement)
+ return false;
+
IntRect videoBox;
if (m_textTrackRepresentation) {
videoBox = m_textTrackRepresentation->bounds();
@@ -1404,19 +1403,42 @@
videoBox.setHeight(videoBox.height() * deviceScaleFactor);
} else {
if (!is<RenderVideo>(mediaElement->renderer()))
- return;
+ return false;
videoBox = downcast<RenderVideo>(*mediaElement->renderer()).videoBox();
}
- if (force == ForceUpdate::No && m_videoDisplaySize == videoBox)
+ if (m_videoDisplaySize == videoBox)
+ return false;
+
+ m_videoDisplaySize = videoBox;
+ updateTextTrackRepresentationStyle();
+
+ return true;
+}
+
+void MediaControlTextTrackContainerElement::updateSizes(ForceUpdate force)
+{
+ if (updateVideoDisplaySize() || force == ForceUpdate::Yes)
+ updateCueStyles();
+}
+
+void MediaControlTextTrackContainerElement::updateCueStyles()
+{
+ if (!document().page())
return;
- m_videoDisplaySize = videoBox;
- m_updateTextTrackRepresentationStyle = true;
+ auto mediaElement = parentMediaElement(this);
+ if (!mediaElement)
+ return;
+
mediaElement->syncTextTrackBounds();
- // FIXME (121170): This function is called during layout, and should lay out the text tracks immediately.
- m_updateTimer.startOneShot(0_s);
+ for (auto& activeCue : mediaElement->currentlyActiveCues())
+ activeCue.data()->recalculateStyles();
+
+ updateActiveCuesFontSize();
+ updateDisplay();
+ updateTextStrokeStyle();
}
RefPtr<Image> MediaControlTextTrackContainerElement::createTextTrackRepresentationImage()
@@ -1465,14 +1487,20 @@
#if !RELEASE_LOG_DISABLED
const Logger& MediaControlTextTrackContainerElement::logger() const
{
- return document().logger();
+ if (!m_logger)
+ m_logger = &document().logger();
+
+ return *m_logger;
}
const void* MediaControlTextTrackContainerElement::logIdentifier() const
{
- if (auto mediaElement = parentMediaElement(this))
- return mediaElement->logIdentifier();
- return nullptr;
+ if (!m_logIdentifier) {
+ if (auto mediaElement = parentMediaElement(this))
+ m_logIdentifier = mediaElement->logIdentifier();
+ }
+
+ return m_logIdentifier;
}
WTFLogChannel& MediaControlTextTrackContainerElement::logChannel() const
Modified: branches/safari-609-branch/Source/WebCore/html/shadow/MediaControlElements.h (257036 => 257037)
--- branches/safari-609-branch/Source/WebCore/html/shadow/MediaControlElements.h 2020-02-20 03:36:53 UTC (rev 257036)
+++ branches/safari-609-branch/Source/WebCore/html/shadow/MediaControlElements.h 2020-02-20 03:48:09 UTC (rev 257037)
@@ -31,6 +31,7 @@
#if ENABLE(VIDEO)
+#include "GenericTaskQueue.h"
#include "MediaControlElementTypes.h"
#include "TextTrackRepresentation.h"
#include <wtf/LoggerHelper.h>
@@ -482,6 +483,7 @@
enum class ForceUpdate { Yes, No };
void updateSizes(ForceUpdate force = ForceUpdate::No);
+ void layoutIfNecessary();
void updateDisplay();
void enteredFullscreen();
@@ -488,34 +490,37 @@
void exitedFullscreen();
private:
- void updateTimerFired();
+ explicit MediaControlTextTrackContainerElement(Document&);
+
+ bool updateVideoDisplaySize();
+ void updateCueStyles();
void updateActiveCuesFontSize();
void updateTextStrokeStyle();
void processActiveVTTCue(VTTCue&);
+ RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override;
+ RefPtr<Image> createTextTrackRepresentationImage() override;
+ void textTrackRepresentationBoundsChanged(const IntRect&) override;
+ void updateTextTrackRepresentation();
+ void clearTextTrackRepresentation();
+ void updateTextTrackRepresentationStyle();
+
#if !RELEASE_LOG_DISABLED
const Logger& logger() const final;
const void* logIdentifier() const final;
WTFLogChannel& logChannel() const final;
const char* logClassName() const final { return "MediaControlTextTrackContainerElement"; }
+ mutable RefPtr<Logger> m_logger;
+ mutable const void* m_logIdentifier { nullptr };
#endif
- explicit MediaControlTextTrackContainerElement(Document&);
-
- RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override;
-
- RefPtr<Image> createTextTrackRepresentationImage() override;
- void textTrackRepresentationBoundsChanged(const IntRect&) override;
- void updateTextTrackRepresentation();
- void clearTextTrackRepresentation();
- void updateStyleForTextTrackRepresentation();
std::unique_ptr<TextTrackRepresentation> m_textTrackRepresentation;
- Timer m_updateTimer;
+ GenericTaskQueue<Timer> m_taskQueue;
IntRect m_videoDisplaySize;
- int m_fontSize;
- bool m_fontSizeIsImportant;
- bool m_updateTextTrackRepresentationStyle;
+ int m_fontSize { 0 };
+ bool m_fontSizeIsImportant { false };
+ bool m_waitingForFirstLayout { true };
};
#endif
Modified: branches/safari-609-branch/Source/WebCore/platform/graphics/TextTrackRepresentation.cpp (257036 => 257037)
--- branches/safari-609-branch/Source/WebCore/platform/graphics/TextTrackRepresentation.cpp 2020-02-20 03:36:53 UTC (rev 257036)
+++ branches/safari-609-branch/Source/WebCore/platform/graphics/TextTrackRepresentation.cpp 2020-02-20 03:48:09 UTC (rev 257037)
@@ -36,10 +36,11 @@
class NullTextTrackRepresentation : public TextTrackRepresentation {
public:
virtual ~NullTextTrackRepresentation() = default;
- void update() override { }
- PlatformLayer* platformLayer() override { return nullptr; }
- void setContentScale(float) override { }
- IntRect bounds() const override { return IntRect(); }
+ void update() final { }
+ PlatformLayer* platformLayer() final { return nullptr; }
+ void setContentScale(float) final { }
+ IntRect bounds() const final { return IntRect(); }
+ void setHidden(bool) const final { }
};
#if !(PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)))
Modified: branches/safari-609-branch/Source/WebCore/platform/graphics/TextTrackRepresentation.h (257036 => 257037)
--- branches/safari-609-branch/Source/WebCore/platform/graphics/TextTrackRepresentation.h 2020-02-20 03:36:53 UTC (rev 257036)
+++ branches/safari-609-branch/Source/WebCore/platform/graphics/TextTrackRepresentation.h 2020-02-20 03:48:09 UTC (rev 257037)
@@ -55,6 +55,7 @@
virtual PlatformLayer* platformLayer() = 0;
virtual void setContentScale(float) = 0;
virtual IntRect bounds() const = 0;
+ virtual void setHidden(bool) const = 0;
};
}
Modified: branches/safari-609-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (257036 => 257037)
--- branches/safari-609-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2020-02-20 03:36:53 UTC (rev 257036)
+++ branches/safari-609-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2020-02-20 03:48:09 UTC (rev 257037)
@@ -408,7 +408,7 @@
MediaPlayerPrivateAVFoundationObjC::MediaPlayerPrivateAVFoundationObjC(MediaPlayer* player)
: MediaPlayerPrivateAVFoundation(player)
- , m_videoFullscreenLayerManager(makeUnique<VideoFullscreenLayerManagerObjC>())
+ , m_videoFullscreenLayerManager(makeUnique<VideoFullscreenLayerManagerObjC>(logger(), logIdentifier()))
, m_videoFullscreenGravity(MediaPlayer::VideoGravity::ResizeAspect)
, m_objcObserver(adoptNS([[WebCoreAVFMovieObserver alloc] initWithPlayer:makeWeakPtr(*this)]))
, m_videoFrameHasDrawn(false)
@@ -1119,6 +1119,7 @@
void MediaPlayerPrivateAVFoundationObjC::setVideoFullscreenFrame(FloatRect frame)
{
+ ALWAYS_LOG(LOGIDENTIFIER, "width = ", frame.size().width(), ", height = ", frame.size().height());
m_videoFullscreenLayerManager->setVideoFullscreenFrame(frame);
}
@@ -1588,17 +1589,13 @@
createImageGenerator();
ASSERT(m_imageGenerator);
-#if !RELEASE_LOG_DISABLED
MonotonicTime start = MonotonicTime::now();
-#endif
[m_imageGenerator.get() setMaximumSize:CGSize(rect.size())];
RetainPtr<CGImageRef> rawImage = adoptCF([m_imageGenerator.get() copyCGImageAtTime:CMTimeMakeWithSeconds(time, 600) actualTime:nil error:nil]);
RetainPtr<CGImageRef> image = adoptCF(CGImageCreateCopyWithColorSpace(rawImage.get(), sRGBColorSpaceRef()));
-#if !RELEASE_LOG_DISABLED
INFO_LOG(LOGIDENTIFIER, "creating image took ", (MonotonicTime::now() - start).seconds());
-#endif
return image;
}
@@ -2045,9 +2042,7 @@
void MediaPlayerPrivateAVFoundationObjC::updateAudioTracks()
{
-#if !RELEASE_LOG_DISABLED
size_t count = m_audioTracks.size();
-#endif
Vector<String> characteristics = player()->preferredAudioCharacteristics();
if (!m_audibleGroup) {
@@ -2063,16 +2058,12 @@
for (auto& track : m_audioTracks)
track->resetPropertiesFromTrack();
-#if !RELEASE_LOG_DISABLED
- INFO_LOG(LOGIDENTIFIER, "track count was ", count, ", is ", m_audioTracks.size());
-#endif
+ ALWAYS_LOG(LOGIDENTIFIER, "track count was ", count, ", is ", m_audioTracks.size());
}
void MediaPlayerPrivateAVFoundationObjC::updateVideoTracks()
{
-#if !RELEASE_LOG_DISABLED
size_t count = m_videoTracks.size();
-#endif
determineChangedTracksFromNewTracksAndOldItems(m_cachedTracks.get(), AVMediaTypeVideo, m_videoTracks, &VideoTrackPrivateAVFObjC::create, player(), &MediaPlayer::removeVideoTrack, &MediaPlayer::addVideoTrack);
@@ -2087,9 +2078,7 @@
for (auto& track : m_audioTracks)
track->resetPropertiesFromTrack();
-#if !RELEASE_LOG_DISABLED
- INFO_LOG(LOGIDENTIFIER, "track count was ", count, ", is ", m_videoTracks.size());
-#endif
+ ALWAYS_LOG(LOGIDENTIFIER, "track count was ", count, ", is ", m_videoTracks.size());
}
bool MediaPlayerPrivateAVFoundationObjC::requiresTextTrackRepresentation() const
@@ -2261,15 +2250,11 @@
m_pixelBufferConformer = makeUnique<PixelBufferConformerCV>((__bridge CFDictionaryRef)attributes);
}
-#if !RELEASE_LOG_DISABLED
MonotonicTime start = MonotonicTime::now();
-#endif
m_lastImage = m_pixelBufferConformer->createImageFromPixelBuffer(m_lastPixelBuffer.get());
-#if !RELEASE_LOG_DISABLED
INFO_LOG(LOGIDENTIFIER, "creating buffer took ", (MonotonicTime::now() - start).seconds());
-#endif
#endif // HAVE(CORE_VIDEO)
}
@@ -3485,7 +3470,6 @@
#endif
}
-#if !RELEASE_LOG_DISABLED
if (player->logger().willLog(player->logChannel(), WTFLogLevel::Debug) && !([keyPath isEqualToString:@"loadedTimeRanges"] || [keyPath isEqualToString:@"seekableTimeRanges"])) {
auto identifier = Logger::LogSiteIdentifier("MediaPlayerPrivateAVFoundation", "observeValueForKeyPath", player->logIdentifier());
@@ -3499,7 +3483,6 @@
} else
player->logger().debug(player->logChannel(), identifier, willChange ? "will" : "did", " change '", [keyPath UTF8String], "'");
}
-#endif
});
});
}
Modified: branches/safari-609-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h (257036 => 257037)
--- branches/safari-609-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2020-02-20 03:36:53 UTC (rev 257036)
+++ branches/safari-609-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2020-02-20 03:48:09 UTC (rev 257037)
@@ -63,9 +63,7 @@
class MediaPlayerPrivateMediaSourceAVFObjC
: public CanMakeWeakPtr<MediaPlayerPrivateMediaSourceAVFObjC>
, public MediaPlayerPrivateInterface
-#if !RELEASE_LOG_DISABLED
, private LoggerHelper
-#endif
{
public:
explicit MediaPlayerPrivateMediaSourceAVFObjC(MediaPlayer*);
@@ -150,7 +148,6 @@
const Vector<ContentType>& mediaContentTypesRequiringHardwareSupport() const;
bool shouldCheckHardwareSupport() const;
-#if !RELEASE_LOG_DISABLED
const Logger& logger() const final { return m_logger.get(); }
const char* logClassName() const override { return "MediaPlayerPrivateMediaSourceAVFObjC"; }
const void* logIdentifier() const final { return reinterpret_cast<const void*>(m_logIdentifier); }
@@ -158,7 +155,6 @@
const void* mediaPlayerLogIdentifier() { return logIdentifier(); }
const Logger& mediaPlayerLogger() { return logger(); }
-#endif
enum SeekState {
Seeking,
@@ -327,14 +323,11 @@
RefPtr<MediaPlaybackTarget> m_playbackTarget;
bool m_shouldPlayToTarget { false };
#endif
+ Ref<const Logger> m_logger;
+ const void* m_logIdentifier;
std::unique_ptr<VideoFullscreenLayerManagerObjC> m_videoFullscreenLayerManager;
Ref<EffectiveRateChangedListener> m_effectiveRateChangedListener;
-
-#if !RELEASE_LOG_DISABLED
- Ref<const Logger> m_logger;
- const void* m_logIdentifier;
-#endif
};
String convertEnumerationToString(MediaPlayerPrivateMediaSourceAVFObjC::SeekState);
Modified: branches/safari-609-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (257036 => 257037)
--- branches/safari-609-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2020-02-20 03:36:53 UTC (rev 257036)
+++ branches/safari-609-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2020-02-20 03:48:09 UTC (rev 257037)
@@ -137,12 +137,10 @@
, m_playing(0)
, m_seeking(false)
, m_loadingProgressed(false)
- , m_videoFullscreenLayerManager(makeUnique<VideoFullscreenLayerManagerObjC>())
- , m_effectiveRateChangedListener(EffectiveRateChangedListener::create(*this, [m_synchronizer timebase]))
-#if !RELEASE_LOG_DISABLED
, m_logger(player->mediaPlayerLogger())
, m_logIdentifier(player->mediaPlayerLogIdentifier())
-#endif
+ , m_videoFullscreenLayerManager(makeUnique<VideoFullscreenLayerManagerObjC>(m_logger, m_logIdentifier))
+ , m_effectiveRateChangedListener(EffectiveRateChangedListener::create(*this, [m_synchronizer timebase]))
{
auto logSiteIdentifier = LOGIDENTIFIER;
ALWAYS_LOG(logSiteIdentifier);
@@ -1225,12 +1223,10 @@
return true;
}
-#if !RELEASE_LOG_DISABLED
WTFLogChannel& MediaPlayerPrivateMediaSourceAVFObjC::logChannel() const
{
return LogMediaSource;
}
-#endif
}
Modified: branches/safari-609-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h (257036 => 257037)
--- branches/safari-609-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h 2020-02-20 03:36:53 UTC (rev 257036)
+++ branches/safari-609-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h 2020-02-20 03:48:09 UTC (rev 257037)
@@ -58,10 +58,8 @@
class VideoFullscreenLayerManagerObjC;
class VideoTrackPrivateMediaStream;
-class MediaPlayerPrivateMediaStreamAVFObjC final : public CanMakeWeakPtr<MediaPlayerPrivateMediaStreamAVFObjC>, public MediaPlayerPrivateInterface, private MediaStreamPrivate::Observer, private MediaStreamTrackPrivate::Observer
-#if !RELEASE_LOG_DISABLED
+class MediaPlayerPrivateMediaStreamAVFObjC final : public MediaPlayerPrivateInterface, private MediaStreamPrivate::Observer, private MediaStreamTrackPrivate::Observer, public SampleBufferDisplayLayer::Client
, private LoggerHelper
-#endif
{
public:
explicit MediaPlayerPrivateMediaStreamAVFObjC(MediaPlayer*);
@@ -89,12 +87,10 @@
PlatformLayer* displayLayer();
PlatformLayer* backgroundLayer();
-#if !RELEASE_LOG_DISABLED
const Logger& logger() const final { return m_logger.get(); }
const char* logClassName() const override { return "MediaPlayerPrivateMediaStreamAVFObjC"; }
const void* logIdentifier() const final { return reinterpret_cast<const void*>(m_logIdentifier); }
WTFLogChannel& logChannel() const final;
-#endif
private:
// MediaPlayerPrivateInterface
@@ -261,13 +257,17 @@
PlaybackState m_playbackState { PlaybackState::None };
MediaSample::VideoRotation m_videoRotation { MediaSample::VideoRotation::None };
CGAffineTransform m_videoTransform;
- std::unique_ptr<VideoFullscreenLayerManagerObjC> m_videoFullscreenLayerManager;
+ std::unique_ptr<SampleBufferDisplayLayer> m_sampleBufferDisplayLayer;
-#if !RELEASE_LOG_DISABLED
Ref<const Logger> m_logger;
const void* m_logIdentifier;
-#endif
+ std::unique_ptr<VideoFullscreenLayerManagerObjC> m_videoFullscreenLayerManager;
+ // SampleBufferDisplayLayer::Client
+ void sampleBufferDisplayLayerStatusDidChange(SampleBufferDisplayLayer&) final;
+
+ RetainPtr<WebRootSampleBufferBoundsChangeListener> m_boundsChangeListener;
+
bool m_videoMirrored { false };
bool m_playing { false };
bool m_muted { false };
Modified: branches/safari-609-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm (257036 => 257037)
--- branches/safari-609-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm 2020-02-20 03:36:53 UTC (rev 257036)
+++ branches/safari-609-branch/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm 2020-02-20 03:48:09 UTC (rev 257037)
@@ -183,11 +183,10 @@
: m_player(player)
, m_statusChangeListener(adoptNS([[WebAVSampleBufferStatusChangeListener alloc] initWithParent:this]))
, m_clock(PAL::Clock::create())
- , m_videoFullscreenLayerManager(makeUnique<VideoFullscreenLayerManagerObjC>())
-#if !RELEASE_LOG_DISABLED
, m_logger(player->mediaPlayerLogger())
, m_logIdentifier(player->mediaPlayerLogIdentifier())
-#endif
+ , m_videoFullscreenLayerManager(makeUnique<VideoFullscreenLayerManagerObjC>(m_logger, m_logIdentifier))
+ , m_boundsChangeListener(adoptNS([[WebRootSampleBufferBoundsChangeListener alloc] initWithParent:this]))
{
INFO_LOG(LOGIDENTIFIER);
}
@@ -1214,12 +1213,10 @@
});
}
-#if !RELEASE_LOG_DISABLED
WTFLogChannel& MediaPlayerPrivateMediaStreamAVFObjC::logChannel() const
{
return LogMedia;
}
-#endif
}
Modified: branches/safari-609-branch/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.h (257036 => 257037)
--- branches/safari-609-branch/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.h 2020-02-20 03:36:53 UTC (rev 257036)
+++ branches/safari-609-branch/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.h 2020-02-20 03:48:09 UTC (rev 257037)
@@ -31,6 +31,7 @@
#include "VideoFullscreenLayerManager.h"
#include "WebVideoContainerLayer.h"
#include <wtf/Function.h>
+#include <wtf/LoggerHelper.h>
#include <wtf/Noncopyable.h>
#include <wtf/RetainPtr.h>
@@ -38,10 +39,10 @@
namespace WebCore {
-class VideoFullscreenLayerManagerObjC final : public VideoFullscreenLayerManager {
+class VideoFullscreenLayerManagerObjC final : public VideoFullscreenLayerManager , public LoggerHelper {
WTF_MAKE_FAST_ALLOCATED;
public:
- VideoFullscreenLayerManagerObjC();
+ VideoFullscreenLayerManagerObjC(const Logger&, const void*);
PlatformLayer *videoInlineLayer() const final { return m_videoInlineLayer.get(); }
PlatformLayer *videoFullscreenLayer() const final { return m_videoFullscreenLayer.get(); }
@@ -57,6 +58,14 @@
void syncTextTrackBounds() final;
private:
+ const Logger& logger() const final { return m_logger.get(); }
+ const void* logIdentifier() const final { return m_logIdentifier; }
+ const char* logClassName() const final { return "VideoFullscreenLayerManagerObjC"; }
+ WTFLogChannel& logChannel() const final;
+
+ Ref<const Logger> m_logger;
+ const void* m_logIdentifier;
+
RetainPtr<PlatformLayer> m_textTrackRepresentationLayer;
RetainPtr<WebVideoContainerLayer> m_videoInlineLayer;
RetainPtr<PlatformLayer> m_videoFullscreenLayer;
Modified: branches/safari-609-branch/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.mm (257036 => 257037)
--- branches/safari-609-branch/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.mm 2020-02-20 03:36:53 UTC (rev 257036)
+++ branches/safari-609-branch/Source/WebCore/platform/graphics/avfoundation/objc/VideoFullscreenLayerManagerObjC.mm 2020-02-20 03:48:09 UTC (rev 257037)
@@ -27,6 +27,7 @@
#import "VideoFullscreenLayerManagerObjC.h"
#import "Color.h"
+#import "Logging.h"
#import "TextTrackRepresentation.h"
#import "WebCoreCALayerExtras.h"
#import <mach/mach_init.h>
@@ -39,13 +40,17 @@
namespace WebCore {
-VideoFullscreenLayerManagerObjC::VideoFullscreenLayerManagerObjC()
+VideoFullscreenLayerManagerObjC::VideoFullscreenLayerManagerObjC(const Logger& logger, const void* logIdentifier)
: VideoFullscreenLayerManager()
+ , m_logger(logger)
+ , m_logIdentifier(logIdentifier)
{
}
void VideoFullscreenLayerManagerObjC::setVideoLayer(PlatformLayer *videoLayer, IntSize contentSize)
{
+ ALWAYS_LOG(LOGIDENTIFIER, contentSize.width(), ", ", contentSize.height());
+
m_videoLayer = videoLayer;
m_videoInlineFrame = CGRectMake(0, 0, contentSize.width(), contentSize.height());
@@ -81,6 +86,8 @@
return;
}
+ ALWAYS_LOG(LOGIDENTIFIER);
+
m_videoFullscreenLayer = videoFullscreenLayer;
[CATransaction begin];
@@ -121,6 +128,8 @@
void VideoFullscreenLayerManagerObjC::setVideoFullscreenFrame(FloatRect videoFullscreenFrame)
{
+ ALWAYS_LOG(LOGIDENTIFIER, videoFullscreenFrame.x(), ", ", videoFullscreenFrame.y(), ", ", videoFullscreenFrame.width(), ", ", videoFullscreenFrame.height());
+
m_videoFullscreenFrame = videoFullscreenFrame;
if (!m_videoFullscreenLayer)
return;
@@ -131,6 +140,8 @@
void VideoFullscreenLayerManagerObjC::didDestroyVideoLayer()
{
+ ALWAYS_LOG(LOGIDENTIFIER);
+
[m_videoLayer removeFromSuperlayer];
m_videoInlineLayer = nil;
@@ -147,6 +158,9 @@
if (!m_videoFullscreenLayer || !m_textTrackRepresentationLayer)
return;
+ if (m_textTrackRepresentationLayer.get().bounds == m_videoFullscreenFrame)
+ return;
+
[CATransaction begin];
[CATransaction setDisableActions:YES];
@@ -157,6 +171,8 @@
void VideoFullscreenLayerManagerObjC::setTextTrackRepresentation(TextTrackRepresentation* representation)
{
+ ALWAYS_LOG(LOGIDENTIFIER);
+
PlatformLayer* representationLayer = representation ? representation->platformLayer() : nil;
if (representationLayer == m_textTrackRepresentationLayer) {
syncTextTrackBounds();
@@ -180,5 +196,10 @@
}
+WTFLogChannel& VideoFullscreenLayerManagerObjC::logChannel() const
+{
+ return LogMedia;
}
+}
+
Modified: branches/safari-609-branch/Source/WebCore/platform/graphics/cocoa/TextTrackRepresentationCocoa.h (257036 => 257037)
--- branches/safari-609-branch/Source/WebCore/platform/graphics/cocoa/TextTrackRepresentationCocoa.h 2020-02-20 03:36:53 UTC (rev 257036)
+++ branches/safari-609-branch/Source/WebCore/platform/graphics/cocoa/TextTrackRepresentationCocoa.h 2020-02-20 03:48:09 UTC (rev 257037)
@@ -28,9 +28,10 @@
#if (PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))) && ENABLE(VIDEO_TRACK)
-#import "TextTrackRepresentation.h"
-#import <QuartzCore/CALayer.h>
-#import <wtf/RetainPtr.h>
+#include "GenericTaskQueue.h"
+#include "TextTrackRepresentation.h"
+#include <QuartzCore/CALayer.h>
+#include <wtf/RetainPtr.h>
@class WebCoreTextTrackRepresentationCocoaHelper;
@@ -43,13 +44,17 @@
TextTrackRepresentationClient& client() const { return m_client; }
- PlatformLayer* platformLayer() override { return m_layer.get(); }
- IntRect bounds() const override;
+ PlatformLayer* platformLayer() final { return m_layer.get(); }
+ IntRect bounds() const final;
+ void boundsChanged();
+
private:
- void update() override;
- void setContentScale(float) override;
+ void update() final;
+ void setContentScale(float) final;
+ void setHidden(bool) const final;
+ GenericTaskQueue<Timer> m_taskQueue;
TextTrackRepresentationClient& m_client;
RetainPtr<CALayer> m_layer;
RetainPtr<WebCoreTextTrackRepresentationCocoaHelper> m_delegate;
Modified: branches/safari-609-branch/Source/WebCore/platform/graphics/cocoa/TextTrackRepresentationCocoa.mm (257036 => 257037)
--- branches/safari-609-branch/Source/WebCore/platform/graphics/cocoa/TextTrackRepresentationCocoa.mm 2020-02-20 03:36:53 UTC (rev 257036)
+++ branches/safari-609-branch/Source/WebCore/platform/graphics/cocoa/TextTrackRepresentationCocoa.mm 2020-02-20 03:48:09 UTC (rev 257037)
@@ -92,7 +92,7 @@
});
#else
if (_parent && [keyPath isEqual:@"bounds"] && object == _parent->platformLayer())
- _parent->client().textTrackRepresentationBoundsChanged(_parent->bounds());
+ _parent->boundsChanged();
#endif
}
@@ -137,9 +137,21 @@
[m_layer.get() setContentsScale:scale];
}
+void TextTrackRepresentationCocoa::setHidden(bool hidden) const
+{
+ [m_layer.get() setHidden:hidden];
+}
+
IntRect TextTrackRepresentationCocoa::bounds() const
{
return enclosingIntRect(FloatRect([m_layer.get() bounds]));
}
+void TextTrackRepresentationCocoa::boundsChanged()
+{
+ m_taskQueue.enqueueTask([this] () {
+ client().textTrackRepresentationBoundsChanged(bounds());
+ });
+}
+
#endif // (PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))) && ENABLE(VIDEO_TRACK)
Modified: branches/safari-609-branch/Source/WebCore/rendering/RenderMediaControlElements.cpp (257036 => 257037)
--- branches/safari-609-branch/Source/WebCore/rendering/RenderMediaControlElements.cpp 2020-02-20 03:36:53 UTC (rev 257036)
+++ branches/safari-609-branch/Source/WebCore/rendering/RenderMediaControlElements.cpp 2020-02-20 03:48:09 UTC (rev 257037)
@@ -104,7 +104,7 @@
ASSERT(mediaControlElementType(element()) == MediaTextTrackDisplayContainer);
LayoutStateDisabler layoutStateDisabler(view().frameView().layoutContext());
- static_cast<MediaControlTextTrackContainerElement*>(element())->updateSizes();
+ static_cast<MediaControlTextTrackContainerElement*>(element())->layoutIfNecessary();
}
#endif // ENABLE(VIDEO_TRACK)