diff options
author | 2016-04-26 12:33:16 -0800 | |
---|---|---|
committer | 2016-04-26 13:42:13 -0700 | |
commit | f037135f5e51559e766ee471f4888807a257a1fd (patch) | |
tree | c0b10c4305f871ddfbc53e0fe8fed64a0e5fb70c | |
parent | 791a664aef6005187128e06da07e593154f1ea92 (diff) |
Fix flaky test failure in firefox where asking for bounding box of an svg element that has been detached from the dom produces NS_ERROR_FAILURE
Change: 120846455
-rw-r--r-- | tensorflow/tensorboard/components/tf-graph-common/lib/scene/minimap.ts | 15 | ||||
-rw-r--r-- | tensorflow/tensorboard/components/tf-graph-common/lib/scene/scene.ts | 13 |
2 files changed, 21 insertions, 7 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 db6fcfee57..40030122de 100644 --- a/tensorflow/tensorboard/components/tf-graph-common/lib/scene/minimap.ts +++ b/tensorflow/tensorboard/components/tf-graph-common/lib/scene/minimap.ts @@ -138,8 +138,17 @@ export class Minimap { * was updated (e.g. when a node was expanded). */ update(): void { - // The origin hasn't rendered yet. Ignore making an update. - if (this.zoomG == null || this.zoomG.childElementCount === 0) { + let sceneSize = null; + try { + // Get the size of the entire scene. + sceneSize = this.zoomG.getBBox(); + if (sceneSize.width === 0) { + // There is no scene anymore. We have been detached from the dom. + return; + } + } catch (e) { + // Firefox produced NS_ERROR_FAILURE if we have been + // detached from the dom. return; } let $download = d3.select('#graphdownload'); @@ -182,8 +191,6 @@ export class Minimap { let zoomTransform = $zoomG.attr('transform'); $zoomG.attr('transform', null); - // Get the size of the entire scene. - let sceneSize = this.zoomG.getBBox(); // Since we add padding, account for that here. sceneSize.height += this.labelPadding * 2; sceneSize.width += this.labelPadding * 2; 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 d5c63f89ce..0451fb308d 100644 --- a/tensorflow/tensorboard/components/tf-graph-common/lib/scene/scene.ts +++ b/tensorflow/tensorboard/components/tf-graph-common/lib/scene/scene.ts @@ -78,9 +78,16 @@ 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. + let sceneSize = null; + try { + sceneSize = zoomG.getBBox(); + if (sceneSize.width === 0) { + // There is no scene anymore. We have been detached from the dom. + return; + } + } catch (e) { + // Firefox produced NS_ERROR_FAILURE if we have been + // detached from the dom. return; } let scale = 0.9 * Math.min( |