Bug 212619

Summary: [iOS] WKProcessAssertionBackgroundTaskManager incorrectly ignores expiration notifications for daemons
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: WebKit2Assignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, ggaren, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 212615    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Description Chris Dumez 2020-06-01 16:49:08 PDT
WKProcessAssertionBackgroundTaskManager incorrectly ignores expiration notifications for daemons, because it rely on visibility to make decisions.
Comment 1 Chris Dumez 2020-06-01 16:58:53 PDT
Created attachment 400770 [details]
Patch
Comment 2 Chris Dumez 2020-06-01 17:01:07 PDT
Created attachment 400771 [details]
Patch
Comment 3 Chris Dumez 2020-06-02 08:33:38 PDT
Created attachment 400825 [details]
Patch
Comment 4 Chris Dumez 2020-06-02 08:41:16 PDT
Created attachment 400828 [details]
Patch
Comment 5 Chris Dumez 2020-06-02 08:46:05 PDT
Created attachment 400830 [details]
Patch
Comment 6 Alex Christensen 2020-06-02 17:31:20 PDT
Comment on attachment 400830 [details]
Patch

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

> Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm:53
> +    return [[[RBSProcessHandle currentProcess] activeLimitations] runTime] != RBSProcessTimeLimitationNone;

It might be worth putting this inside a std::call_once, because this should never change, right?

> Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm:241
> +    auto remainingTime = [[[RBSProcessHandle currentProcess] activeLimitations] runTime];

Can we use dot syntax for any of this?
Comment 7 Chris Dumez 2020-06-02 17:33:21 PDT
Comment on attachment 400830 [details]
Patch

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

>> Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm:53
>> +    return [[[RBSProcessHandle currentProcess] activeLimitations] runTime] != RBSProcessTimeLimitationNone;
> 
> It might be worth putting this inside a std::call_once, because this should never change, right?

It totally changes. For example, for applications, based on app visibility. The timer should only get started after the app gets backgrounded and thus this would return RBSProcessTimeLimitationNone when foreground and a positive value when background.

>> Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm:241
>> +    auto remainingTime = [[[RBSProcessHandle currentProcess] activeLimitations] runTime];
> 
> Can we use dot syntax for any of this?

ok
Comment 8 Chris Dumez 2020-06-02 18:50:03 PDT
Created attachment 400875 [details]
Patch
Comment 9 EWS 2020-06-02 22:29:18 PDT
Committed r262477: <https://trac.webkit.org/changeset/262477>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 400875 [details].
Comment 10 Radar WebKit Bug Importer 2020-06-02 22:30:16 PDT
<rdar://problem/63909510>