Closed Bug 1698601 Opened 5 years ago Closed 5 years ago

Carry-over restore data to the new BrowsingContext after a process swap

Categories

(Firefox :: Session Restore, task, P2)

task

Tracking

()

RESOLVED FIXED
89 Branch
Fission Milestone M7a
Tracking Status
firefox89 --- fixed

People

(Reporter: u608768, Assigned: annyG)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

With bug 1597499, we completely clear the new context's restore data after a swap. COOP loads will require us to carry this data over into the new process.

See https://phabricator.services.mozilla.com/D107883#inline-606067:

Can we file a follow-up to make restore data carry over to the new BrowsingContext after a swap? I think we want to support restoring data into e.g. a document with Cross-Origin-Opener-Policy, though we can do it after the change.

This is follow-up work. Doesn't need to block M7.

No longer blocks: fission-sessionstore
Assignee: kmadan → agakhokidze
Severity: -- → N/A
Status: NEW → ASSIGNED
Fission Milestone: --- → M7a
Priority: -- → P2

I then tried to run this test https://searchfox.org/mozilla-central/rev/bb37e6fe8bbe383a57a4ad21a201e26416613ca1/browser/components/sessionstore/test/browser_scrollPositions.js#163-238, by changing browser_scrollPositions_sample.html to have same-origin COOP headers.

We end up with the following test case: a COOP document is loaded in a tab, then we scroll, navigate to a second url, scroll there as well and then close the window. Then we undo closing of a window, check that the scroll position for second url has been restored, navigate back and check that scroll position for the COOP document has been restored. And this is where we fail - we can't restore scroll position for the COOP document.

I've printed state in SessionHistory in SessionStore's undoCloseWindow , and I see that in a case when first document is non-COOP, we have 'pressState' saved in data corresponding to the tab, however, we don't have pressState when the document we loaded is a COOP one (I check this in serializeEntry in SessionHistory.jsm.

The reason we don't have pressState is because in serializeEntry, shEntry.layoutHistoryState is null.

This might be the reason we are not restoring scroll position for the coop document once we navigate back to it. So I should probably be looking why shEntry.layoutHistoryState is null.

I wouldn't be surprised if in browsing context switch case call to SynchronizeLayoutHistoryState() doesn't succeed.
Parent side might still get the message, but https://searchfox.org/mozilla-central/rev/6309f663e7396e957138704f7ae7254c92f52f43/dom/ipc/ContentParent.cpp#7263 is possibly null.

This is the window state in undoCloseWindow when the document has no COOP headers

{
   "windows":[
      {
         "tabs":[
            {
               "entries":[
                  {
                     "url":"about:blank",
                     "title":"about:blank",
                     "cacheKey":0,
                     "ID":25,
                     "docshellUUID":"{c6e75e2b-e861-f046-86c8-6d4a35b0066f}",
                     "resultPrincipalURI":null,
                     "principalToInherit_base64":"eyIwIjp7IjAiOiJtb3otbnVsbHByaW5jaXBhbDp7OTc2ZWRkYWQtNjk5Yy00MjBlLWEwODEtMjlkZTBhY2Q2NmFlfSJ9fQ==",
                     "hasUserInteraction":false,
                     "triggeringPrincipal_base64":"eyIzIjp7fX0=",
                     "docIdentifier":25,
                     "persist":false
                  }
               ],
               "lastAccessed":1617041518373,
               "hidden":false,
               "searchMode":null,
               "userContextId":0,
               "attributes":{
                  
               },
               "image":null,
               "index":1,
               "requestedIndex":0
            },
            {
               "entries":[
                  {
                     "url":"https://example.com/browser/browser/components/sessionstore/test/browser_scrollPositions_sample.html",
                     "title":"browser_scrollPositions_sample.html",
                     "cacheKey":0,
                     "ID":26,
                     "docshellUUID":"{1aa7cf13-7d57-5f40-99ac-fde56e082fc8}",
                     "resultPrincipalURI":null,
                     "presState":[
                        {
                           "stateKey":"0>html>1",
                           "scroll":"10860,14700",
                           "scrollOriginDowngrade":false
                        }
                     ],
                     "hasUserInteraction":false,
                     "triggeringPrincipal_base64":"eyIzIjp7fX0=",
                     "docIdentifier":26,
                     "persist":true
                  },
                  {
                     "url":"https://example.com/browser/browser/components/sessionstore/test/browser_scrollPositions_sample2.html",
                     "title":"browser_scrollPositions_sample.html",
                     "cacheKey":0,
                     "ID":28,
                     "docshellUUID":"{1aa7cf13-7d57-5f40-99ac-fde56e082fc8}",
                     "resultPrincipalURI":null,
                     "hasUserInteraction":false,
                     "triggeringPrincipal_base64":"eyIzIjp7fX0=",
                     "docIdentifier":28,
                     "persist":true
                  }
               ],
               "lastAccessed":1617041516126,
               "hidden":false,
               "searchMode":null,
               "userContextId":0,
               "attributes":{
                  
               },
               "scroll":{
                  "scroll":"592,784"
               },
               "index":2,
               "requestedIndex":0,
               "image":null
            }
         ],
         "selected":1,
         "_closedTabs":[
            
         ],
         "width":1229,
         "height":691,
         "screenX":4,
         "screenY":4,
         "sizemode":"maximized",
         "sizemodeBeforeMinimized":"maximized",
         "zIndex":1,
         "title":"New Tab",
         "closedId":0
      }
   ]
}

and this is the data for a document with COOP headers

{
   "windows":[
      {
         "tabs":[
            {
               "entries":[
                  {
                     "url":"about:blank",
                     "title":"about:blank",
                     "cacheKey":0,
                     "ID":25,
                     "docshellUUID":"{fbb74a90-babe-8044-a7d0-418214bd4a48}",
                     "resultPrincipalURI":null,
                     "principalToInherit_base64":"eyIwIjp7IjAiOiJtb3otbnVsbHByaW5jaXBhbDp7MTIwNjc2MmEtODNlNy00YzM5LTliNzQtZWM2MjA4ZGEwMzBkfSJ9fQ==",
                     "hasUserInteraction":false,
                     "triggeringPrincipal_base64":"eyIzIjp7fX0=",
                     "docIdentifier":25,
                     "persist":false
                  }
               ],
               "lastAccessed":1617040981298,
               "hidden":false,
               "searchMode":null,
               "userContextId":0,
               "attributes":{
                  
               },
               "image":null,
               "index":1,
               "requestedIndex":0
            },
            {
               "entries":[
                  {
                     "url":"https://example.com/browser/browser/components/sessionstore/test/browser_scrollPositions_sample.html",
                     "title":"browser_scrollPositions_sample.html",
                     "cacheKey":0,
                     "ID":26,
                     "docshellUUID":"{f84e3e88-c0fa-cc48-81aa-61afc59b1c27}",
                     "resultPrincipalURI":null,
                     "hasUserInteraction":false,
                     "triggeringPrincipal_base64":"eyIzIjp7fX0=",
                     "docIdentifier":26,
                     "persist":true
                  },
                  {
                     "url":"https://example.com/browser/browser/components/sessionstore/test/browser_scrollPositions_sample2.html",
                     "title":"browser_scrollPositions_sample.html",
                     "cacheKey":0,
                     "ID":28,
                     "docshellUUID":"{f84e3e88-c0fa-cc48-81aa-61afc59b1c27}",
                     "resultPrincipalURI":null,
                     "hasUserInteraction":false,
                     "triggeringPrincipal_base64":"eyIzIjp7fX0=",
                     "docIdentifier":28,
                     "persist":true
                  }
               ],
               "lastAccessed":1617040979136,
               "hidden":false,
               "searchMode":null,
               "userContextId":0,
               "attributes":{
                  
               },
               "scroll":{
                  "scroll":"308,553"
               },
               "index":2,
               "requestedIndex":0,
               "image":null
            }
         ],
         "selected":1,
         "_closedTabs":[
            
         ],
         "width":1229,
         "height":691,
         "screenX":4,
         "screenY":4,
         "sizemode":"maximized",
         "sizemodeBeforeMinimized":"maximized",
         "zIndex":1,
         "title":"New Tab",
         "closedId":0
      }
   ]
}

Notice the presence of

                     "presState":[
                        {
                           "stateKey":"0>html>1",
                           "scroll":"10860,14700",
                           "scrollOriginDowngrade":false
                        }
                     ],

in the non-COOP document entry.

The call to https://searchfox.org/mozilla-central/rev/74d0efd1107a26f178b108b6a18a179e9b06547c/docshell/base/nsDocShell.cpp#3257-3258 succeeds, but when we arrive to the parent process, we check the BC and see that it has been discarded. This happens because nsDocShell::SynchronizeLayoutHistoryState takes place after the BC has been replaced. Indeed, the id of the BC that we send over the IPC matches the id of the current BC in CanonicalBrowsingContext::ReplacedBy that is getting replaced. Now I need to think about how we can pass that information differently.

Blocks: 1703351

Modify related test files to test documents with COOP headers enabled.

There are some tests that fail when run with new COOP configurations without
Fission enabled, prior to fixes that come in part 2. This means that some of
the COOP behaviour was already broken. Since fixing non-Fission COOP
behaviour prior to this patch is out of scope, I disabled new COOP
configuration for such tests by setting coopWithFissionOnly to true when
calling addTestCoopNonCoop().

Even with COOP headers disabled, some tests fail when the document they load
is served over httpS and not http. For a single test where this behaviour was
occuring prior to fixes in part 2, I have disabled such configuration by
setting useHttpWhenCoopDisabled to true when calling addTestCoopNonCoop(),
and filed 1703351 to fix such behaviour.

Also, make sure we update layout history state from docshell before we load a
new URI, as it might be our last chance to do so before a process swap.

Depends on D110993

Attachment #9213904 - Attachment description: WIP: Bug 1698601 - Part 1: Extend existing session store test files with COOP document testing → Bug 1698601 - Part 1: Extend existing session store test files with COOP document testing, r=smaug!
Attachment #9213905 - Attachment description: WIP: Bug 1698601 - Part 2: Carry over restore data to new context after a process swap → Bug 1698601 - Part 2: Carry over restore data to new context after a process swap, r=smaug!
Pushed by agakhokidze@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/55b243205236 Part 1: Extend existing session store test files with COOP document testing, r=smaug https://hg.mozilla.org/integration/autoland/rev/edfb69ecfb06 Part 2: Carry over restore data to new context after a process swap, r=smaug
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 89 Branch
No longer blocks: 1703351
See Also: → 1703351
Blocks: 1703351
See Also: 1703351
No longer blocks: 1703351
See Also: → 1703351
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: