Bug 221996 - [macOS] Observe system sleep events in the UI process
Summary: [macOS] Observe system sleep events in the UI process
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Per Arne Vollan
URL:
Keywords: InRadar
: 222055 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-02-16 13:44 PST by Per Arne Vollan
Modified: 2021-02-18 10:18 PST (History)
11 users (show)

See Also:


Attachments
Patch (11.47 KB, patch)
2021-02-16 14:25 PST, Per Arne Vollan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Per Arne Vollan 2021-02-16 13:44:09 PST
System sleep events should be observed in the UI process, which should notify the WebContent process.
Comment 1 Radar WebKit Bug Importer 2021-02-16 14:20:18 PST
<rdar://problem/74406570>
Comment 2 Per Arne Vollan 2021-02-16 14:25:54 PST
Created attachment 420540 [details]
Patch
Comment 3 Brent Fulgham 2021-02-17 09:44:52 PST
Comment on attachment 420540 [details]
Patch

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

I'm worried this change is not right for iOS, since the MediaSessionManagerIOS class is a subclass of MediaSessionManager. I like the idea of the UIProcess handling sleep events, and forwarding them to the WebContent process -- I just think you might need these changes for iOS, too.

> Source/WebKit/UIProcess/WebProcessPool.h:132
> +    , private PAL::SystemSleepListener::Client

MediaSessionManagerIOS *is a* MediaSessionManagerCocoa. Are you sure we don't need this code in the iOS case?
Comment 4 Per Arne Vollan 2021-02-17 09:49:29 PST
(In reply to Brent Fulgham from comment #3)
> Comment on attachment 420540 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=420540&action=review
> 
> I'm worried this change is not right for iOS, since the
> MediaSessionManagerIOS class is a subclass of MediaSessionManager. I like
> the idea of the UIProcess handling sleep events, and forwarding them to the
> WebContent process -- I just think you might need these changes for iOS, too.
> 
> > Source/WebKit/UIProcess/WebProcessPool.h:132
> > +    , private PAL::SystemSleepListener::Client
> 
> MediaSessionManagerIOS *is a* MediaSessionManagerCocoa. Are you sure we
> don't need this code in the iOS case?

Yes, I believe you are right. I will add it for iOS as well.

Thanks for reviewing!
Comment 5 youenn fablet 2021-02-17 09:57:20 PST
Comment on attachment 420540 [details]
Patch

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

>> Source/WebKit/UIProcess/WebProcessPool.h:132
>> +    , private PAL::SystemSleepListener::Client
> 
> MediaSessionManagerIOS *is a* MediaSessionManagerCocoa. Are you sure we don't need this code in the iOS case?

I think this change is ok in practice, agreed it is a bit weird that this code is in Cocoa and not MediaSessionManagerMac, but we do not have any.
I am not sure WebProcessPool is the best choice though.
Maybe there should be a singleton that would be enabled at creation of WebProcessPool for instance and that would send it to all processes of all process pools.

Another approach would be to do this in GPUProcess, since this is only used for media.
Comment 6 Peng Liu 2021-02-17 15:55:08 PST
*** Bug 222055 has been marked as a duplicate of this bug. ***
Comment 7 Chris Dumez 2021-02-17 17:15:52 PST
Comment on attachment 420540 [details]
Patch

r=me
Comment 8 Per Arne Vollan 2021-02-18 07:02:03 PST
(In reply to Per Arne Vollan from comment #4)
> (In reply to Brent Fulgham from comment #3)
> > Comment on attachment 420540 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=420540&action=review
> > 
> > I'm worried this change is not right for iOS, since the
> > MediaSessionManagerIOS class is a subclass of MediaSessionManager. I like
> > the idea of the UIProcess handling sleep events, and forwarding them to the
> > WebContent process -- I just think you might need these changes for iOS, too.
> > 
> > > Source/WebKit/UIProcess/WebProcessPool.h:132
> > > +    , private PAL::SystemSleepListener::Client
> > 
> > MediaSessionManagerIOS *is a* MediaSessionManagerCocoa. Are you sure we
> > don't need this code in the iOS case?
> 
> Yes, I believe you are right. I will add it for iOS as well.
> 
> Thanks for reviewing!

Looking closer, it seems that the SystemSleepListener is only an empty implementation on iOS, so it does not seem like it is required.
Comment 9 Per Arne Vollan 2021-02-18 07:07:39 PST
(In reply to youenn fablet from comment #5)
> Comment on attachment 420540 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=420540&action=review
> 
> >> Source/WebKit/UIProcess/WebProcessPool.h:132
> >> +    , private PAL::SystemSleepListener::Client
> > 
> > MediaSessionManagerIOS *is a* MediaSessionManagerCocoa. Are you sure we don't need this code in the iOS case?
> 
> I think this change is ok in practice, agreed it is a bit weird that this
> code is in Cocoa and not MediaSessionManagerMac, but we do not have any.
> I am not sure WebProcessPool is the best choice though.
> Maybe there should be a singleton that would be enabled at creation of
> WebProcessPool for instance and that would send it to all processes of all
> process pools.
> 
> Another approach would be to do this in GPUProcess, since this is only used
> for media.

These are very good points. In this case, it seems we only create MediaSessionManagerCocoa in the WP process, also with the GPU process enabled, so it seems to be sufficient to only forward these events to the WP process. We may need to forward these events to other WebKit process going forward, though.

Thanks for reviewing!
Comment 10 Per Arne Vollan 2021-02-18 07:07:56 PST
(In reply to Chris Dumez from comment #7)
> Comment on attachment 420540 [details]
> Patch
> 
> r=me

Thanks for reviewing!
Comment 11 EWS 2021-02-18 10:18:37 PST
Committed r273082: <https://commits.webkit.org/r273082>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 420540 [details].