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

Issue 684916 link

Starred by 2 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug

Blocked on:
issue 638276

Blocking:
issue 705079
issue 634832



Sign in to add a comment

Saved offline snapshots might be deleted when attempting to update them.

Project Member Reported by carlosk@chromium.org, Jan 25 2017

Issue description

Because of the the snapshot saving process works, where it first deletes existing page to only then save a new one, it might cause offline pages to be lost and left without the newer replacement in case the new snapshot fails to be saved.

This affects both Downloads snapshot and last_n snapshots. The former is the more serious case as it will come as a complete surprise to the user: they requested the page to be offlined, received confirmation that it was saved but if this bug happens that saved page will be gone.

For each of the snapshot requesters a different solution is more appropriate. In both cases snapshot deletion should be dissociated from snapshot creation (it is currently a pre-step). Beyond that:

- For last_n: previously existing pages should be deleted when navigating to another page or when the tab is closed. There will be other cases where a TabHelper implementation will not be enough to do the proper cleanup so we also need scheduled maintenance to do it and a more robust way to query the model about valid last_n pages.

- For Downloads: it should be possible to directly update the existing offline model entry to avoid the problematic delete-then-create process. This update ability doesn't yet exist but it was already planned to be implemented at some point.

Note: we're exclusively dealing here for the current last_n focus where N = 1.
 
Cc: carlosk@chromium.org
 Issue 655697  has been merged into this issue.
Status: Assigned (was: Untriaged)
Blockedon: 638276
Blocking: 634832
Linking related issues.
Cc: vitaliii@chromium.org
Labels: M-58
Even though this is an existing issue I would like to have this solved before M-58, at least for the last_n case.
Blocking: 659205
Cc: romax@chromium.org
Status: Started (was: Assigned)
I'm starting to work on the last_n part of this issue.

Note that this change will make the logic a bit less robust IRT leaving extra last_n snapshots behind. The reason being that we will first create the snapshot and only then delete any previous existing one only if it was a successful save (currently the order is reversed, hence this issue). So if a event out of our control happens -- i.e. a crash -- between these steps, two snapshots will exist for the same tab.

However this should not be a problem because we do have cleanup procedures to handle leftover snapshots:
- There already is a periodical cleanup task that runs upon Chrome start to detect lingering last_n snapshots.
- When either CL [1] or [2] lands another cleanup step will also run upon tab closure.

Please dewittj@ and romax@, correct me if I'm wrong here.

[1] https://codereview.chromium.org/2684973014/

[2] https://codereview.chromium.org/2706343007/

Comment 7 by romax@chromium.org, Feb 25 2017

If you're talking about consistency check yes there's a cleanup procedure to handle leftover snapshots. However it only takes care of:
1. you have a file on disk, but no entry in the database, delete the file
2. you have an entry in database, but no file on disk, delete the database entry.

it's here: https://cs.chromium.org/chromium/src/components/offline_pages/core/offline_page_model_impl.cc?rcl=1aa3f1c709ebdc77c75fa90263b983d181af91e1&l=984
I talked with romax@ offline and figured out why I was a bit confused. There are in fact two different cleanup tasks. The one that runs when Chrome is started and loads the Offline Model is a "consistency check". That's what he  described in #7.

The one I was interested at runs continuously but throttled by Offline storage usage and a timeout. This one does cleanup expired offline pages, what would take care of any last_n pages left behind after 2 days (current expiration time for last_n pages).
Summary: Saved offline snapshots might be deleted when attempting to update them. (was: Saved offline snaphosts might be deleted when attempting to update them.)
Blocking: 705079
Status: Assigned (was: Started)
Labels: -Pri-3 -M-58 Pri-2
This is a good candidate to fix soon.
Si disattivato e non posso più attivarlo
Blocking: -659205
This does not block NTP anymore.
Labels: Hotlist-Fixit
Cc: -vitaliii@chromium.org
This has indeed evolved to be two separate issues:

*Last_n*
Presents the simpler fix as (hopefully) the main thing we need to do is to move the deletion of the previous snapshot to be the last step in the callbacks chain started in `WebContentsWasHidden`.

If anything happens and we end up with two pages, our interceptor should favor opening the last one, which is the desired behavior.

Another adequate change would be to update the "previous pages deletion step" in RecentTabHelper::DidFinishNavigation to delete any and all previous last_n pages bound to the assigned tab in case of a successful navigation (not to an error page for instance). This should lessen any privacy concern matters IRT leaving behind pages for previously navigated URLs in that tab.


*Downloads*
In this case we probably want to create a new Offline Page Model task that allows replacing an offline page with a newly generated archive. This is to avoid the current problem of losing the previously saved page in case the new save fails but also to avoid the user ending up with two manually downloaded pages instead.

This logic might already have been implemented during the development of offline pages sharing as the "publishing of a private page" has to deal with a similar problem.

Sign in to add a comment