Bug 138155

Summary: [iOS] WebProcess needs to take a background task assertion to prevent being killed for "suspended with locked system files"
Product: WebKit Reporter: Daniel Bates <dbates>
Component: WebKit2Assignee: Daniel Bates <dbates>
Severity: Normal CC: aestes, andersca, ap, barraclough, beidson, ddkilzer, sam, thorton
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: iPhone / iPad   
OS: iOS 8.1   
Description Flags
Patch none

Description Daniel Bates 2014-10-28 16:02:38 PDT
Towards mitigating the web content process being killed when suspended holding lock files, we should have the web content process notify the UI process when it is holding such files so that the UI process can acquire a background task assertion to allow both to continue to run for an extended period of time in the background. In particular, we want to take a background task assertion when performing a SQLite transaction(s).
Comment 1 Daniel Bates 2014-10-28 16:03:22 PDT
Comment 2 Daniel Bates 2014-10-28 16:05:50 PDT
Created attachment 240575 [details]
Comment 3 Daniel Bates 2014-10-28 16:23:20 PDT
I open to suggestions on this patch.

The class WebSQLiteDatabaseTracker (included in the patch) isn't specific to iOS and hence can be used by other ports. At the time of writing, the iOS port is the only port that implements a non-trivial ProcessAssertion class to acquire a background task assertion. I guarded the instantiation of this class with PLATFORM(IOS) though I placed the class files in Source/WebKit2/WebProcess/WebCoreSupport/ (should I move them to an iOS-specific directory?) because I was unclear if it was acceptable to instantiate for all ports a WebSQLiteDatabaseTracker, which would send messages to the UIProcess (*), given that iOS is the only port that makes use of such messages. I was also unclear if we should either add a new compile-time guard for this feature to avoid the instantiation on non-iOS ports, say ENABLE_SQL_DATABASE_TRACKER, or if it's acceptable to instantiate WebSQLiteDatabaseTracker for all ports and have it only enabled for iOS (say, by not calling SQLDatabaseTracker::setClient() on non-iOS ports). Let me know if there is a preferred way to expose this functionality.

(*) I didn't measure the performance implications of such messaging.
Comment 4 Daniel Bates 2014-11-06 08:40:22 PST
Comment on attachment 240575 [details]

Clearing flags on attachment: 240575

Committed r175698: <http://trac.webkit.org/changeset/175698>
Comment 5 Daniel Bates 2014-11-06 08:40:26 PST
All reviewed patches have been landed.  Closing bug.