New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 694864 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Last visit 22 days ago
Closed: Mar 2017
Cc:
EstimatedDays: 2
NextAction: ----
OS: Android
Pri: 2
Type: Bug



Sign in to add a comment

Broken cancel() assumption on BackgroundLoader when saving causes copious amount of EXPIRED requests

Project Member Reported by chili@chromium.org, Feb 22 2017

Issue description

Rare case:

Repro:
- RequestCoordinator calls Cancel() while BL is in the middle of a SavePage
- BL sets "DeleteAfterSave" to be true and returns
- RequestCoordinator, thinking it's cancelled, then bombards BL with requests, but BL still working on actual save, so returns false
- Results in ~50 requests being EXPIRED within 10 seconds

Proposed short fix:
- in BackgroundLoaderOffliner::Cancel(), if a save operation is in progress, pass the WebContents pointer to something else that will be deleted later after Save completes.
- in BackgroundLoaderOffliner::OnPageSaved(), check to see if offline_id matches with current pending_request_.  If it doesn't, ignore the call and delete the pointer holding onto the old WebContents.

Longer-term fix/solution:
- We can have RequestCoordinator observe the SavePage calls so that the timer is only for page load rather than page load + save
- This can be further improved to start a new request once we start the Save process.
 

Comment 1 by chili@chromium.org, Feb 22 2017

On second thought, the proposed short-fix has the potential to run into an issue, where keeping 2 webcontents in memory (even for a short time) may raise our chances of OOM issues.  In effort to delay this until actual experimentation regarding 2+ background loaders, we have alternative fix:

- Offliner::Cancel() will be changed to async (takes a callback)
- in PrerenderOffliner::Cancel(), the callback will be called immediately
- in BackgroundLoaderOffliner::Cancel(), the callback will be called immediately if we're not in a Save() operation, or after the Save()
- in RequestCoordinator, when Cancel() is called, we will do whatever comes post-cancel inside the callback
Project Member

Comment 2 by bugdroid1@chromium.org, Mar 4 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/9f04f39d54f599a346c59670f91923f4af05e416

commit 9f04f39d54f599a346c59670f91923f4af05e416
Author: chili <chili@chromium.org>
Date: Sat Mar 04 01:23:56 2017

[Offline Pages] Turn Offliner::Cancel into an async operation to resolve conflicting assumptions
between the Offliner and RequestCoordinator.

Upon Offliner::Cancel, RequestCoordinator assumes that the offliner is free, but
offliner may be waiting until save operation to complete. This discrepancy causes
RequestCoordinator to bombard the offliner with all the pending requests, potentially
blocking the main thread for the save operation callback to be called and causing
all pending requests to be labeled as EXPIRED

BUG= 694864 

Review-Url: https://codereview.chromium.org/2715433006
Cr-Commit-Position: refs/heads/master@{#454740}

[modify] https://crrev.com/9f04f39d54f599a346c59670f91923f4af05e416/chrome/browser/android/offline_pages/background_loader_offliner.cc
[modify] https://crrev.com/9f04f39d54f599a346c59670f91923f4af05e416/chrome/browser/android/offline_pages/background_loader_offliner.h
[modify] https://crrev.com/9f04f39d54f599a346c59670f91923f4af05e416/chrome/browser/android/offline_pages/background_loader_offliner_unittest.cc
[modify] https://crrev.com/9f04f39d54f599a346c59670f91923f4af05e416/chrome/browser/android/offline_pages/prerendering_offliner.cc
[modify] https://crrev.com/9f04f39d54f599a346c59670f91923f4af05e416/chrome/browser/android/offline_pages/prerendering_offliner.h
[modify] https://crrev.com/9f04f39d54f599a346c59670f91923f4af05e416/chrome/browser/android/offline_pages/prerendering_offliner_unittest.cc
[modify] https://crrev.com/9f04f39d54f599a346c59670f91923f4af05e416/components/offline_pages/core/background/offliner.h
[modify] https://crrev.com/9f04f39d54f599a346c59670f91923f4af05e416/components/offline_pages/core/background/offliner_stub.cc
[modify] https://crrev.com/9f04f39d54f599a346c59670f91923f4af05e416/components/offline_pages/core/background/offliner_stub.h
[modify] https://crrev.com/9f04f39d54f599a346c59670f91923f4af05e416/components/offline_pages/core/background/request_coordinator.cc
[modify] https://crrev.com/9f04f39d54f599a346c59670f91923f4af05e416/components/offline_pages/core/background/request_coordinator.h

Comment 3 by chili@chromium.org, Mar 7 2017

Status: Fixed (was: Assigned)

Comment 4 by chili@chromium.org, Mar 9 2017

Labels: Merge-Request-58
Project Member

Comment 5 by sheriffbot@chromium.org, Mar 9 2017

Labels: -Merge-Request-58 Hotlist-Merge-Approved Merge-Approved-58
Your change meets the bar and is auto-approved for M58. Please go ahead and merge the CL to branch 3029 manually. Please contact milestone owner if you have questions.
Owners: amineer@(clank), cmasso@(bling), bhthompson@(cros), govind@(desktop)

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Project Member

Comment 6 by bugdroid1@chromium.org, Mar 10 2017

Labels: -merge-approved-58 merge-merged-3029
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/dedea73d3b658d752873cadbc162c84f88bcd878

commit dedea73d3b658d752873cadbc162c84f88bcd878
Author: Dmitry Titov <dimich@chromium.org>
Date: Fri Mar 10 01:24:15 2017

[Offline Pages] Turn Offliner::Cancel into an async operation to resolve conflicting assumptions between the Offliner and RequestCoordinator.

Upon Offliner::Cancel, RequestCoordinator assumes that the offliner is free, but
offliner may be waiting until save operation to complete. This discrepancy causes
RequestCoordinator to bombard the offliner with all the pending requests, potentially
blocking the main thread for the save operation callback to be called and causing
all pending requests to be labeled as EXPIRED

BUG= 694864 

Review-Url: https://codereview.chromium.org/2715433006
Cr-Commit-Position: refs/heads/master@{#454740}
(cherry picked from commit 9f04f39d54f599a346c59670f91923f4af05e416)

Review-Url: https://codereview.chromium.org/2744553005 .
Cr-Commit-Position: refs/branch-heads/3029@{#105}
Cr-Branched-From: 939b32ee5ba05c396eef3fd992822fcca9a2e262-refs/heads/master@{#454471}

[modify] https://crrev.com/dedea73d3b658d752873cadbc162c84f88bcd878/chrome/browser/android/offline_pages/background_loader_offliner.cc
[modify] https://crrev.com/dedea73d3b658d752873cadbc162c84f88bcd878/chrome/browser/android/offline_pages/background_loader_offliner.h
[modify] https://crrev.com/dedea73d3b658d752873cadbc162c84f88bcd878/chrome/browser/android/offline_pages/background_loader_offliner_unittest.cc
[modify] https://crrev.com/dedea73d3b658d752873cadbc162c84f88bcd878/chrome/browser/android/offline_pages/prerendering_offliner.cc
[modify] https://crrev.com/dedea73d3b658d752873cadbc162c84f88bcd878/chrome/browser/android/offline_pages/prerendering_offliner.h
[modify] https://crrev.com/dedea73d3b658d752873cadbc162c84f88bcd878/chrome/browser/android/offline_pages/prerendering_offliner_unittest.cc
[modify] https://crrev.com/dedea73d3b658d752873cadbc162c84f88bcd878/components/offline_pages/core/background/offliner.h
[modify] https://crrev.com/dedea73d3b658d752873cadbc162c84f88bcd878/components/offline_pages/core/background/offliner_stub.cc
[modify] https://crrev.com/dedea73d3b658d752873cadbc162c84f88bcd878/components/offline_pages/core/background/offliner_stub.h
[modify] https://crrev.com/dedea73d3b658d752873cadbc162c84f88bcd878/components/offline_pages/core/background/request_coordinator.cc
[modify] https://crrev.com/dedea73d3b658d752873cadbc162c84f88bcd878/components/offline_pages/core/background/request_coordinator.h

Sign in to add a comment