Bug 206077

Summary: MemoryPressureHandler should handle more than one callback
Product: WebKit Reporter: Ben Nham <nham>
Component: Web Template FrameworkAssignee: Ben Nham <nham>
Status: NEW    
Severity: Normal CC: cdumez, nham, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Ben Nham
Reported 2020-01-10 11:00:18 PST
Currently MemoryPressureHandler only stores a single callback lambda. This causes issues with the common pattern of setting the lambda for the singleton MemoryPressureHandler. For instance, all of these callsites do the equivalent of MemoryPressureHandler::singleton().setLowMemoryHandler in the UI process: 1. Legacy WebView init in WebInstallMemoryPressureHandler 2. WebProcessPool init in WebProcessPool::platformInitialize 3. +[NSAttributedString retrieveOrCreateWebview] used by all of the +[NSAttributedString loadFromHTMLWith...] APIs So for instance, if your app creates a WKWebView, and then calls +[NSAttributedString loadFromHTMLWithRequest:options:completionHandler:], then the WebProcessPool low memory handler installed by WKWebView gets overwritten by the NSAttributedString low memory handler, which seems undesirable. There's a FIXME about this in WebProcessPool, so we should probably make it harder to trample on an existing memory pressure handler, or just allow multiple callbacks to be attached to a single memory pressure handler.
Attachments
Radar WebKit Bug Importer
Comment 1 2020-01-10 11:00:46 PST
Note You need to log in before you can comment on or make changes to this bug.