Closed Bug 1602501 Opened 5 years ago Closed 4 years ago

[SessionHistory in the parent] One failure in browser_swapDocShells.js

Categories

(Core :: DOM: Navigation, defect, P2)

defect

Tracking

()

RESOLVED FIXED
87 Branch
Fission Milestone M6c
Tracking Status
firefox87 --- fixed

People

(Reporter: alchen, Assigned: kmag)

References

(Blocks 2 open bugs)

Details

Attachments

(3 files)

When doing mochitest with attachment 9114933 [details] (patch of bug 1507287) and pref " fission.sessionHistoryInParent", there is still one failure in browser_swapDocShells.js.

TEST-UNEXPECTED-FAIL | browser/components/sessionstore/test/browser_swapDocShells.js | tab was duplicated - Got about:blank, expected about:mozilla

Depends on: 1507287

The STR is like below:

  1. Open a tab (about:mozilla)
    let tab = (gBrowser.selectedTab = BrowserTestUtils.addTab(
    gBrowser,
    "about:mozilla"
    ));
  2. Use gBrowser.replaceTabWithWindow() with the tab we just open
    let win = gBrowser.replaceTabWithWindow(tab);
  3. Make sure the tab is loaded with URL "about:mozilla"
  4. Duplicate the tab in step 3.
  5. Check the URL after the tab is restored.

The problem of this failure is we cannot get sessionHistory when trying to duplicate the tab in step 4.
So we have a blank page in the end.

Assignee: nobody → alchen

By disabling the session history in the parent, we can know the correct behavior.

[pref off]
Right after "duplicateTabIn()", we get historychange data from child process.
The data is collected from ContentSessionStore.jsm.
Then we use the data to restoreHistory.
In the end, restoreTabContent will use history.reloadCurrentEntry to reload the current history entry.

0:12.05 GECKO(19446) -----browser_swapDocShell.js before duplicateTabIn
0:12.11 GECKO(19446) ====DEBUG==== @ SessionStore.jsm updateSessionStoreFromTablistener() without aData.sHistoryNeeded.!!!
0:12.14 GECKO(19446) -----browser_swapDocShell.js after duplicateTabIn
0:12.17 GECKO(19446) ====DEBUG==== @ ContentSessionStore.jsm receiveMessage(SessionStore:flush), data={"id":1}!!!
0:12.18 GECKO(19446) ====DEBUG==== @ SessionStore.jsm receiveMessage(SessionStore:update), data={"data":{"historychange":{"entries":[{"url":"about:mozilla","title":"The Book of Mozilla, 11:14","cacheKey":0,"ID":0,"docshellUUID":"{d5e8f84b-48bd-4186-a7e4-7a5e31c40383}","resultPrincipalURI":null,"triggeringPrincipal_base64":"eyIzIjp7fX0=","docIdentifier":1,"persist":true}],"userContextId":0,"requestedIndex":0,"index":1,"fromIdx":-1}},"flushID":1,"isFinal":false,"epoch":0}!!!
0:12.26 GECKO(19446) ====DEBUG==== @ ContentSessionStore.jsm receiveMessage(SessionStore:restoreHistory), data={"tabData":{"entries":[{"url":"about:mozilla","title":"The Book of Mozilla, 11:14","cacheKey":0,"ID":0,"docshellUUID":"{d5e8f84b-48bd-4186-a7e4-7a5e31c40383}","resultPrincipalURI":null,"triggeringPrincipal_base64":"eyIzIjp7fX0=","docIdentifier":1,"persist":true}],"lastAccessed":1575991322724,"hidden":false,"attributes":{},"index":1,"userContextId":0,"image":"","userTypedValue":"","userTypedClear":0},"epoch":1,"isRemotenessUpdate":true}!!!
0:12.26 GECKO(19446) ====DEBUG==== @ ContentSessionStore.jsm restoreHistory(tabData={"entries":[{"url":"about:mozilla","title":"The Book of Mozilla, 11:14","cacheKey":0,"ID":0,"docshellUUID":"{d5e8f84b-48bd-4186-a7e4-7a5e31c40383}","resultPrincipalURI":null,"triggeringPrincipal_base64":"eyIzIjp7fX0=","docIdentifier":1,"persist":true}],"lastAccessed":1575991322724,"hidden":false,"attributes":{},"index":1,"userContextId":0,"image":"","userTypedValue":"","userTypedClear":0}!!!
0:12.29 GECKO(19446) ====DEBUG==== @ SessionStore.jsm receiveMessage(SessionStore:restoreHistoryComplete), data={"epoch":1,"isRemotenessUpdate":true}!!!
0:12.30 GECKO(19446) ====DEBUG==== @ ContentSessionStore.jsm receiveMessage(SessionStore:restoreTabContent), data={"isRemotenessUpdate":true,"reason":0}!!!
0:12.30 GECKO(19446) ====DEBUG==== @ ContentRestore.jsm restoreTabContent(), TabData.entries=[{"url":"about:mozilla","title":"The Book of Mozilla, 11:14","cacheKey":0,"ID":0,"docshellUUID":"{d5e8f84b-48bd-4186-a7e4-7a5e31c40383}","resultPrincipalURI":null,"triggeringPrincipal_base64":"eyIzIjp7fX0=","docIdentifier":1,"persist":true}]!!!
0:12.37 GECKO(19446) ====DEBUG==== @ SessionStore.jsm receiveMessage(SessionStore:restoreTabContentStarted), data={"epoch":1,"isRemotenessUpdate":true,"reason":0}!!!
0:12.42 GECKO(19446) ====DEBUG==== @ SessionStore.jsm receiveMessage(SessionStore:restoreTabContentComplete), data={"epoch":1,"isRemotenessUpdate":true}!!!
0:12.42 GECKO(19446) -----browser_swapDocShell.js after promiseTabRestored
0:12.42 PASS tab was duplicated -

[pref on]
When pref on, we need to collect sessionHistory change in the parent process.
As you can see in the log, we cannot get sessionHistory object successfully due to aBrowser.frameLoader is null in this case.
So there is no sessionHistoryChanges in the sessionStore data.
In the end, there's nothing to restore, we get a blank page.

0:11.56 GECKO(16525) -----browser_swapDocShell.js before duplicateTabIn
0:11.61 GECKO(16525) ====DEBUG==== @ SessionStore.jsm updateSessionStoreFromTablistener() with aData.sHistoryNeeded.!!!
0:11.61 GECKO(16525) ====DEBUG==== @ SessionStore.jsm updateSessionStoreFromTablistener() but no SHlistener. Add again!!!
0:11.61 GECKO(16525) ====DEBUG==== addSHistoryListener(), aBrowser.frameLoader not exists,browser.currentURI.displaySpec=null
0:11.61 GECKO(16525) ====DEBUG==== @ SessionStore.jsm updateSessionStoreFromTablistener() with sHistoryNeeded, but no sHlistener!!!
0:11.63 GECKO(16525) -----browser_swapDocShell.js after duplicateTabIn
0:11.67 GECKO(16525) ====DEBUG==== @ ContentSessionStore.jsm receiveMessage(SessionStore:flush), data={"id":1}!!!
0:11.67 GECKO(16525) ====DEBUG==== @ SessionStore.jsm receiveMessage(SessionStore:update), data={"data":{},"flushID":1,"isFinal":false,"epoch":0}!!!
0:11.83 GECKO(16525) ====DEBUG==== @ SessionStore.jsm receiveMessage(SessionStore:AddSHistoryListener), data=null!!!
0:11.85 INFO Console message: SessionStore: [process-switch]: cannot find tabbrowser for loading tab - ignoring
0:11.97 GECKO(16525) ====DEBUG==== @ SessionStore.jsm receiveMessage(SessionStore:AddSHistoryListener), data=null!!!
0:12.00 GECKO(16525) ====DEBUG==== @ ContentSessionStore.jsm receiveMessage(SessionStore:restoreHistory), data={"tabData":{"entries":[],"lastAccessed":1575991224617,"hidden":false,"attributes":{},"image":null,"index":1,"pinned":false},"epoch":1}!!!
0:12.00 GECKO(16525) ====DEBUG==== @ ContentSessionStore.jsm restoreHistory(tabData={"entries":[],"lastAccessed":1575991224617,"hidden":false,"attributes":{},"image":null,"index":1,"pinned":false}!!!
0:12.00 GECKO(16525) ====DEBUG==== @ ContentSessionStore.jsm receiveMessage(SessionStore:restoreTabContent), data={"isRemotenessUpdate":false,"reason":0}!!!
0:12.01 GECKO(16525) ====DEBUG==== @ SessionStore.jsm receiveMessage(SessionStore:restoreSHistoryInParent), data={"epoch":1,"tabData":{"entries":[],"lastAccessed":1575991224617,"hidden":false,"attributes":{},"image":null,"index":1,"pinned":false}}!!!
0:12.01 GECKO(16525) ====DEBUG==== @ ContentSessionStore.jsm receiveMessage(SessionStore:restoreHistoryBottomHalf), data={}!!!
0:12.02 GECKO(16525) ====DEBUG==== @ SessionStore.jsm receiveMessage(SessionStore:restoreHistoryComplete), data={"epoch":1}!!!
0:12.02 GECKO(16525) ====DEBUG==== @ SessionStore.jsm receiveMessage(SessionStore:removeRestoreListener), data={"epoch":1}!!!
0:12.02 GECKO(16525) ====DEBUG==== @ ContentRestore.jsm restoreTabContent(), no TabData.entries there's nothing to restore, we should still blank the page!!!
0:12.04 GECKO(16525) ====DEBUG==== @ SessionStore.jsm receiveMessage(SessionStore:restoreTabContentStarted), data={"epoch":1,"isRemotenessUpdate":false,"reason":0}!!!
0:12.08 GECKO(16525) ====DEBUG==== @ SessionStore.jsm receiveMessage(SessionStore:restoreTabContentComplete), data={"epoch":1,"isRemotenessUpdate":false}!!!
0:12.08 GECKO(16525) -----browser_swapDocShell.js after promiseTabRestored
0:12.08 FAIL tab was duplicated - Got about:blank, expected about:mozilla

Assignee: alchen → nobody
Attached file Base_PATCH_For_THIS_BUG (deleted) —

Tracking for Fission mochitests (M4.1)

Fission Milestone: --- → M4.1

Since this is only with fission.sessionHistoryInParent which isn't enabled by default yet, it does not belong to M4.1. Moving this to M5.

Assignee: nobody → alchen
Status: NEW → ASSIGNED
Fission Milestone: M4.1 → M5
Priority: -- → P2

If I changed the url from "about:mozilla" to "https://example.org", we can collect sessionHistory changes successfully.
In the end, we can use this history change in the session store data to duplicate the tab.

(In reply to Alphan Chen [:alchen] from comment #5)

[pref on]
When pref on, we need to collect sessionHistory change in the parent process.
As you can see in the log, we cannot get sessionHistory object successfully due to aBrowser.frameLoader is null in this case.
So there is no sessionHistoryChanges in the sessionStore data.
In the end, there's nothing to restore, we get a blank page.

0:11.56 GECKO(16525) -----browser_swapDocShell.js before duplicateTabIn
0:11.61 GECKO(16525) ====DEBUG==== @ SessionStore.jsm updateSessionStoreFromTablistener() with aData.sHistoryNeeded.!!!
0:11.61 GECKO(16525) ====DEBUG==== @ SessionStore.jsm updateSessionStoreFromTablistener() but no SHlistener. Add again!!!
0:11.61 GECKO(16525) ====DEBUG==== addSHistoryListener(), aBrowser.frameLoader not exists,browser.currentURI.displaySpec=null
0:11.61 GECKO(16525) ====DEBUG==== @ SessionStore.jsm updateSessionStoreFromTablistener() with sHistoryNeeded, but no sHlistener!!!

0:11.94 GECKO(22071) ====DEBUG==== @SessionStore.jsm updateSessionStoreFromTablistener()------- aData={"data":{"scroll":null,"storage":null,"historychange":{"entries":[{"url":"https://example.org/","title":"mochitest index /","cacheKey":0,"ID":8,"docshellUUID":"{b8494fed-2a34-4c1c-b443-4e13b9f72ed9}","originalURI":"https://example.org/","resultPrincipalURI":"https://example.org/","loadReplace":false,"loadReplace2":true,"principalToInherit_base64":"eyIwIjp7IjAiOiJtb3otbnVsbHByaW5jaXBhbDp7NjQ2MmEzMTEtODVlYi00MGI4LTkwMGMtNDE1MjFlYTNkNzA3fSJ9fQ==","storagePrincipalToInherit_base64":"eyIwIjp7IjAiOiJtb3otbnVsbHByaW5jaXBhbDp7NjQ2MmEzMTEtODVlYi00MGI4LTkwMGMtNDE1MjFlYTNkNzA3fSJ9fQ==","triggeringPrincipal_base64":"eyIzIjp7fX0=","docIdentifier":8589934593,"persist":true}],"userContextId":0,"requestedIndex":0,"index":1,"fromIdx":-1}},"flushID":1,"isFinal":false,"epoch":0}

0:11.63 GECKO(16525) -----browser_swapDocShell.js after duplicateTabIn
0:11.67 GECKO(16525) ====DEBUG==== @ ContentSessionStore.jsm receiveMessage(SessionStore:flush), data={"id":1}!!!
0:11.67 GECKO(16525) ====DEBUG==== @ SessionStore.jsm receiveMessage(SessionStore:update), data={"data":{},"flushID":1,"isFinal":false,"epoch":0}!!!
0:11.83 GECKO(16525) ====DEBUG==== @ SessionStore.jsm receiveMessage(SessionStore:AddSHistoryListener), data=null!!!
0:11.85 INFO Console message: SessionStore: [process-switch]: cannot find tabbrowser for loading tab - ignoring
0:11.97 GECKO(16525) ====DEBUG==== @ SessionStore.jsm receiveMessage(SessionStore:AddSHistoryListener), data=null!!!
0:12.00 GECKO(16525) ====DEBUG==== @ ContentSessionStore.jsm receiveMessage(SessionStore:restoreHistory), data={"tabData":{"entries":[],"lastAccessed":1575991224617,"hidden":false,"attributes":{},"image":null,"index":1,"pinned":false},"epoch":1}!!!
0:12.00 GECKO(16525) ====DEBUG==== @ ContentSessionStore.jsm restoreHistory(tabData={"entries":[],"lastAccessed":1575991224617,"hidden":false,"attributes":{},"image":null,"index":1,"pinned":false}!!!
0:12.00 GECKO(16525) ====DEBUG==== @ ContentSessionStore.jsm receiveMessage(SessionStore:restoreTabContent), data={"isRemotenessUpdate":false,"reason":0}!!!
0:12.01 GECKO(16525) ====DEBUG==== @ SessionStore.jsm receiveMessage(SessionStore:restoreSHistoryInParent), data={"epoch":1,"tabData":{"entries":[],"lastAccessed":1575991224617,"hidden":false,"attributes":{},"image":null,"index":1,"pinned":false}}!!!

0:12.34 GECKO(22071) ====DEBUG==== @ SessionStore.jsm receiveMessage(SessionStore:restoreSHistoryInParent), data={"epoch":1,"tabData":{"entries":[{"url":"https://example.org/","title":"mochitest index /","cacheKey":0,"ID":8,"docshellUUID":"{b8494fed-2a34-4c1c-b443-4e13b9f72ed9}","originalURI":"https://example.org/","resultPrincipalURI":"https://example.org/","loadReplace":false,"loadReplace2":true,"principalToInherit_base64":"eyIwIjp7IjAiOiJtb3otbnVsbHByaW5jaXBhbDp7NjQ2MmEzMTEtODVlYi00MGI4LTkwMGMtNDE1MjFlYTNkNzA3fSJ9fQ==","storagePrincipalToInherit_base64":"eyIwIjp7IjAiOiJtb3otbnVsbHByaW5jaXBhbDp7NjQ2MmEzMTEtODVlYi00MGI4LTkwMGMtNDE1MjFlYTNkNzA3fSJ9fQ==","triggeringPrincipal_base64":"eyIzIjp7fX0=","docIdentifier":8589934593,"persist":true}],"lastAccessed":1577111186043,"hidden":false,"attributes":{},"image":null,"userContextId":0,"index":1,"requestedIndex":0,"pinned":false}}!!!

0:12.01 GECKO(16525) ====DEBUG==== @ ContentSessionStore.jsm receiveMessage(SessionStore:restoreHistoryBottomHalf), data={}!!!
0:12.02 GECKO(16525) ====DEBUG==== @ SessionStore.jsm receiveMessage(SessionStore:restoreHistoryComplete), data={"epoch":1}!!!
0:12.02 GECKO(16525) ====DEBUG==== @ SessionStore.jsm receiveMessage(SessionStore:removeRestoreListener), data={"epoch":1}!!!
0:12.02 GECKO(16525) ====DEBUG==== @ ContentRestore.jsm restoreTabContent(), no TabData.entries there's nothing to restore, we should still blank the page!!!
0:12.04 GECKO(16525) ====DEBUG==== @ SessionStore.jsm receiveMessage(SessionStore:restoreTabContentStarted), data={"epoch":1,"isRemotenessUpdate":false,"reason":0}!!!
0:12.08 GECKO(16525) ====DEBUG==== @ SessionStore.jsm receiveMessage(SessionStore:restoreTabContentComplete), data={"epoch":1,"isRemotenessUpdate":false}!!!
0:12.08 GECKO(16525) -----browser_swapDocShell.js after promiseTabRestored
0:12.08 FAIL tab was duplicated - Got about:blank, expected about:mozilla

Add one more finding,

If we add a "TabStateFlusher.flush" before "gBrowser.replaceTabWithWindow(tab)", the test can pass.
https://searchfox.org/mozilla-central/rev/8f7b017a31326515cb467e69eef1f6c965b4f00e/browser/components/sessionstore/test/browser_swapDocShells.js#10

It means that we force collecting the session history change before doing "swap docshell".
In this case, we can collect the session history successfully.
And we restore session history correctly by this data.

However, after doing "swap docshell" we cannot get session history object.

  • In the begining, the reason is "no frameloader".
    0:11.61 GECKO(16525) ====DEBUG==== addSHistoryListener(), aBrowser.frameLoader not exists,browser.currentURI.displaySpec=null
  • Recently the reason becomes "no browsingContext". (not sure it is caused timing or code base change)
    0:11.64 GECKO(12863) ====DEBUG==== addSHistoryListener(), aBrowser.fl.browsingContext not exists,browser.currentURI.displaySpec=null

Tracking for Fission Nightly (M6) because Session Restore doesn't need to block Fission dogfooding (M5).

Fission Milestone: M5 → M6

For this bug, it is a mochitest test failure when enabling sessionHistory in the parent.
This is related to sessionHistory in parent implementation.
Per the previous discussion with Peter, we should check the fission mochitest result after the new implementation is landed.
Since I won't have any action in a short time, unassign the bug now.

Hi Peter,
I cannot find a suitable bug that I can add it into dependency to show this bug block "enabling sessionHistory in the parent".
Could you help?

Assignee: alchen → nobody
Status: ASSIGNED → NEW
Flags: needinfo?(peterv)

M6b
Test depends on fission-history bug.

No longer blocks: fission-history
Fission Milestone: M6 → M6b
Depends on: fission-history
Fission Milestone: M6b → M6c

Alphan tested and this seems to be passing with sessionHistoryInParent pref on. Keeping this on file to re-test once bug 1656208 is done.

Depends on: fission-history-m6b
No longer depends on: fission-history
Flags: needinfo?(peterv)

Andreas, can you look into this one? Comment 14 suggests it might be fixed with SHIP but SHIP-failures spreadsheet has this test so might not be fixed just yet.

Flags: needinfo?(afarre)

This still repros:

FAIL tab was duplicated - Got "about:blank", expected "about:mozilla"
Stack trace:
chrome://mochikit/content/browser-test.js:test_is:1332
chrome://mochitests/content/browser/browser/components/sessionstore/test/browser_swapDocShells.js:null:18

Flags: needinfo?(afarre)
Assignee: nobody → rjesup
Status: NEW → ASSIGNED

This fails in tab duplication so most probably session restore related.

With SHIP and kashav's sessionstore patch (bug 1673617), it still fails:

0:04.66 INFO Console message: [JavaScript Error: "Error: no SessionHistory object" {file: "resource:///modules/sessionstore/SessionStore.jsm" line: 1046}]
addSHistoryListener@resource:///modules/sessionstore/SessionStore.jsm:1046:13
updateSessionStoreFromTablistener@resource:///modules/sessionstore/SessionStore.jsm:1213:14
updateSessionStoreFromTablistener@resource:///modules/sessionstore/SessionStore.jsm:421:33
SSF_updateSessionStore@resource://gre/modules/SessionStoreFunctions.jsm:450:18
UpdateSessionStore@resource://gre/modules/SessionStoreFunctions.jsm:21:35
flush@resource:///modules/sessionstore/TabStateFlusher.jsm:99:51
flush@resource:///modules/sessionstore/TabStateFlusher.jsm:29:36
ssi_duplicateTab@resource:///modules/sessionstore/SessionStore.jsm:3092:21
ss_duplicateTab@resource:///modules/sessionstore/SessionStore.jsm:308:33
duplicateTabIn@chrome://browser/content/browser.js:8622:20
@chrome://mochitests/content/browser/browser/components/sessionstore/test/browser_swapDocShells.js:15:7

Assigned this to farre last week in the SHIP meeting but forgot to make the change in Bugzilla.

Assignee: rjesup → afarre
Assignee: afarre → nika

Nika looked into the usage and found out the only thing affected because of this is the extension tab duplication which might not work with non-remote tabs.

Assignee: nika → kmaglione+bmo
Pushed by maglione.k@gmail.com: https://hg.mozilla.org/integration/autoland/rev/0a600f3a62b5 Update TabListener owner content when swapping frame loaders. r=peterv
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 87 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: