зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1531917 - Add Telemetry for how pages use bfcache r=jesup,bdekoz,smaug
Differential Revision: https://phabricator.services.mozilla.com/D30211 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
d396718f90
Коммит
04337d74c3
|
@ -7212,9 +7212,53 @@ bool nsDocShell::CanSavePresentation(uint32_t aLoadType,
|
|||
|
||||
// If the document does not want its presentation cached, then don't.
|
||||
RefPtr<Document> doc = mScriptGlobal->GetExtantDoc();
|
||||
return doc && doc->CanSavePresentation(aNewRequest);
|
||||
|
||||
uint16_t bfCacheCombo = 0;
|
||||
bool canSavePresentation =
|
||||
doc->CanSavePresentation(aNewRequest, bfCacheCombo);
|
||||
ReportBFCacheComboTelemetry(bfCacheCombo);
|
||||
|
||||
return doc && canSavePresentation;
|
||||
}
|
||||
|
||||
void nsDocShell::ReportBFCacheComboTelemetry(uint16_t aCombo) {
|
||||
switch (aCombo) {
|
||||
case BFCACHE_SUCCESS:
|
||||
Telemetry::AccumulateCategorical(
|
||||
Telemetry::LABELS_BFCACHE_COMBO::BFCache_Success);
|
||||
break;
|
||||
case UNLOAD:
|
||||
Telemetry::AccumulateCategorical(Telemetry::LABELS_BFCACHE_COMBO::Unload);
|
||||
break;
|
||||
case UNLOAD_REQUEST:
|
||||
Telemetry::AccumulateCategorical(
|
||||
Telemetry::LABELS_BFCACHE_COMBO::Unload_Req);
|
||||
break;
|
||||
case REQUEST:
|
||||
Telemetry::AccumulateCategorical(Telemetry::LABELS_BFCACHE_COMBO::Req);
|
||||
break;
|
||||
case UNLOAD_REQUEST_PEER:
|
||||
Telemetry::AccumulateCategorical(
|
||||
Telemetry::LABELS_BFCACHE_COMBO::Unload_Req_Peer);
|
||||
break;
|
||||
case UNLOAD_REQUEST_PEER_MSE:
|
||||
Telemetry::AccumulateCategorical(
|
||||
Telemetry::LABELS_BFCACHE_COMBO::Unload_Req_Peer_MSE);
|
||||
break;
|
||||
case UNLOAD_REQUEST_MSE:
|
||||
Telemetry::AccumulateCategorical(
|
||||
Telemetry::LABELS_BFCACHE_COMBO::Unload_Req_MSE);
|
||||
break;
|
||||
case SUSPENDED_UNLOAD_REQUEST_PEER:
|
||||
Telemetry::AccumulateCategorical(
|
||||
Telemetry::LABELS_BFCACHE_COMBO::SPD_Unload_Req_Peer);
|
||||
break;
|
||||
default:
|
||||
Telemetry::AccumulateCategorical(Telemetry::LABELS_BFCACHE_COMBO::Other);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
void nsDocShell::ReattachEditorToWindow(nsISHEntry* aSHEntry) {
|
||||
MOZ_ASSERT(!mIsBeingDestroyed);
|
||||
|
||||
|
|
|
@ -751,6 +751,37 @@ class nsDocShell final : public nsDocLoader,
|
|||
bool CanSavePresentation(uint32_t aLoadType, nsIRequest* aNewRequest,
|
||||
mozilla::dom::Document* aNewDocument);
|
||||
|
||||
// There are 11 possible reasons to make a request fails to use BFCache
|
||||
// (see BFCacheStatus in dom/base/Document.h), and we'd like to record
|
||||
// the common combinations for reasons which make requests fail to use
|
||||
// BFCache. These combinations are generated based on some local browsings,
|
||||
// we need to adjust them when necessary.
|
||||
enum BFCacheStatusCombo : uint16_t {
|
||||
BFCACHE_SUCCESS,
|
||||
UNLOAD = mozilla::dom::BFCacheStatus::UNLOAD_LISTENER,
|
||||
UNLOAD_REQUEST = mozilla::dom::BFCacheStatus::UNLOAD_LISTENER |
|
||||
mozilla::dom::BFCacheStatus::REQUEST,
|
||||
REQUEST = mozilla::dom::BFCacheStatus::REQUEST,
|
||||
UNLOAD_REQUEST_PEER = mozilla::dom::BFCacheStatus::UNLOAD_LISTENER |
|
||||
mozilla::dom::BFCacheStatus::REQUEST |
|
||||
mozilla::dom::BFCacheStatus::ACTIVE_PEER_CONNECTION,
|
||||
UNLOAD_REQUEST_PEER_MSE =
|
||||
mozilla::dom::BFCacheStatus::UNLOAD_LISTENER |
|
||||
mozilla::dom::BFCacheStatus::REQUEST |
|
||||
mozilla::dom::BFCacheStatus::ACTIVE_PEER_CONNECTION |
|
||||
mozilla::dom::BFCacheStatus::CONTAINS_MSE_CONTENT,
|
||||
UNLOAD_REQUEST_MSE = mozilla::dom::BFCacheStatus::UNLOAD_LISTENER |
|
||||
mozilla::dom::BFCacheStatus::REQUEST |
|
||||
mozilla::dom::BFCacheStatus::CONTAINS_MSE_CONTENT,
|
||||
SUSPENDED_UNLOAD_REQUEST_PEER =
|
||||
mozilla::dom::BFCacheStatus::SUSPENDED |
|
||||
mozilla::dom::BFCacheStatus::UNLOAD_LISTENER |
|
||||
mozilla::dom::BFCacheStatus::REQUEST |
|
||||
mozilla::dom::BFCacheStatus::ACTIVE_PEER_CONNECTION,
|
||||
};
|
||||
|
||||
void ReportBFCacheComboTelemetry(uint16_t aCombo);
|
||||
|
||||
// Captures the state of the supporting elements of the presentation
|
||||
// (the "window" object, docshell tree, meta-refresh loads, and security
|
||||
// state) and stores them on |mOSHE|.
|
||||
|
|
|
@ -7634,9 +7634,13 @@ void Document::CollectDescendantDocuments(
|
|||
}
|
||||
}
|
||||
|
||||
bool Document::CanSavePresentation(nsIRequest* aNewRequest) {
|
||||
bool Document::CanSavePresentation(nsIRequest* aNewRequest,
|
||||
uint16_t& aBFCacheCombo) {
|
||||
bool ret = true;
|
||||
|
||||
if (!IsBFCachingAllowed()) {
|
||||
return false;
|
||||
aBFCacheCombo |= BFCacheStatus::NOT_ALLOWED;
|
||||
ret = false;
|
||||
}
|
||||
|
||||
nsAutoCString uri;
|
||||
|
@ -7649,7 +7653,8 @@ bool Document::CanSavePresentation(nsIRequest* aNewRequest) {
|
|||
if (EventHandlingSuppressed()) {
|
||||
MOZ_LOG(gPageCacheLog, mozilla::LogLevel::Verbose,
|
||||
("Save of %s blocked on event handling suppression", uri.get()));
|
||||
return false;
|
||||
aBFCacheCombo |= BFCacheStatus::EVENT_HANDLING_SUPPRESSED;
|
||||
ret = false;
|
||||
}
|
||||
|
||||
// Do not allow suspended windows to be placed in the
|
||||
|
@ -7661,7 +7666,8 @@ bool Document::CanSavePresentation(nsIRequest* aNewRequest) {
|
|||
if (win && win->IsSuspended() && !win->IsFrozen()) {
|
||||
MOZ_LOG(gPageCacheLog, mozilla::LogLevel::Verbose,
|
||||
("Save of %s blocked on suspended Window", uri.get()));
|
||||
return false;
|
||||
aBFCacheCombo |= BFCacheStatus::SUSPENDED;
|
||||
ret = false;
|
||||
}
|
||||
|
||||
// Check our event listener manager for unload/beforeunload listeners.
|
||||
|
@ -7671,7 +7677,8 @@ bool Document::CanSavePresentation(nsIRequest* aNewRequest) {
|
|||
if (manager && manager->HasUnloadListeners()) {
|
||||
MOZ_LOG(gPageCacheLog, mozilla::LogLevel::Verbose,
|
||||
("Save of %s blocked due to unload handlers", uri.get()));
|
||||
return false;
|
||||
aBFCacheCombo |= BFCacheStatus::UNLOAD_LISTENER;
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7715,8 +7722,8 @@ bool Document::CanSavePresentation(nsIRequest* aNewRequest) {
|
|||
("Save of %s blocked because document has request %s",
|
||||
uri.get(), requestName.get()));
|
||||
}
|
||||
|
||||
return false;
|
||||
aBFCacheCombo |= BFCacheStatus::REQUEST;
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7726,7 +7733,8 @@ bool Document::CanSavePresentation(nsIRequest* aNewRequest) {
|
|||
MediaManager::Get()->IsWindowStillActive(win->WindowID())) {
|
||||
MOZ_LOG(gPageCacheLog, mozilla::LogLevel::Verbose,
|
||||
("Save of %s blocked due to GetUserMedia", uri.get()));
|
||||
return false;
|
||||
aBFCacheCombo |= BFCacheStatus::ACTIVE_GET_USER_MEDIA;
|
||||
ret = false;
|
||||
}
|
||||
|
||||
#ifdef MOZ_WEBRTC
|
||||
|
@ -7734,14 +7742,16 @@ bool Document::CanSavePresentation(nsIRequest* aNewRequest) {
|
|||
if (win && win->HasActivePeerConnections()) {
|
||||
MOZ_LOG(gPageCacheLog, mozilla::LogLevel::Verbose,
|
||||
("Save of %s blocked due to PeerConnection", uri.get()));
|
||||
return false;
|
||||
aBFCacheCombo |= BFCacheStatus::ACTIVE_PEER_CONNECTION;
|
||||
ret = false;
|
||||
}
|
||||
#endif // MOZ_WEBRTC
|
||||
|
||||
// Don't save presentations for documents containing EME content, so that
|
||||
// CDMs reliably shutdown upon user navigation.
|
||||
if (ContainsEMEContent()) {
|
||||
return false;
|
||||
aBFCacheCombo |= BFCacheStatus::CONTAINS_EME_CONTENT;
|
||||
ret = false;
|
||||
}
|
||||
|
||||
// Don't save presentations for documents containing MSE content, to
|
||||
|
@ -7749,7 +7759,8 @@ bool Document::CanSavePresentation(nsIRequest* aNewRequest) {
|
|||
if (ContainsMSEContent()) {
|
||||
MOZ_LOG(gPageCacheLog, mozilla::LogLevel::Verbose,
|
||||
("Save of %s blocked due to MSE use", uri.get()));
|
||||
return false;
|
||||
aBFCacheCombo |= BFCacheStatus::CONTAINS_MSE_CONTENT;
|
||||
ret = false;
|
||||
}
|
||||
|
||||
if (mSubDocuments) {
|
||||
|
@ -7757,12 +7768,16 @@ bool Document::CanSavePresentation(nsIRequest* aNewRequest) {
|
|||
auto entry = static_cast<SubDocMapEntry*>(iter.Get());
|
||||
Document* subdoc = entry->mSubDocument;
|
||||
|
||||
uint16_t subDocBFCacheCombo = 0;
|
||||
// The aIgnoreRequest we were passed is only for us, so don't pass it on.
|
||||
bool canCache = subdoc ? subdoc->CanSavePresentation(nullptr) : false;
|
||||
bool canCache =
|
||||
subdoc ? subdoc->CanSavePresentation(nullptr, subDocBFCacheCombo)
|
||||
: false;
|
||||
if (!canCache) {
|
||||
MOZ_LOG(gPageCacheLog, mozilla::LogLevel::Verbose,
|
||||
("Save of %s blocked due to subdocument blocked", uri.get()));
|
||||
return false;
|
||||
aBFCacheCombo |= subDocBFCacheCombo;
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7773,17 +7788,19 @@ bool Document::CanSavePresentation(nsIRequest* aNewRequest) {
|
|||
if (globalWindow->HasActiveSpeechSynthesis()) {
|
||||
MOZ_LOG(gPageCacheLog, mozilla::LogLevel::Verbose,
|
||||
("Save of %s blocked due to Speech use", uri.get()));
|
||||
return false;
|
||||
aBFCacheCombo |= BFCacheStatus::HAS_ACTIVE_SPEECH_SYNTHESIS;
|
||||
ret = false;
|
||||
}
|
||||
#endif
|
||||
if (globalWindow->HasUsedVR()) {
|
||||
MOZ_LOG(gPageCacheLog, mozilla::LogLevel::Verbose,
|
||||
("Save of %s blocked due to having used VR", uri.get()));
|
||||
return false;
|
||||
aBFCacheCombo |= BFCacheStatus::HAS_USED_VR;
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Document::Destroy() {
|
||||
|
|
|
@ -221,6 +221,20 @@ class CallbackObjectHolder;
|
|||
|
||||
enum class CallerType : uint32_t;
|
||||
|
||||
enum BFCacheStatus {
|
||||
NOT_ALLOWED = 1 << 0, // Status 0
|
||||
EVENT_HANDLING_SUPPRESSED = 1 << 1, // Status 1
|
||||
SUSPENDED = 1 << 2, // Status 2
|
||||
UNLOAD_LISTENER = 1 << 3, // Status 3
|
||||
REQUEST = 1 << 4, // Status 4
|
||||
ACTIVE_GET_USER_MEDIA = 1 << 5, // Status 5
|
||||
ACTIVE_PEER_CONNECTION = 1 << 6, // Status 6
|
||||
CONTAINS_EME_CONTENT = 1 << 7, // Status 7
|
||||
CONTAINS_MSE_CONTENT = 1 << 8, // Status 8
|
||||
HAS_ACTIVE_SPEECH_SYNTHESIS = 1 << 9, // Status 9
|
||||
HAS_USED_VR = 1 << 10, // Status 10
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -2252,8 +2266,12 @@ class Document : public nsINode,
|
|||
* replace this document in the docshell. The new document's request
|
||||
* will be ignored when checking for active requests. If there is no
|
||||
* request associated with the new document, this parameter may be null.
|
||||
*
|
||||
* |aBFCacheCombo| is used as a bitmask to indicate what the status
|
||||
* combination is when we try to BFCache aNewRequest
|
||||
*/
|
||||
virtual bool CanSavePresentation(nsIRequest* aNewRequest);
|
||||
virtual bool CanSavePresentation(nsIRequest* aNewRequest,
|
||||
uint16_t& aBFCacheCombo);
|
||||
|
||||
virtual nsresult Init();
|
||||
|
||||
|
|
|
@ -42,7 +42,8 @@ class PluginDocument final : public MediaDocument, public nsIPluginDocument {
|
|||
|
||||
void SetScriptGlobalObject(
|
||||
nsIScriptGlobalObject* aScriptGlobalObject) override;
|
||||
bool CanSavePresentation(nsIRequest* aNewRequest) override;
|
||||
bool CanSavePresentation(nsIRequest* aNewRequest,
|
||||
uint16_t& aBFCacheStatus) override;
|
||||
|
||||
const nsCString& GetType() const { return mMimeType; }
|
||||
Element* GetPluginContent() { return mPluginContent; }
|
||||
|
@ -136,7 +137,8 @@ void PluginDocument::SetScriptGlobalObject(
|
|||
}
|
||||
}
|
||||
|
||||
bool PluginDocument::CanSavePresentation(nsIRequest* aNewRequest) {
|
||||
bool PluginDocument::CanSavePresentation(nsIRequest* aNewRequest,
|
||||
uint16_t& aBFCacheStatus) {
|
||||
// Full-page plugins cannot be cached, currently, because we don't have
|
||||
// the stream listener data to feed to the plugin instance.
|
||||
return false;
|
||||
|
|
|
@ -14472,6 +14472,26 @@
|
|||
"labels": ["FullStandards", "AlmostStandards", "NavQuirks"],
|
||||
"description": "HTML document compat mode (quirks mode)"
|
||||
},
|
||||
"BFCACHE_COMBO": {
|
||||
"record_in_processes": ["main", "content"],
|
||||
"alert_emails": ["sefeng@mozilla.com"],
|
||||
"bug_numbers": [1531917],
|
||||
"expires_in_version": "never",
|
||||
"kind": "categorical",
|
||||
"releaseChannelCollection": "opt-out",
|
||||
"labels": [
|
||||
"BFCache_Success",
|
||||
"Unload",
|
||||
"Unload_Req",
|
||||
"Req",
|
||||
"Unload_Req_Peer",
|
||||
"Unload_Req_Peer_MSE",
|
||||
"Unload_Req_MSE",
|
||||
"SPD_Unload_Req_Peer",
|
||||
"Other"
|
||||
],
|
||||
"description": "The common combinations of BFCacheStatus when we determine whether the page can be BFCached or not; If it uses BFCache, we record BFCache_Success; If it's not and it falls under common failure reasons combinations, we record the corresponding combination; Otherwise, we record Other to indicate this is not a common failure"
|
||||
},
|
||||
"HIDDEN_VIEWPORT_OVERFLOW_TYPE": {
|
||||
"record_in_processes": ["main", "content"],
|
||||
"alert_emails": ["mozilla-telemetry@upsuper.org", "botond@mozilla.com"],
|
||||
|
|
Загрузка…
Ссылка в новой задаче