aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/tensorboard
diff options
context:
space:
mode:
authorGravatar Dan Smilkov <dsmilkov@gmail.com>2016-04-25 08:54:21 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-04-25 10:02:50 -0700
commit9e4f8f61af7ae11ac5eb1d19be6b3baa42dae04d (patch)
treeebfe513549565fcac7823406bbf611d66c2e368e /tensorflow/tensorboard
parent0306d9134780a447c48369de7346cd5ac56cfdf7 (diff)
When the user switches tabs quickly, the zoom events contain NaNs that are now ignored. Also fix the minimap issue when the user tries zooming in before the scene is ready.
This should also fix the flaky test. Change: 120716688
Diffstat (limited to 'tensorflow/tensorboard')
-rw-r--r--tensorflow/tensorboard/components/tf-graph-common/lib/scene/minimap.ts8
-rw-r--r--tensorflow/tensorboard/components/tf-graph-common/lib/scene/scene.ts4
-rw-r--r--tensorflow/tensorboard/components/tf-tensorboard/test/fastTabSwitch.html14
-rw-r--r--tensorflow/tensorboard/components/tf-tensorboard/test/fastTabSwitch.ts30
-rw-r--r--tensorflow/tensorboard/components/tf-tensorboard/test/index.html1
5 files changed, 55 insertions, 2 deletions
diff --git a/tensorflow/tensorboard/components/tf-graph-common/lib/scene/minimap.ts b/tensorflow/tensorboard/components/tf-graph-common/lib/scene/minimap.ts
index 8a987e78ed..d044bada30 100644
--- a/tensorflow/tensorboard/components/tf-graph-common/lib/scene/minimap.ts
+++ b/tensorflow/tensorboard/components/tf-graph-common/lib/scene/minimap.ts
@@ -113,7 +113,7 @@ export class Minimap {
this.downloadCanvas =
<HTMLCanvasElement>$minimap.select("canvas.download").node();
d3.select(this.downloadCanvas).style("display", "none");
-
+ this.update();
}
/**
@@ -139,7 +139,7 @@ export class Minimap {
*/
update(): void {
// The origin hasn't rendered yet. Ignore making an update.
- if (this.zoomG.childElementCount === 0) {
+ if (this.zoomG == null || this.zoomG.childElementCount === 0) {
return;
}
let $download = d3.select("#graphdownload");
@@ -273,6 +273,10 @@ export class Minimap {
* @param scale The scaling factor, or none to use the last used one.
*/
zoom(translate?: [number, number], scale?: number): void {
+ if (this.scaleMinimap == null) {
+ // Scene is not ready yet.
+ return;
+ }
// Update the new translate and scale params, only if specified.
this.translate = translate || this.translate;
this.scaleMain = scale || this.scaleMain;
diff --git a/tensorflow/tensorboard/components/tf-graph-common/lib/scene/scene.ts b/tensorflow/tensorboard/components/tf-graph-common/lib/scene/scene.ts
index 1b6cb3a58c..8efde844a9 100644
--- a/tensorflow/tensorboard/components/tf-graph-common/lib/scene/scene.ts
+++ b/tensorflow/tensorboard/components/tf-graph-common/lib/scene/scene.ts
@@ -81,6 +81,10 @@ export let Class = {
export function fit(svg, zoomG, d3zoom, callback) {
let svgRect = svg.getBoundingClientRect();
let sceneSize = zoomG.getBBox();
+ if (sceneSize.width === 0) {
+ // There is no scene anymore.
+ return;
+ }
let scale = 0.9 * Math.min(
svgRect.width / sceneSize.width,
svgRect.height / sceneSize.height,
diff --git a/tensorflow/tensorboard/components/tf-tensorboard/test/fastTabSwitch.html b/tensorflow/tensorboard/components/tf-tensorboard/test/fastTabSwitch.html
new file mode 100644
index 0000000000..dce10f9c7d
--- /dev/null
+++ b/tensorflow/tensorboard/components/tf-tensorboard/test/fastTabSwitch.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src="../../webcomponentsjs/webcomponents-lite.min.js"></script>
+ <script src="../../web-component-tester/browser.js"></script>
+ <link rel="import" href="../../tf-imports/d3.html">
+ <link rel="import" href="../tf-tensorboard-demo.html">
+ <link rel="stylesheet" type="text/css" href="../../../lib/css/global.css">
+</head>
+<body>
+ <tf-tensorboard-demo no-hash="true" data-dir="data/"></tf-tensorboard-demo>
+ <script src="fastTabSwitch.js"></script>
+</body>
+</html>
diff --git a/tensorflow/tensorboard/components/tf-tensorboard/test/fastTabSwitch.ts b/tensorflow/tensorboard/components/tf-tensorboard/test/fastTabSwitch.ts
new file mode 100644
index 0000000000..20e2edc3b7
--- /dev/null
+++ b/tensorflow/tensorboard/components/tf-tensorboard/test/fastTabSwitch.ts
@@ -0,0 +1,30 @@
+describe('fast tab switch', () => {
+ let assert = chai.assert;
+ window.HTMLImports.whenReady(() => {
+ let tb = d3.select('tf-tensorboard');
+ var tabs = (<any>tb.node()).$.tabs;
+
+ // This test will select the events tab. Once the events tab
+ // renders, will select the graph tab, and immediately select
+ // the images tab wihout waiting for the graph tab to finish
+ // rendering. Finally, it finishes when the images tab
+ // has rendered and no errors were thrown.
+ let eventsTabIndex = TF.TensorBoard.TABS.indexOf('events');
+ let imagesTabIndex = TF.TensorBoard.TABS.indexOf('images');
+ let graphTabIndex = TF.TensorBoard.TABS.indexOf('graphs');
+
+ // Listen for when the events tab rendered.
+ tb.on('rendered', () => {
+ it('switching to graph tab and immediately to images', done => {
+ // Select the graph tab.
+ tabs.set('selected', graphTabIndex);
+ // Interrupt graph rendering by immediately selecting the images tab
+ // and finish when the images tab has rendered.
+ tb.on('rendered', () => done());
+ tabs.set('selected', imagesTabIndex);
+ });
+ });
+ // Select the events tab.
+ tabs.set('selected', eventsTabIndex);
+ });
+});
diff --git a/tensorflow/tensorboard/components/tf-tensorboard/test/index.html b/tensorflow/tensorboard/components/tf-tensorboard/test/index.html
index a07e12105f..e665ab28d9 100644
--- a/tensorflow/tensorboard/components/tf-tensorboard/test/index.html
+++ b/tensorflow/tensorboard/components/tf-tensorboard/test/index.html
@@ -10,6 +10,7 @@
WCT.loadSuites([
'tensorboardTests.html',
'e2eTests.html',
+ 'fastTabSwitch.html'
]);
</script>
</body>