When a web page starts a XHR request after the page is finished loading, we should take a background activity token and hold it until the request is cancelled or finished. Otherwise the WebContent process could be suspended since its activity token could drop to 0 after this point.
<rdar://problem/18846532>
Created attachment 255795 [details] Patch.
Hmm, this fix could have the side effect of holding the web process too long if there is a long lasting XHR request. I need to work on a better fix.
Update the title to reflect the real problem.
Created attachment 255810 [details] Patch v2.
Comment on attachment 255810 [details] Patch v2. View in context: https://bugs.webkit.org/attachment.cgi?id=255810&action=review > Source/WebKit2/UIProcess/WebPageProxy.h:821 > + void processWillBecomeForground(); "processWillBecomeForground" -> processWillBecomeForeground
Comment on attachment 255810 [details] Patch v2. I don’t know which state transitions are possible. Is it a concern that the outcomes of the following transitions are different? Foreground -> Suspended -> Background Foreground -> Background Is it a concern that this transition will fail to restore the state? Foreground -> Suspended -> Background -> Suspended -> Foreground (because on the second entry into Suspended, m_hasNetworkRequestsOnSuspended will change to false)
(In reply to comment #7) > Comment on attachment 255810 [details] > Patch v2. > > I don’t know which state transitions are possible. Is it a concern that the > outcomes of the following transitions are different? > Foreground -> Suspended -> Background > Foreground -> Background I could be wrong, but based on code inspection and my own test, I didn't find a scenario where the web process could go from Suspended to Background. > > Is it a concern that this transition will fail to restore the state? > Foreground -> Suspended -> Background -> Suspended -> Foreground > (because on the second entry into Suspended, m_hasNetworkRequestsOnSuspended > will change to false) Again, this ties to whether Suspended -> Background transition is possible. Thanks for the review! I will fix the typo on commit.
Created attachment 255956 [details] Patch for landing.
Comment on attachment 255956 [details] Patch for landing. Clearing flags on attachment: 255956 Committed r186200: <http://trac.webkit.org/changeset/186200>
All reviewed patches have been landed. Closing bug.