Skip to content

Commit

Permalink
Bug 1883278 - Force-enable platform collection code of session store …
Browse files Browse the repository at this point in the history
…when SHIP is enabled. r=farre,geckoview-reviewers,sessionstore-reviewers

If session history in the parent is enabled then session store only works
correctly if the platform collection code is turned on.

Differential Revision: https://phabricator.services.mozilla.com/D203375
  • Loading branch information
petervanderbeken committed Mar 13, 2024
1 parent 30b363a commit 80aa104
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docshell/base/CanonicalBrowsingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2607,7 +2607,7 @@ void CanonicalBrowsingContext::UpdateSessionStoreForStorage(
}

void CanonicalBrowsingContext::MaybeScheduleSessionStoreUpdate() {
if (!StaticPrefs::browser_sessionstore_platform_collection_AtStartup()) {
if (!SessionStorePlatformCollection()) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5666,7 +5666,7 @@ nsDocShell::OnStateChange(nsIWebProgress* aProgress, nsIRequest* aRequest,
mBusyFlags = (BusyFlags)(BUSY_FLAGS_BUSY | BUSY_FLAGS_BEFORE_PAGE_LOAD);

if ((aStateFlags & STATE_RESTORING) == 0) {
if (StaticPrefs::browser_sessionstore_platform_collection_AtStartup()) {
if (SessionStorePlatformCollection()) {
if (IsForceReloadType(mLoadType)) {
if (WindowContext* windowContext =
mBrowsingContext->GetCurrentWindowContext()) {
Expand Down Expand Up @@ -6393,7 +6393,7 @@ nsresult nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
// incorrectly overrides session store data from the following load.
return NS_OK;
}
if (StaticPrefs::browser_sessionstore_platform_collection_AtStartup()) {
if (SessionStorePlatformCollection()) {
if (WindowContext* windowContext =
mBrowsingContext->GetCurrentWindowContext()) {
using Change = SessionStoreChangeListener::Change;
Expand Down
2 changes: 1 addition & 1 deletion dom/base/nsFrameLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3016,7 +3016,7 @@ nsresult nsFrameLoader::EnsureMessageManager() {
NS_ENSURE_TRUE(mChildMessageManager, NS_ERROR_UNEXPECTED);

// Set up session store
if (StaticPrefs::browser_sessionstore_platform_collection_AtStartup()) {
if (SessionStorePlatformCollection()) {
if (XRE_IsParentProcess() && mIsTopLevelContent) {
mSessionStoreChild = SessionStoreChild::GetOrCreate(
GetExtantBrowsingContext(), mOwnerContent);
Expand Down
2 changes: 1 addition & 1 deletion dom/ipc/BrowserChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ nsresult BrowserChild::Init(mozIDOMWindowProxy* aParent,

mIPCOpen = true;

if (StaticPrefs::browser_sessionstore_platform_collection_AtStartup()) {
if (SessionStorePlatformCollection()) {
mSessionStoreChild = SessionStoreChild::GetOrCreate(mBrowsingContext);
}

Expand Down
3 changes: 2 additions & 1 deletion dom/storage/SessionStorageManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "mozilla/ipc/BackgroundChild.h"
#include "mozilla/ipc/BackgroundParent.h"
#include "mozilla/ipc/PBackgroundChild.h"
#include "nsIXULRuntime.h"
#include "nsTHashMap.h"
#include "nsThreadUtils.h"

Expand Down Expand Up @@ -918,7 +919,7 @@ void BackgroundSessionStorageManager::SetCurrentBrowsingContextId(
}

void BackgroundSessionStorageManager::MaybeScheduleSessionStoreUpdate() {
if (!StaticPrefs::browser_sessionstore_platform_collection_AtStartup()) {
if (!SessionStorePlatformCollection()) {
return;
}

Expand Down
3 changes: 1 addition & 2 deletions mobile/android/chrome/geckoview/SessionStateAggregator.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const DEFAULT_INTERVAL_MS = 1500;
const TIMEOUT_DISABLED_PREF = "browser.sessionstore.debug.no_auto_updates";

const PREF_INTERVAL = "browser.sessionstore.interval";
const PREF_SESSION_COLLECTION = "browser.sessionstore.platform_collection";

class Handler {
constructor(store) {
Expand Down Expand Up @@ -607,7 +606,7 @@ class SessionStateAggregator extends GeckoViewChildModule {
this.messageQueue,
];

if (!Services.prefs.getBoolPref(PREF_SESSION_COLLECTION, false)) {
if (!Services.appinfo.sessionStorePlatformCollection) {
this.handlers.push(
new FormDataListener(this),
new ScrollPositionListener(this)
Expand Down
13 changes: 8 additions & 5 deletions modules/libpref/init/StaticPrefList.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1655,15 +1655,18 @@
value: 15000
mirror: always

# Platform collection of data for session store
- name: browser.sessionstore.platform_collection
# Disable collection of data for session store using the native collector code,
# instead use the older implementation that's not compatible with session
# history in the parent (and thus Fission).
- name: browser.sessionstore.disable_platform_collection
type: bool
#if defined(ANDROID) || defined(MOZ_THUNDERBIRD)
value: false
#else
#if defined(MOZ_THUNDERBIRD)
value: true
#else
value: false
#endif
mirror: once
do_not_use_directly: true

# Causes SessionStore to ignore non-final update messages from
# browser tabs that were not caused by a flush from the parent.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ SessionStoreChangeListener::HandleEvent(dom::Event* aEvent) {

/* static */ already_AddRefed<SessionStoreChangeListener>
SessionStoreChangeListener::Create(BrowsingContext* aBrowsingContext) {
MOZ_RELEASE_ASSERT(
StaticPrefs::browser_sessionstore_platform_collection_AtStartup());
MOZ_RELEASE_ASSERT(SessionStorePlatformCollection());
if (!aBrowsingContext) {
return nullptr;
}
Expand Down
12 changes: 12 additions & 0 deletions toolkit/xre/nsAppRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,12 @@ bool SessionHistoryInParent() {
fission_disableSessionHistoryInParent_AtStartup_DoNotUseDirectly();
}

bool SessionStorePlatformCollection() {
return SessionHistoryInParent() &&
!StaticPrefs::
browser_sessionstore_disable_platform_collection_AtStartup_DoNotUseDirectly();
}

bool BFCacheInParent() {
return SessionHistoryInParent() &&
StaticPrefs::fission_bfcacheInParent_DoNotUseDirectly();
Expand Down Expand Up @@ -1428,6 +1434,12 @@ nsXULAppInfo::GetSessionHistoryInParent(bool* aResult) {
return NS_OK;
}

NS_IMETHODIMP
nsXULAppInfo::GetSessionStorePlatformCollection(bool* aResult) {
*aResult = SessionStorePlatformCollection();
return NS_OK;
}

NS_IMETHODIMP
nsXULAppInfo::GetBrowserTabsRemoteAutostart(bool* aResult) {
*aResult = BrowserTabsRemoteAutostart();
Expand Down
9 changes: 9 additions & 0 deletions xpcom/system/nsIXULRuntime.idl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ bool FissionExperimentEnrolled();
// fission.disableSessionHistoryInParent is false.
bool SessionHistoryInParent();

// Returns true if SessionHistoryInParent() is true and
// browser.sessionstore.disable_platform_collection is false.
bool SessionStorePlatformCollection();

// Returns true if SessionHistoryInParent() returns true and
// fission.bfcacheInParent is true.
bool BFCacheInParent();
Expand Down Expand Up @@ -168,6 +172,11 @@ interface nsIXULRuntime : nsISupports
*/
readonly attribute boolean sessionHistoryInParent;

/**
* Whether Gecko code drives session store collection data.
*/
readonly attribute boolean sessionStorePlatformCollection;

/**
* Whether to write console errors to a log file. If a component
* encounters startup errors that might prevent the app from showing
Expand Down

0 comments on commit 80aa104

Please sign in to comment.