Skip to content

Commit

Permalink
Alpha version of the BLeak results viewer.
Browse files Browse the repository at this point in the history
  • Loading branch information
John Vilk committed Feb 10, 2018
1 parent 1b9c992 commit 528700b
Show file tree
Hide file tree
Showing 32 changed files with 2,257 additions and 214 deletions.
22 changes: 22 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<title>BLeak Results Viewer</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="node_modules/react-treeview/react-treeview.css">
</head>
<body>
<div id="main">
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script src="node_modules/d3/build/d3.min.js"></script>
<script src="build/viewer.js" type="text/javascript"></script>
</body>
</html>
32 changes: 28 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
"description": "Automatically finds memory leaks in single page web applications.",
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"build": "npm-run-all -s build:core rollup:viewer",
"build:core": "tsc",
"rollup:viewer": "rollup -c",
"test": "npm-run-all -s build nyc:test",
"nyc:test": "nyc mocha --require source-map-support/register build/test"
"nyc:test": "nyc mocha --require source-map-support/register build/test",
"watch": "npm-run-all -s build:core -p tsc:watch rollup:viewer:watch",
"tsc:watch": "tsc -w",
"rollup:viewer:watch": "rollup -w -c"
},
"repository": {
"type": "git",
Expand All @@ -27,29 +32,48 @@
"license": "MIT",
"homepage": "https://bitbucket.org/jvilk/deuterium-oxide#readme",
"devDependencies": {
"@types/ace": "^0.0.36",
"@types/babel-core": "^6.25.1",
"@types/benchmark": "^1.0.30",
"@types/body-parser": "^1.16.5",
"@types/bootstrap": "^3.3.37",
"@types/d3": "^4.12.0",
"@types/error-stack-parser": "^1.3.18",
"@types/esprima": "^2.1.33",
"@types/estree": "0.0.34",
"@types/express": "^4.0.37",
"@types/extract-zip": "^1.6.2",
"@types/glob": "^5.0.30",
"@types/htmlparser2": "^3.7.29",
"@types/jquery": "^3.3.0",
"@types/mocha": "^2.2.40",
"@types/node": "^7.0.12",
"@types/papaparse": "^4.1.30",
"@types/progress": "^2.0.1",
"@types/react": "^16.0.36",
"@types/react-dom": "^16.0.3",
"@types/source-map": "^0.5.1",
"@types/ws": "^3.0.2",
"@types/yargs": "^8.0.2",
"benchmark": "^2.1.4",
"d3": "^4.13.0",
"glob": "^7.1.2",
"mocha": "^3.2.0",
"npm-run-all": "^4.0.2",
"nyc": "^10.2.0",
"react": "^16.2.0",
"react-ace": "^5.9.0",
"react-dom": "^16.2.0",
"react-treeview": "^0.4.7",
"rimraf": "^2.6.2",
"rollup": "^0.55.3",
"rollup-plugin-buble": "^0.18.0",
"rollup-plugin-commonjs": "^8.3.0",
"rollup-plugin-node-resolve": "^3.0.2",
"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"source-map-support": "^0.5.3",
"typescript": "^2.4.2"
"typescript": "^2.7.1"
},
"dependencies": {
"astring": "^1.0.5",
Expand All @@ -64,14 +88,14 @@
"esprima": "^4.0.0",
"express": "^4.15.4",
"extract-zip": "^1.6.0",
"glob": "^7.1.1",
"htmlparser2": "^3.9.2",
"locate-java-home": "^0.1.6",
"microtime": "^2.1.6",
"mitmproxy": "~1.4.0",
"papaparse": "^4.3.6",
"progress": "^2.0.0",
"source-map": "^0.5.6",
"tslib": "^1.9.0",
"ws": "^3.1.0",
"yargs": "^8.0.2"
},
Expand Down
68 changes: 68 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import sourcemaps from 'rollup-plugin-sourcemaps';
import buble from 'rollup-plugin-buble';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import replace from 'rollup-plugin-replace';
// import builtins from 'rollup-plugin-node-builtins';
// import globals from 'rollup-plugin-node-globals';
import {join} from 'path';

const inBase = join(__dirname, 'build', 'src');
const outBase = join(__dirname, 'build');

export default {
input: join(inBase, 'viewer', 'index.js'),
output: [{
file: join(outBase, 'viewer.js'),
sourcemap: true,
strict: true,
globals: {
d3: 'd3',
jquery: '$'
},
format: 'iife',
name: 'BLeakResultsViewer'
}],
external: ['d3', 'jquery'],
plugins: [
sourcemaps(),
buble({
transforms: {
// Assumes all `for of` statements are on arrays or array-like items.
dangerousForOf: true
}
}),
resolve({
// use "module" field for ES6 module if possible
module: true, // Default: true

// use "jsnext:main" if possible
// – see https://github.com/rollup/rollup/wiki/jsnext:main
jsnext: true, // Default: false

// use "main" field or index.js, even if it's not an ES6 module
// (needs to be converted from CommonJS to ES6
// – see https://github.com/rollup/rollup-plugin-commonjs
main: true, // Default: true

// some package.json files have a `browser` field which
// specifies alternative files to load for people bundling
// for the browser. If that's you, use this option, otherwise
// pkg.browser will be ignored
browser: true // Default: false
}),
commonjs({
namedExports: {
//'vis': ['Network', 'DataSet'],
'react-dom': ['render'],
'react': ['Component', 'createElement']
}
}),
replace({
// Production for production builds.
'process.env.NODE_ENV': JSON.stringify( 'development' )
})
// builtins(),
// globals()
]
};
2 changes: 1 addition & 1 deletion src/common/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {default as MITMProxy} from 'mitmproxy';
import MITMProxy from 'mitmproxy';
import {getInterceptor} from '../lib/mitmproxy_interceptor';
import {Log} from './interfaces';

Expand Down
3 changes: 2 additions & 1 deletion src/frontends/check_alt_strategies.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {HeapGrowthTracker, pathToString} from '../lib/growth_graph';
import {HeapGrowthTracker} from '../lib/growth_graph';
import pathToString from '../lib/path_to_string';
import {createReadStream, createWriteStream} from 'fs';
import HeapSnapshotParser from '../lib/heap_snapshot_parser';
import {createGunzip} from 'zlib';
Expand Down
3 changes: 2 additions & 1 deletion src/frontends/find_growing_paths.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {HeapGrowthTracker, pathToString} from '../lib/growth_graph';
import {HeapGrowthTracker} from '../lib/growth_graph';
import pathToString from '../lib/path_to_string';
import {createReadStream} from 'fs';
import * as readline from 'readline';
import {SnapshotNodeTypeToString, SnapshotEdgeTypeToString, SnapshotNodeType} from '../common/interfaces';
Expand Down
4 changes: 2 additions & 2 deletions src/lib/bleak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class BLeakDetector {

private _driver: ChromeDriver;
private readonly _progressBar: IProgressBar;
private readonly _configSource: string;
//private readonly _configSource: string;
private readonly _config: ConfigurationFile;
private readonly _growthTracker = new HeapGrowthTracker();
private _leakRoots: LeakRoot[] = [];
Expand All @@ -89,7 +89,7 @@ export class BLeakDetector {
private constructor(driver: ChromeDriver, progressBar: IProgressBar, configSource: string, snapshotCb: (sn: HeapSnapshotParser) => Promise<void> = defaultSnapshotCb) {
this._driver = driver;
this._progressBar = progressBar;
this._configSource = configSource;
//this._configSource = configSource;
this._config = getConfigFromSource(configSource);
this._snapshotCb = snapshotCb;
this._configInject = getConfigBrowserInjection(configSource);
Expand Down
16 changes: 3 additions & 13 deletions src/lib/chrome_driver.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import HeapSnapshotParser from '../lib/heap_snapshot_parser';
import {createSession} from 'chrome-debugging-client';
import {ISession as ChromeSession, IAPIClient as ChromeAPIClient, IBrowserProcess as ChromeProcess, IDebuggingProtocolClient as ChromeDebuggingProtocolClient} from 'chrome-debugging-client/dist/lib/types';
import {ISession as ChromeSession, IBrowserProcess as ChromeProcess} from 'chrome-debugging-client/dist/lib/types';
import {HeapProfiler as ChromeHeapProfiler, Network as ChromeNetwork, Console as ChromeConsole, Page as ChromePage, Runtime as ChromeRuntime, DOM as ChromeDOM} from "chrome-debugging-client/dist/protocol/tot";
import {accessSync} from 'fs';
import {join} from 'path';
Expand Down Expand Up @@ -124,41 +124,31 @@ export default class ChromeDriver {
// Disable service workers
await network.setBypassServiceWorker({ bypass: true });

const driver = new ChromeDriver(log, headless, mitmProxy, session, chromeProcess, client, debugClient, page, runtime, heapProfiler, network, chromeConsole, dom);
const driver = new ChromeDriver(log, headless, mitmProxy, chromeProcess, page, runtime, heapProfiler, chromeConsole);

return driver;
}

private _log: Log;
private _headless: boolean;
public readonly mitmProxy: MITMProxy;
private _session: ChromeSession;
private _process: ChromeProcess;
private _client: ChromeAPIClient;
private _debugClient: ChromeDebuggingProtocolClient;
private _page: ChromePage;
private _runtime: ChromeRuntime;
private _heapProfiler: ChromeHeapProfiler;
private _network: ChromeNetwork;
private _console: ChromeConsole;
private _dom: ChromeDOM;
private _loadedFrames = new Set<string>();
private _shutdown: boolean = false;

private constructor(log: Log, headless: boolean, mitmProxy: MITMProxy, session: ChromeSession, process: ChromeProcess, client: ChromeAPIClient, debugClient: ChromeDebuggingProtocolClient, page: ChromePage, runtime: ChromeRuntime, heapProfiler: ChromeHeapProfiler, network: ChromeNetwork, console: ChromeConsole, dom: ChromeDOM) {
private constructor(log: Log, headless: boolean, mitmProxy: MITMProxy, process: ChromeProcess, page: ChromePage, runtime: ChromeRuntime, heapProfiler: ChromeHeapProfiler, console: ChromeConsole) {
this._log = log;
this._headless = headless;
this.mitmProxy = mitmProxy;
this._session = session;
this._process = process;
this._client = client;
this._debugClient = debugClient;
this._runtime = runtime;
this._page = page;
this._heapProfiler = heapProfiler;
this._network = network;
this._console = console;
this._dom = dom;

this._console.messageAdded = (evt) => {
const m = evt.message;
Expand Down
4 changes: 0 additions & 4 deletions src/lib/closure_state_transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ function getProgramPrelude(statements: IfStatement[]): ExpressionStatement {
}]
},
generator: false,
expression: false,
async: false
}]).concat(statements)
},
Expand Down Expand Up @@ -407,7 +406,6 @@ function getScopeAssignment(functionVarName: string, scopeVarName: string): Expr
}]
},
generator: false,
expression: false,
async: false
},
kind: "init",
Expand Down Expand Up @@ -501,7 +499,6 @@ function getScopeProperties(names: string[]): Property[] {
}]
},
generator: false,
expression: false,
async: false
},
kind: "init",
Expand Down Expand Up @@ -534,7 +531,6 @@ function getScopeProperties(names: string[]): Property[] {
}]
},
generator: false,
expression: false,
async: false
},
kind: "init",
Expand Down
Loading

0 comments on commit 528700b

Please sign in to comment.