mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-22 23:27:30 +09:00
Add performance warnings to Deprecated module.
Adds a dedicated handler for performance warnings to be logged to consoles if known performance-impacting methods are called. Search service init is changed from a deprecation warning to a performance warning for synchronous init. This also re-enables the warning for the Basilisk & Co. search service initialization which was previously removed in [a930a79] See also the discussion on #916.
This commit is contained in:
parent
304984a6aa
commit
69919870c1
4 changed files with 60 additions and 7 deletions
|
|
@ -956,6 +956,9 @@ pref("toolkit.asyncshutdown.log", false);
|
||||||
// Enable deprecation warnings.
|
// Enable deprecation warnings.
|
||||||
pref("devtools.errorconsole.deprecation_warnings", true);
|
pref("devtools.errorconsole.deprecation_warnings", true);
|
||||||
|
|
||||||
|
// Enable performance warnings.
|
||||||
|
pref("devtools.errorconsole.performance_warnings", true);
|
||||||
|
|
||||||
// Disable debugging chrome
|
// Disable debugging chrome
|
||||||
pref("devtools.chrome.enabled", false);
|
pref("devtools.chrome.enabled", false);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "OS",
|
||||||
"resource://gre/modules/osfile.jsm");
|
"resource://gre/modules/osfile.jsm");
|
||||||
XPCOMUtils.defineLazyModuleGetter(this, "Task",
|
XPCOMUtils.defineLazyModuleGetter(this, "Task",
|
||||||
"resource://gre/modules/Task.jsm");
|
"resource://gre/modules/Task.jsm");
|
||||||
|
XPCOMUtils.defineLazyModuleGetter(this, "Deprecated",
|
||||||
|
"resource://gre/modules/Deprecated.jsm");
|
||||||
XPCOMUtils.defineLazyModuleGetter(this, "SearchStaticData",
|
XPCOMUtils.defineLazyModuleGetter(this, "SearchStaticData",
|
||||||
"resource://gre/modules/SearchStaticData.jsm");
|
"resource://gre/modules/SearchStaticData.jsm");
|
||||||
XPCOMUtils.defineLazyModuleGetter(this, "setTimeout",
|
XPCOMUtils.defineLazyModuleGetter(this, "setTimeout",
|
||||||
|
|
@ -2691,6 +2693,13 @@ SearchService.prototype = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let performanceWarning =
|
||||||
|
"Search service falling back to synchronous initialization. " +
|
||||||
|
"This is generally the consequence of an add-on using a deprecated " +
|
||||||
|
"search service API.";
|
||||||
|
Deprecated.perfWarning(performanceWarning, "https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIBrowserSearchService#async_warning");
|
||||||
|
LOG(performanceWarning);
|
||||||
|
|
||||||
this._syncInit();
|
this._syncInit();
|
||||||
if (!Components.isSuccessCode(this._initRV)) {
|
if (!Components.isSuccessCode(this._initRV)) {
|
||||||
throw this._initRV;
|
throw this._initRV;
|
||||||
|
|
|
||||||
|
|
@ -2917,12 +2917,12 @@ SearchService.prototype = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let warning =
|
let performanceWarning =
|
||||||
"Search service falling back to synchronous initialization. " +
|
"Search service falling back to synchronous initialization. " +
|
||||||
"This is generally the consequence of an add-on using a deprecated " +
|
"This is generally the consequence of an add-on using a deprecated " +
|
||||||
"search service API.";
|
"search service API.";
|
||||||
Deprecated.warning(warning, "https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIBrowserSearchService#async_warning");
|
Deprecated.perfWarning(performanceWarning, "https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIBrowserSearchService#async_warning");
|
||||||
LOG(warning);
|
LOG(performanceWarning);
|
||||||
|
|
||||||
engineMetadataService.syncInit();
|
engineMetadataService.syncInit();
|
||||||
this._syncInit();
|
this._syncInit();
|
||||||
|
|
|
||||||
|
|
@ -9,15 +9,21 @@ this.EXPORTED_SYMBOLS = [ "Deprecated" ];
|
||||||
const Cu = Components.utils;
|
const Cu = Components.utils;
|
||||||
const Ci = Components.interfaces;
|
const Ci = Components.interfaces;
|
||||||
const PREF_DEPRECATION_WARNINGS = "devtools.errorconsole.deprecation_warnings";
|
const PREF_DEPRECATION_WARNINGS = "devtools.errorconsole.deprecation_warnings";
|
||||||
|
const PREF_PERFORMANCE_WARNINGS = "devtools.errorconsole.performance_warnings";
|
||||||
|
|
||||||
Cu.import("resource://gre/modules/Services.jsm");
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
// A flag that indicates whether deprecation warnings should be logged.
|
// A flag that indicates whether deprecation warnings should be logged.
|
||||||
var logWarnings = Services.prefs.getBoolPref(PREF_DEPRECATION_WARNINGS);
|
var logDepWarnings = Services.prefs.getBoolPref(PREF_DEPRECATION_WARNINGS);
|
||||||
|
var logPerfWarnings = Services.prefs.getBoolPref(PREF_PERFORMANCE_WARNINGS);
|
||||||
|
|
||||||
Services.prefs.addObserver(PREF_DEPRECATION_WARNINGS,
|
Services.prefs.addObserver(PREF_DEPRECATION_WARNINGS,
|
||||||
function (aSubject, aTopic, aData) {
|
function (aSubject, aTopic, aData) {
|
||||||
logWarnings = Services.prefs.getBoolPref(PREF_DEPRECATION_WARNINGS);
|
logDepWarnings = Services.prefs.getBoolPref(PREF_DEPRECATION_WARNINGS);
|
||||||
|
}, false);
|
||||||
|
Services.prefs.addObserver(PREF_PERFORMANCE_WARNINGS,
|
||||||
|
function (aSubject, aTopic, aData) {
|
||||||
|
logPerfWarnings = Services.prefs.getBoolPref(PREF_PERFORMANCE_WARNINGS);
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -58,7 +64,7 @@ this.Deprecated = {
|
||||||
* logged.
|
* logged.
|
||||||
*/
|
*/
|
||||||
warning: function (aText, aUrl, aStack) {
|
warning: function (aText, aUrl, aStack) {
|
||||||
if (!logWarnings) {
|
if (!logDepWarnings) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,7 +77,42 @@ this.Deprecated = {
|
||||||
|
|
||||||
let textMessage = "DEPRECATION WARNING: " + aText +
|
let textMessage = "DEPRECATION WARNING: " + aText +
|
||||||
"\nYou may find more details about this deprecation at: " +
|
"\nYou may find more details about this deprecation at: " +
|
||||||
aUrl + "\n" +
|
aUrl + "\nCallstack:\n" +
|
||||||
|
// Append a callstack part to the deprecation message.
|
||||||
|
stringifyCallstack(aStack);
|
||||||
|
|
||||||
|
// Report deprecation warning.
|
||||||
|
Cu.reportError(textMessage);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a performance warning.
|
||||||
|
*
|
||||||
|
* @param string aText
|
||||||
|
* Performance issue warning text.
|
||||||
|
* @param string aUrl
|
||||||
|
* A URL pointing to documentation describing performance
|
||||||
|
* issue and the way to address it.
|
||||||
|
* @param nsIStackFrame aStack
|
||||||
|
* An optional callstack. If it is not provided a
|
||||||
|
* snapshot of the current JavaScript callstack will be
|
||||||
|
* logged.
|
||||||
|
*/
|
||||||
|
perfWarning: function (aText, aUrl, aStack) {
|
||||||
|
if (!logPerfWarnings) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If URL is not provided, report an error.
|
||||||
|
if (!aUrl) {
|
||||||
|
Cu.reportError("Error in Deprecated.perfWarning: warnings must " +
|
||||||
|
"provide a URL documenting this performance issue.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let textMessage = "PERFORMANCE WARNING: " + aText +
|
||||||
|
"\nYou may find more details about this problem at: " +
|
||||||
|
aUrl + "\nCallstack:\n" +
|
||||||
// Append a callstack part to the deprecation message.
|
// Append a callstack part to the deprecation message.
|
||||||
stringifyCallstack(aStack);
|
stringifyCallstack(aStack);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue