mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 757408 - Opening debugger hangs completely on large scripts; r=past
This commit is contained in:
parent
7caf83c50d
commit
2dbed58a48
@ -218,6 +218,8 @@ ThreadActor.prototype = {
|
||||
}
|
||||
packet.why = { type: "attached" };
|
||||
|
||||
this._restoreBreakpoints();
|
||||
|
||||
// Send the response to the attach request now (rather than
|
||||
// returning it), because we're going to start a nested event loop
|
||||
// here.
|
||||
@ -740,36 +742,23 @@ ThreadActor.prototype = {
|
||||
|
||||
/**
|
||||
* Get the script and source lists from the debugger.
|
||||
*
|
||||
* TODO bug 637572: we should be dealing with sources directly, not inferring
|
||||
* them through scripts.
|
||||
*/
|
||||
_discoverScriptsAndSources: function TA__discoverScriptsAndSources() {
|
||||
let promises = [];
|
||||
let foundSourceMaps = false;
|
||||
let scripts = this.dbg.findScripts();
|
||||
for (let s of scripts) {
|
||||
if (s.sourceMapURL && !foundSourceMaps) {
|
||||
foundSourceMaps = true;
|
||||
break;
|
||||
}
|
||||
_discoverSources: function TA__discoverSources() {
|
||||
// Only get one script per url.
|
||||
let scriptsByUrl = {};
|
||||
for (let s of this.dbg.findScripts()) {
|
||||
scriptsByUrl[s.url] = s;
|
||||
}
|
||||
if (this._options.useSourceMaps && foundSourceMaps) {
|
||||
for (let s of scripts) {
|
||||
promises.push(this._addScript(s));
|
||||
}
|
||||
return all(promises);
|
||||
}
|
||||
// When source maps are not enabled or not used in the page _addScript is
|
||||
// synchronous, since it doesn't need to wait for fetching source maps, so
|
||||
// resolves immediately. This eliminates a huge slowdown in script-heavy
|
||||
// pages like G+ or chrome debugging, where the GC takes a long time to
|
||||
// clean up after Promise.all.
|
||||
for (let s of scripts) {
|
||||
this._addScriptSync(s);
|
||||
}
|
||||
return resolve(null);
|
||||
|
||||
return all([this.sources.sourcesForScript(scriptsByUrl[s])
|
||||
for (s of Object.keys(scriptsByUrl))]);
|
||||
},
|
||||
|
||||
onSources: function TA_onSources(aRequest) {
|
||||
return this._discoverScriptsAndSources().then(() => {
|
||||
return this._discoverSources().then(() => {
|
||||
return {
|
||||
sources: [s.form() for (s of this.sources.iter())]
|
||||
};
|
||||
@ -1269,6 +1258,7 @@ ThreadActor.prototype = {
|
||||
*/
|
||||
onNewScript: function TA_onNewScript(aScript, aGlobal) {
|
||||
this._addScript(aScript);
|
||||
this.sources.sourcesForScript(aScript);
|
||||
},
|
||||
|
||||
onNewSource: function TA_onNewSource(aSource) {
|
||||
@ -1303,37 +1293,12 @@ ThreadActor.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Add the provided script to the server cache synchronously, without checking
|
||||
* for any declared source maps.
|
||||
*
|
||||
* @param aScript Debugger.Script
|
||||
* The source script that will be stored.
|
||||
* @returns true, if the script was added; false otherwise.
|
||||
* Restore any pre-existing breakpoints to the scripts that we have access to.
|
||||
*/
|
||||
_addScriptSync: function TA__addScriptSync(aScript) {
|
||||
if (!this._allowSource(aScript.url)) {
|
||||
return false;
|
||||
_restoreBreakpoints: function TA__restoreBreakpoints() {
|
||||
for (let s of this.dbg.findScripts()) {
|
||||
this._addScript(s);
|
||||
}
|
||||
|
||||
this.sources.source(aScript.url);
|
||||
// Set any stored breakpoints.
|
||||
let existing = this._breakpointStore[aScript.url];
|
||||
if (existing) {
|
||||
let endLine = aScript.startLine + aScript.lineCount - 1;
|
||||
// Iterate over the lines backwards, so that sliding breakpoints don't
|
||||
// affect the loop.
|
||||
for (let line = existing.length - 1; line >= 0; line--) {
|
||||
let bp = existing[line];
|
||||
// Only consider breakpoints that are not already associated with
|
||||
// scripts, and limit search to the line numbers contained in the new
|
||||
// script.
|
||||
if (bp && !bp.actor.scripts.length &&
|
||||
line >= aScript.startLine && line <= endLine) {
|
||||
this._setBreakpoint(bp);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1341,38 +1306,32 @@ ThreadActor.prototype = {
|
||||
*
|
||||
* @param aScript Debugger.Script
|
||||
* The source script that will be stored.
|
||||
* @returns a promise of true, if the script was added; of false otherwise.
|
||||
* @returns true, if the script was added; false otherwise.
|
||||
*/
|
||||
_addScript: function TA__addScript(aScript) {
|
||||
if (!this._allowSource(aScript.url)) {
|
||||
return resolve(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO bug 637572: we should be dealing with sources directly, not
|
||||
// inferring them through scripts.
|
||||
return this.sources.sourcesForScript(aScript).then(() => {
|
||||
|
||||
// Set any stored breakpoints.
|
||||
let existing = this._breakpointStore[aScript.url];
|
||||
if (existing) {
|
||||
let endLine = aScript.startLine + aScript.lineCount - 1;
|
||||
// Iterate over the lines backwards, so that sliding breakpoints don't
|
||||
// affect the loop.
|
||||
for (let line = existing.length - 1; line >= 0; line--) {
|
||||
let bp = existing[line];
|
||||
// Only consider breakpoints that are not already associated with
|
||||
// scripts, and limit search to the line numbers contained in the new
|
||||
// script.
|
||||
if (bp && !bp.actor.scripts.length &&
|
||||
line >= aScript.startLine && line <= endLine) {
|
||||
this._setBreakpoint(bp);
|
||||
}
|
||||
// Set any stored breakpoints.
|
||||
let existing = this._breakpointStore[aScript.url];
|
||||
if (existing) {
|
||||
let endLine = aScript.startLine + aScript.lineCount - 1;
|
||||
// Iterate over the lines backwards, so that sliding breakpoints don't
|
||||
// affect the loop.
|
||||
for (let line = existing.length - 1; line >= aScript.startLine; line--) {
|
||||
let bp = existing[line];
|
||||
// Only consider breakpoints that are not already associated with
|
||||
// scripts, and limit search to the line numbers contained in the new
|
||||
// script.
|
||||
if (bp && !bp.actor.scripts.length && line <= endLine) {
|
||||
this._setBreakpoint(bp);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
ThreadActor.prototype.requestTypes = {
|
||||
@ -2638,7 +2597,8 @@ ThreadSources.prototype = {
|
||||
return [
|
||||
this.source(s, aSourceMap) for (s of aSourceMap.sources)
|
||||
];
|
||||
}, (e) => {
|
||||
})
|
||||
.then(null, (e) => {
|
||||
reportError(e);
|
||||
delete this._sourceMaps[this._normalize(aScript.sourceMapURL, aScript.url)];
|
||||
delete this._sourceMapsByGeneratedSource[aScript.url];
|
||||
@ -2682,7 +2642,7 @@ ThreadSources.prototype = {
|
||||
return this._sourceMaps[aAbsSourceMapURL];
|
||||
} else {
|
||||
let promise = fetch(aAbsSourceMapURL).then((rawSourceMap) => {
|
||||
let map = new SourceMapConsumer(rawSourceMap);
|
||||
let map = new SourceMapConsumer(rawSourceMap);
|
||||
let base = aAbsSourceMapURL.replace(/\/[^\/]+$/, '/');
|
||||
if (base.indexOf("data:") !== 0) {
|
||||
map.sourceRoot = map.sourceRoot
|
||||
|
@ -30,7 +30,7 @@ function createRootActor()
|
||||
};
|
||||
|
||||
actor.thread.requestTypes["scripts"] = function (aRequest) {
|
||||
return this._discoverScriptsAndSources().then(function () {
|
||||
return this._discoverSources().then(function () {
|
||||
let scripts = [];
|
||||
for (let s of this.dbg.findScripts()) {
|
||||
if (!s.url) {
|
||||
|
Loading…
Reference in New Issue
Block a user