Closed Bug 1654080 Opened 4 years ago Closed 4 years ago

Move SessionStorage to parent process

Categories

(Core :: Storage: localStorage & sessionStorage, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
83 Branch
Fission Milestone M6c
Tracking Status
firefox83 --- fixed

People

(Reporter: neha, Assigned: tt)

References

(Blocks 1 open bug)

Details

Attachments

(4 files, 4 obsolete files)

The initial plan was to make SessionStorage persistent (bug 1445464) for Fission but because that seems to be blocked on QuotaManager v4, we could do an intermediate step of moving SessionStorage state in parent which can be fetched over IPC.

Fission Milestone: --- → M6b
Assignee: nobody → echuang
Severity: -- → S3
Priority: -- → P1
Flags: needinfo?(jstutte)

Take this from Eden since he is on PTO.

Assignee: echuang → ttung

Spoke to Eden and I put my understanding below:

The issue here is that SessionHistory is going to move to the parent process and we need to provide a way for SessionStore to collect on the parent process.

SessionRestore now collects SessionStorage data for documents on the content process through a docshell tree. However, when it comes to a cross-origin iframe/docshell, SessionRestore cannot find the cross-origin/cross-process SessionStorage data properly.

The pref for testing SessionHistory in the parent process is fission.sessionHistoryInParent.

The remaining work here is to move the "collect" operation in SessionRestore to the parent process and check the failure tests on try.

try (without enabling the pref): https://treeherder.mozilla.org/#/jobs?repo=try&revision=10dade5427ae27833db3e638d30d2858e5f6a432

I will try to fix the existing test failures.
Then, polish patches.
Last, collect the SessionStroage on the parent process and push patches to try with enabling the pref.

It seems that it's related to/blocked bug 1572084

See Also: → 1572084

Have a meeting with Nika and Yaron today.

So, the main things that Nika was worried about actually are fixed by Yaron's previous work (https://bugzilla.mozilla.org/show_bug.cgi?id=1593246)
We still want to have a test to verify it and it should still be done in M6b.

The main work here that sync SessionStorage to the parent process for each operation or each a few seconds can be done in M6c rather than M6b

Blocks: 1660485

I have separated the work that should be done before M6b out to bug 1660485, so here is M6c.
And Yaron will work on it :)

Assignee: ttung → ytausky
Fission Milestone: M6b → M6c
No longer blocks: 1660485
See Also: → 1660485

Take this back from Yaron

Assignee: ytausky → ttung

I have a draft that sync SessionStorageCache's write operations (SetItem, RemoveItem, and Clear) to the parent process per stable state asynchronous. So that the parent process has copies of SessionStorageCaches. It uses LSValue, and LSWriteOptimizer so that the size of IPC messages should be reduced.

I will update the patch once I polish the patch.

D87197, D87198, and D87199 can achieve moving SessioinStorage to the parent process. However, we can reduce the changes by reusing the current code for SessionStorage and reduce the size of IPC messages by LSValue and LSWriteOptimizer.

I'm going to abandon D87197, D87198, and D87199.

Attachment #9170251 - Attachment is obsolete: true
Attachment #9170252 - Attachment is obsolete: true
Attachment #9170253 - Attachment is obsolete: true

Before we start reviewing the patches, could you provide a high level description of the approach ?
It doesn't have to be long, just a few sentences, like what top level protocol will be used for communication, what will be re-used from LSNG, etc.

(In reply to Jan Varga [:janv] from comment #19)

Before we start reviewing the patches, could you provide a high level description of the approach ?
It doesn't have to be long, just a few sentences, like what top level protocol will be used for communication, what will be re-used from LSNG, etc.

Sure!

Goal:
Move SessionStorage to parent process because SessionStore/SessionHistory will need to access SessionStorage data for any origin on the parent process during runtime.

What we have right now:

  • All sessionStorage data is sent from a content process to the parent process when the content process is shutting down
  • SessionStorage data is sent from the parent process to content when the corresponding content process is re-created

Changes here:

  • D89340: SessionStorage data for an origin is sent from a content process to the parent process per write operation (SetItem, RemoveItem, and Clear)
  • D89341: Similar to LSSnapshot, accumulate SessionStorage data for an origin and send them to the parent process in a stable state.
  • D89342: Use LSWriteOptimizer and LSValue to coalesce SessionStorage data. So that the IPC message size can be reduced.

Overall/after applying current changes:

  • Once there is a write operation for SessionStorage, SessionStorage will accumulate the wirteInfos until the next stable state and then send them together to the parent process.
  • While a current process is shutting down, SessionStorage doesn't need to send all its session storage to the parent process since we should have had a snapshot of SessionStorageCaches for the content process in the parent process.

what top level protocol will be used for communication

The IPC protocol is still the same. (PContent).
However, the content of the IPC message sent from content process to the parent process is changed to SSWriteInfo.

what will be re-used from LSNG

LSValue, and LSWriteOptimizer are re-used.
The concept of LSSnapshot is re-used as well, but the functionalities are divided into SessionStorageSyncHelper and SeesionStorageCache.

I will update the comment in SessionStorageManager once the changes are finalized (the patches are reviewed)

So, it's almost like LSNG regarding communication between parent/child, except:

  • PContent is used instead of PBackground
  • All data is sent from parent to content at once (during process creation) instead of using a snapshot which would load data on demand.

I'll take a closer look, but it looks this could be a good compromise for now.

(In reply to Jan Varga [:janv] from comment #22)

So, it's almost like LSNG regarding communication between parent/child, except:

  • PContent is used instead of PBackground
  • All data is sent from parent to content at once (during process creation) instead of using a snapshot which would load data on demand.

I'll take a closer look, but it looks this could be a good compromise for now.

Right, and thank you!

Depends on D89342

Attachment #9174166 - Attachment description: Bug 1654080 - Sync SessionStorageCache every stable state if there is a write operation; → Bug 1654080 - Have a helper to make the sync less often by syncing SessionStorageCache in the next stable state;
Status: NEW → ASSIGNED
Flags: needinfo?(jstutte)
Attachment #9170251 - Attachment is obsolete: false
Attachment #9170251 - Attachment is obsolete: true
Attachment #9170252 - Attachment is obsolete: false
Attachment #9170252 - Attachment is obsolete: true
Attachment #9170253 - Attachment is obsolete: false
Attachment #9170253 - Attachment is obsolete: true
Attachment #9174166 - Attachment description: Bug 1654080 - Have a helper to make the sync less often by syncing SessionStorageCache in the next stable state; → Bug 1654080 - Make SessionStorage sync less often by synchronizing SessionStorageCache at the next stable state;
Attachment #9174167 - Attachment description: Bug 1654080 - Use LSValue and LSWriteOptimizer to reduce the size of IPC messages; → Bug 1654080 - Use LSValue and LSWriteOptimizer to send data changes instead of sending all data;
Attachment #9174167 - Attachment description: Bug 1654080 - Use LSValue and LSWriteOptimizer to send data changes instead of sending all data; → Bug 1654080 - Use LSWriteOptimizer to send data changes instead of sending all data;
Attached patch impl.diffSplinter Review
Attachment #9174184 - Attachment is obsolete: true
Attachment #9174184 - Attachment is obsolete: false
Blocks: 1668505
Blocks: 1668506
Attachment #9174167 - Attachment description: Bug 1654080 - Use LSWriteOptimizer to send data changes instead of sending all data; → Bug 1654080 - Use PBackground for syncing SessionStorageCache and use LSWriteOptimizer to send data changes;
Attachment #9174184 - Attachment is obsolete: true

lastest try and it looks good: https://treeherder.mozilla.org/#/jobs?repo=try&revision=61c6b1c638fad3b1991327413fa0e7e39c94f03e
I will land the patches after getting r+ from all reviewers .

Pushed by ttung@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/eccd53004a47 Sync SessionStorageCache to the parent process per write operation; r=dom-workers-and-storage-reviewers,janv https://hg.mozilla.org/integration/autoland/rev/e04b853cf5d2 Make SessionStorage sync less often by synchronizing SessionStorageCache at the next stable state; r=dom-workers-and-storage-reviewers,janv https://hg.mozilla.org/integration/autoland/rev/44541aaaa9f0 Use PBackground for syncing SessionStorageCache and use LSWriteOptimizer to send data changes; r=dom-workers-and-storage-reviewers,janv,nika
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 83 Branch
Blocks: 1671162
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: