Skip to content

Commit

Permalink
[Cocoa] Add nextChildIdentifier() to VideoFullscreenModel
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=257067
rdar://109590097

Reviewed by Eric Carlson.

Multiple WebAVPlayerLayers can exist simultaneously, and disambiguating their logs when they coexist
can be difficult. Use LoggerHelper's concept of a "child identifier", and expose that child
identifier through VideoFullscreenModel. Each WebAVPlayerLayer will get a unique but related
identifier.

* Source/WebCore/platform/cocoa/VideoFullscreenModel.h:
(WebCore::VideoFullscreenModel::nextChildIdentifier const):
* Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.h:
* Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.mm:
(WebCore::VideoFullscreenModelVideoElement::nextChildIdentifier const):
* Source/WebCore/platform/cocoa/WebAVPlayerLayer.mm:
(-[WebAVPlayerLayer setFullscreenModel:]):
(-[WebAVPlayerLayer videoRect]):
* Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h:
* Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
(WebKit::VideoFullscreenModelContext::nextChildIdentifier const):

Canonical link: https://commits.webkit.org/264309@main
  • Loading branch information
jernoble committed May 22, 2023
1 parent bb2ddeb commit 88af6d5
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 7 deletions.
1 change: 1 addition & 0 deletions Source/WebCore/platform/cocoa/VideoFullscreenModel.h
Expand Up @@ -79,6 +79,7 @@ class VideoFullscreenModel : public CanMakeWeakPtr<VideoFullscreenModel> {

#if !RELEASE_LOG_DISABLED
virtual const void* logIdentifier() const { return nullptr; }
virtual const void* nextChildIdentifier() const { return logIdentifier(); }
virtual const Logger* loggerPtr() const { return nullptr; }
#endif
};
Expand Down
Expand Up @@ -79,8 +79,9 @@ class VideoFullscreenModelVideoElement : public VideoFullscreenModel, public Eve
WEBCORE_EXPORT void requestRouteSharingPolicyAndContextUID(CompletionHandler<void(RouteSharingPolicy, String)>&&) override;

#if !RELEASE_LOG_DISABLED
const Logger* loggerPtr() const override;
WEBCORE_EXPORT const void* logIdentifier() const override;
const Logger* loggerPtr() const final;
WEBCORE_EXPORT const void* logIdentifier() const final;
WEBCORE_EXPORT const void* nextChildIdentifier() const final;
const char* logClassName() const { return "VideoFullscreenModelVideoElement"; }
WTFLogChannel& logChannel() const;
#endif
Expand Down Expand Up @@ -112,6 +113,10 @@ class VideoFullscreenModelVideoElement : public VideoFullscreenModel, public Eve
Vector<RefPtr<TextTrack>> m_legibleTracksForMenu;
Vector<RefPtr<AudioTrack>> m_audioTracksForMenu;
std::optional<MediaPlayerIdentifier> m_playerIdentifier;

#if !RELEASE_LOG_DISABLED
mutable uint64_t m_childIdentifierSeed { 0 };
#endif
};

}
Expand Down
Expand Up @@ -338,6 +338,11 @@
return m_videoElement ? m_videoElement->logIdentifier() : nullptr;
}

const void* VideoFullscreenModelVideoElement::nextChildIdentifier() const
{
return LoggerHelper::childLogIdentifier(logIdentifier(), ++m_childIdentifierSeed);
}

WTFLogChannel& VideoFullscreenModelVideoElement::logChannel() const
{
return LogFullscreen;
Expand Down
10 changes: 7 additions & 3 deletions Source/WebCore/platform/cocoa/WebAVPlayerLayer.mm
Expand Up @@ -83,6 +83,9 @@ @implementation WebAVPlayerLayer {
RetainPtr<NSString> _videoGravity;
RetainPtr<NSString> _previousVideoGravity;
std::unique_ptr<WebAVPlayerLayerFullscreenModelClient> _fullscreenModelClient;
#if !RELEASE_LOG_DISABLED
const void* _logIdentifier;
#endif
}

- (instancetype)init
Expand Down Expand Up @@ -127,6 +130,9 @@ - (void)setFullscreenModel:(VideoFullscreenModel*)fullscreenModel
_fullscreenModel->addClient(*_fullscreenModelClient);

self.videoDimensions = _fullscreenModel->videoDimensions();
#if !RELEASE_LOG_DISABLED
_logIdentifier = _fullscreenModel ? _fullscreenModel->nextChildIdentifier() : nullptr;
#endif
}

- (AVPlayerController *)playerController
Expand Down Expand Up @@ -358,9 +364,7 @@ + (NSSet *)keyPathsForValuesAffectingVideoRect
@implementation WebAVPlayerLayer (Logging)
- (const void*)logIdentifier
{
if (_fullscreenModel)
return _fullscreenModel->logIdentifier();
return nullptr;
return _logIdentifier;
}

- (const Logger*)loggerPtr
Expand Down
9 changes: 7 additions & 2 deletions Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h
Expand Up @@ -133,8 +133,9 @@ class VideoFullscreenModelContext final
void fullscreenMayReturnToInline() final;

#if !RELEASE_LOG_DISABLED
const void* logIdentifier() const override;
const Logger* loggerPtr() const override;
const void* logIdentifier() const final;
const void* nextChildIdentifier() const final;
const Logger* loggerPtr() const final;

const char* logClassName() const { return "VideoFullscreenModelContext"; };
WTFLogChannel& logChannel() const;
Expand All @@ -153,6 +154,10 @@ class VideoFullscreenModelContext final
HashSet<WebCore::VideoFullscreenModelClient*> m_clients;
WebCore::FloatSize m_videoDimensions;
bool m_hasVideo { false };

#if !RELEASE_LOG_DISABLED
mutable uint64_t m_childIdentifierSeed { 0 };
#endif
};

class VideoFullscreenManagerProxy : public RefCounted<VideoFullscreenManagerProxy>, private IPC::MessageReceiver {
Expand Down
5 changes: 5 additions & 0 deletions Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm
Expand Up @@ -381,6 +381,11 @@ - (BOOL)prefersStatusBarHidden
return m_playbackSessionModel->logIdentifier();
}

const void* VideoFullscreenModelContext::nextChildIdentifier() const
{
return LoggerHelper::childLogIdentifier(m_playbackSessionModel->logIdentifier(), ++m_childIdentifierSeed);
}

const Logger* VideoFullscreenModelContext::loggerPtr() const
{
return m_playbackSessionModel->loggerPtr();
Expand Down

0 comments on commit 88af6d5

Please sign in to comment.