Bug 210518 - [macOS] Update ScreenTime as playback state changes
Summary: [macOS] Update ScreenTime as playback state changes
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Eric Carlson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-04-14 15:09 PDT by Eric Carlson
Modified: 2021-03-30 22:52 PDT (History)
17 users (show)

See Also:


Attachments
WIP patch for the bots to check (96.43 KB, patch)
2020-04-14 17:29 PDT, Eric Carlson
no flags Details | Formatted Diff | Diff
updated WIP patch for the bots (104.06 KB, patch)
2020-04-14 21:44 PDT, Eric Carlson
no flags Details | Formatted Diff | Diff
updated WIP patch for the bots (104.17 KB, patch)
2020-04-15 07:04 PDT, Eric Carlson
no flags Details | Formatted Diff | Diff
updated WIP patch for the bots (104.19 KB, patch)
2020-04-15 08:36 PDT, Eric Carlson
no flags Details | Formatted Diff | Diff
Patch (115.99 KB, patch)
2020-04-15 16:23 PDT, Eric Carlson
no flags Details | Formatted Diff | Diff
Patch for landing (116.60 KB, patch)
2020-04-15 21:33 PDT, Eric Carlson
no flags Details | Formatted Diff | Diff
Follow-up Patch (1.82 KB, patch)
2020-04-16 11:04 PDT, Jer Noble
eric.carlson: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Carlson 2020-04-14 15:09:25 PDT
Update ScreenTime as playback state changes
Comment 1 Eric Carlson 2020-04-14 15:10:05 PDT
<rdar://problem/61181092>
Comment 2 Eric Carlson 2020-04-14 17:29:58 PDT
Created attachment 396481 [details]
WIP patch for the bots to check
Comment 3 Eric Carlson 2020-04-14 21:44:25 PDT
Created attachment 396497 [details]
updated WIP patch for the bots
Comment 4 Eric Carlson 2020-04-15 07:04:52 PDT
Created attachment 396528 [details]
updated WIP patch for the bots
Comment 5 Eric Carlson 2020-04-15 08:36:35 PDT
Created attachment 396540 [details]
updated WIP patch for the bots
Comment 6 Jer Noble 2020-04-15 09:31:57 PDT
Comment on attachment 396540 [details]
updated WIP patch for the bots

View in context: https://bugs.webkit.org/attachment.cgi?id=396540&action=review

> Source/WebCore/ChangeLog:1
> +2020-04-14  Eric Carlson  <eric.carlson@apple.com>

...

> Source/WebCore/ChangeLog:60
> +2020-04-14  Eric Carlson  <eric.carlson@apple.com>

Looks like you got a double changelong here.

> Source/WebKit/ChangeLog:52
> +2020-04-14  Eric Carlson  <eric.carlson@apple.com>

Here too.

> Source/WebCore/html/MediaElementSession.cpp:123
> +#if PLATFORM(MACCATALYST) || PLATFORM(MAC)

Could you add a ENABLE(MEDIA_USAGE) pragma and use it in platform-independent code instead? That way other ports could adopt without having to touch all these call sites.

> Source/WebKit/UIProcess/WebPageProxy.h:1739
> +    void addMediaUsageManagerSession(WebCore::MediaSessionIdentifier, const String& /* bundleIdentifier */, const URL& /* pageURL */);

Is there a reason these parameter names are commented out?
Comment 7 Eric Carlson 2020-04-15 16:23:59 PDT
Created attachment 396586 [details]
Patch
Comment 8 Eric Carlson 2020-04-15 16:28:45 PDT
Comment on attachment 396540 [details]
updated WIP patch for the bots

View in context: https://bugs.webkit.org/attachment.cgi?id=396540&action=review

>> Source/WebCore/ChangeLog:60
>> +2020-04-14  Eric Carlson  <eric.carlson@apple.com>
> 
> Looks like you got a double changelong here.

Fixed.

>> Source/WebCore/html/MediaElementSession.cpp:123
>> +#if PLATFORM(MACCATALYST) || PLATFORM(MAC)
> 
> Could you add a ENABLE(MEDIA_USAGE) pragma and use it in platform-independent code instead? That way other ports could adopt without having to touch all these call sites.

Good suggestion, changed.

>> Source/WebKit/UIProcess/WebPageProxy.h:1739
>> +    void addMediaUsageManagerSession(WebCore::MediaSessionIdentifier, const String& /* bundleIdentifier */, const URL& /* pageURL */);
> 
> Is there a reason these parameter names are commented out?

Left over from an earlier version with more parameters. Removed.
Comment 9 Peng Liu 2020-04-15 17:12:24 PDT
Comment on attachment 396586 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=396586&action=review

> Source/WebKit/UIProcess/Media/cocoa/MediaUsageManagerCocoa.h:42
> +    void reset() final;

Nit. Looks like these functions can be private?
Comment 10 Jon Lee 2020-04-15 17:29:17 PDT
Comment on attachment 396586 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=396586&action=review

> Source/WebCore/html/MediaElementSession.cpp:1021
> +    auto* fullscreenElement = m_element.document().fullscreenManager().currentFullscreenElement();

document.fullscreenManager()...

> Source/WebCore/html/MediaElementSession.cpp:1036
> +        m_element.document().isMediaDocument() && (m_element.document().frame() && m_element.document().frame()->isMainFrame()),

ditto
Comment 11 Jer Noble 2020-04-15 17:40:36 PDT
Comment on attachment 396586 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=396586&action=review

R=me with just a couple of nits.

> Source/WebCore/testing/Internals.idl:120
> +[
> +    ExportMacro=WEBCORE_TESTSUPPORT_EXPORT,
> +    Conditional=VIDEO,
> +    JSGenerateToJSObject,
> +] dictionary MediaUsageState {

It's unfortunate you can't just re-use MediaUsageInfo here, and not re-declare the existing struct, but I guess that the URL -> DOMString for mediaURL makes that untenable.

> Source/WebKit/UIProcess/Media/cocoa/MediaUsageManagerCocoa.h:63
> +        WebCore::MediaSessionIdentifier m_identifier;
> +        String m_bundleIdentifier;
> +        URL m_pageURL;
> +        Optional<WebCore::MediaUsageInfo> m_mediaUsageInfo;
> +        RetainPtr<USVideoUsage> m_usageTracker;

Since structs have public members, there's no no need to prefix these with `m_`.

> Source/WebKit/UIProcess/Media/cocoa/MediaUsageManagerCocoa.mm:198
> +        WTFLogAlways("MediaUsageManagerCocoa::updateMediaUsage caught exception!");

Do you want to include the exception.description here?
Comment 12 Eric Carlson 2020-04-15 21:33:33 PDT
Created attachment 396616 [details]
Patch for landing
Comment 13 EWS 2020-04-16 06:36:12 PDT
Committed r260182: <https://trac.webkit.org/changeset/260182>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 396616 [details].
Comment 14 Jer Noble 2020-04-16 11:04:15 PDT
Reopening to attach new patch.
Comment 15 Jer Noble 2020-04-16 11:04:17 PDT
Created attachment 396672 [details]
Follow-up Patch
Comment 16 Jer Noble 2020-04-16 11:11:30 PDT
Committed r260201: <https://trac.webkit.org/changeset/260201>