Bug 221258

Summary: Register for power notifications in the UI process
Product: WebKit Reporter: Per Arne Vollan <pvollan>
Component: WebKit Misc.Assignee: Per Arne Vollan <pvollan>
Status: RESOLVED FIXED    
Severity: Normal CC: aakash_jain, bfulgham, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 252940    
Bug Blocks:    
Attachments:
Description Flags
Patch
ews-feeder: commit-queue-
Patch
ews-feeder: commit-queue-
Patch
ews-feeder: commit-queue-
Patch none

Description Per Arne Vollan 2021-02-02 07:23:34 PST
Power notifications should be registered for in the UI process instead of the WebContent process.
Comment 1 Per Arne Vollan 2021-02-02 07:36:50 PST
Created attachment 418999 [details]
Patch
Comment 2 Per Arne Vollan 2021-02-02 08:17:23 PST
Created attachment 419001 [details]
Patch
Comment 3 Per Arne Vollan 2021-02-02 09:18:35 PST
Created attachment 419009 [details]
Patch
Comment 4 Per Arne Vollan 2021-02-02 09:44:01 PST
Created attachment 419014 [details]
Patch
Comment 5 Brent Fulgham 2021-02-02 09:44:36 PST
Comment on attachment 419009 [details]
Patch

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

It looks like tvOS is unhappy, too!

> Source/WebKit/WebProcess/WebProcess.messages.in:199
> +#if PLATFORM(MAC)

Is this needed for Catalyst?

> Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:636
> +    MainThreadSharedTimer::shouldSetupPowerObserver() = false;

It seems like we place the burden of knowing not to set the power observer on the various client processes. Maybe it would be better if it defaulted to false, and the main UIProcess initialization had to set it to true?
Comment 6 Brent Fulgham 2021-02-02 09:53:51 PST
Comment on attachment 419014 [details]
Patch

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

> Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:636
> +    MainThreadSharedTimer::shouldSetupPowerObserver() = false;

This places the burden on all aux processes. How about if we make the default false, and require this be set to true in 'Source/WebKit/Shared/WebKit2Initialize.cpp:void InitializeWebKit2()' so that only the UIProcess has to set this value?
Comment 7 Per Arne Vollan 2021-02-02 11:33:58 PST
(In reply to Brent Fulgham from comment #5)
> Comment on attachment 419009 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=419009&action=review
> 
> It looks like tvOS is unhappy, too!
> 
> > Source/WebKit/WebProcess/WebProcess.messages.in:199
> > +#if PLATFORM(MAC)
> 
> Is this needed for Catalyst?
> 

It seems only Mac is using the PowerObserver, so I do not think this is needed for Catalyst.

> > Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:636
> > +    MainThreadSharedTimer::shouldSetupPowerObserver() = false;
> 
> It seems like we place the burden of knowing not to set the power observer
> on the various client processes. Maybe it would be better if it defaulted to
> false, and the main UIProcess initialization had to set it to true?

We only disable setup of the PowerObserver in the WebContent process. The WebContent process will be notified by the UI process about power events. For the other processes it will default to true, which gives the same behavior as before. I am perhaps not understanding your comment correctly, though. Does this address your comment?

Thanks for reviewing!
Comment 8 Brent Fulgham 2021-02-02 11:39:53 PST
Comment on attachment 419009 [details]
Patch

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

>>> Source/WebKit/WebProcess/WebProcess.messages.in:199
>>> +#if PLATFORM(MAC)
>> 
>> Is this needed for Catalyst?
> 
> It seems only Mac is using the PowerObserver, so I do not think this is needed for Catalyst.

Okay, good.

>>> Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm:636
>>> +    MainThreadSharedTimer::shouldSetupPowerObserver() = false;
>> 
>> It seems like we place the burden of knowing not to set the power observer on the various client processes. Maybe it would be better if it defaulted to false, and the main UIProcess initialization had to set it to true?
> 
> We only disable setup of the PowerObserver in the WebContent process. The WebContent process will be notified by the UI process about power events. For the other processes it will default to true, which gives the same behavior as before. I am perhaps not understanding your comment correctly, though. Does this address your comment?
> 
> Thanks for reviewing!

Oh, I didn't understand that. I thought we were blocking for all processes. In that case, I think your change makes sense.
Comment 9 Per Arne Vollan 2021-02-02 11:52:30 PST
Comment on attachment 419014 [details]
Patch

Thanks for reviewing!
Comment 10 EWS 2021-02-02 12:26:25 PST
commit-queue failed to commit attachment 419014 [details] to WebKit repository.
Comment 11 EWS 2021-02-02 15:15:47 PST
Committed r272241: <https://trac.webkit.org/changeset/272241>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 419014 [details].
Comment 12 Radar WebKit Bug Importer 2021-02-02 15:16:17 PST
<rdar://problem/73901378>