mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Use custom snapshot row translation to prevent Electron 1.6 reload crash
Adding a source map for the entire snapshot was expensive in terms of memory and seemed to be triggering some sort of bug in Chromium when reloading with the DevTools open. The custom row translation relies on a much more compact representation of the data and avoids the crash. Signed-off-by: Nathan Sobo <nathan@github.com>
This commit is contained in:
committed by
Nathan Sobo
parent
dad08f2b38
commit
2c3500503f
@@ -114,16 +114,19 @@ function writeCachedJavascript (relativeCachePath, code) {
|
||||
|
||||
var INLINE_SOURCE_MAP_REGEXP = /\/\/[#@]\s*sourceMappingURL=([^'"\n]+)\s*$/mg
|
||||
|
||||
let snapshotSourceMapConsumer
|
||||
if (global.isGeneratingSnapshot) {
|
||||
// Warm up the source map consumer to efficiently translate positions when
|
||||
// generating stack traces containing a file that was snapshotted.
|
||||
const {SourceMapConsumer} = require('source-map')
|
||||
snapshotSourceMapConsumer = new SourceMapConsumer(snapshotAuxiliaryData.sourceMap) // eslint-disable-line no-undef
|
||||
snapshotSourceMapConsumer.originalPositionFor({line: 42, column: 0})
|
||||
}
|
||||
|
||||
exports.install = function (resourcesPath, nodeRequire) {
|
||||
const snapshotSourceMapConsumer = {
|
||||
originalPositionFor ({line, column}) {
|
||||
const {relativePath, row} = snapshotResult.translateSnapshotRow(line)
|
||||
return {
|
||||
column,
|
||||
line: row,
|
||||
source: path.join(resourcesPath, 'app', 'static', relativePath),
|
||||
name: null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceMapSupport.install({
|
||||
handleUncaughtExceptions: false,
|
||||
|
||||
@@ -132,10 +135,7 @@ exports.install = function (resourcesPath, nodeRequire) {
|
||||
// code from our cache directory.
|
||||
retrieveSourceMap: function (filePath) {
|
||||
if (filePath === '<embedded>') {
|
||||
return {
|
||||
map: snapshotSourceMapConsumer,
|
||||
url: path.join(resourcesPath, 'app', 'static', 'index.js')
|
||||
}
|
||||
return {map: snapshotSourceMapConsumer}
|
||||
}
|
||||
|
||||
if (!cacheDirectory || !fs.isFileSync(filePath)) {
|
||||
|
||||
Reference in New Issue
Block a user