Skip to content

Commit

Permalink
[ios] Don't trigger initial load when deserializing webStateList.
Browse files Browse the repository at this point in the history
Don't trigger the initial load for restored WebStates since the number
of WKWebViews is unbounded and may lead to an OOM crash. Instead,
disable and re-enable WebUsageEnabler SetTriggersInitialLoad

Bug: 1018337
Change-Id: Iaccecc3c0a1e68465b31b8503eee7b6d061d4f58
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1879205
Reviewed-by: Rohit Rao <rohitrao@chromium.org>
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709903}
  • Loading branch information
Justin Cohen authored and Commit Bot committed Oct 28, 2019
1 parent 120545c commit 5babe2d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ios/chrome/browser/tabs/tab_model.mm
Original file line number Diff line number Diff line change
Expand Up @@ -576,11 +576,20 @@ - (BOOL)restoreSessionWindow:(SessionWindowIOS*)window

_webStateList->PerformBatchOperation(
base::BindOnce(^(WebStateList* web_state_list) {
// Don't trigger the initial load for these restored WebStates since the
// number of WKWebViews is unbounded and may lead to an OOM crash.
WebStateListWebUsageEnabler* webUsageEnabler =
WebStateListWebUsageEnablerFactory::GetInstance()
->GetForBrowserState(_browserState);
const bool wasTriggersInitialLoadSet =
webUsageEnabler->TriggersInitialLoad();
webUsageEnabler->SetTriggersInitialLoad(false);
web::WebState::CreateParams createParams(_browserState);
DeserializeWebStateList(
web_state_list, window,
base::BindRepeating(&web::WebState::CreateWithStorageSession,
createParams));
webUsageEnabler->SetTriggersInitialLoad(wasTriggersInitialLoadSet);
}));

DCHECK_GT(_webStateList->count(), oldCount);
Expand Down

0 comments on commit 5babe2d

Please sign in to comment.