Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove initial loading based on viewport. #865

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions plugin/trace_viewer/tf_trace_viewer/tf-trace-viewer-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,16 @@ var tf_component_traceviewer;
};
}
tf_component_traceviewer.debounce = debounce;
/**
* Check whether the given range is valid. A range is considered valid if:
* 1. it has a min and max
* 2. min <= max
* @param {?Object} range The range to check.
* @return {boolean} Whether the range is valid.
*/
function isValidRange(range) {
return range != undefined && range.min != undefined &&
range.max != undefined && range.min <= range.max;
}
tf_component_traceviewer.isValidRange = isValidRange;
})(tf_component_traceviewer || (tf_component_traceviewer = {})); // namespace tf_component_traceviewer
12 changes: 5 additions & 7 deletions plugin/trace_viewer/tf_trace_viewer/tf-trace-viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@
this._displayOverlay('Trace Viewer', 'Trace data URL is not provided.');
return null;
}
this._init(this.currentViewportRange);
this._init();
this._adjustUI();

window.addEventListener('load', function(e) {
Expand Down Expand Up @@ -745,7 +745,7 @@
Polymer.dom(this._traceViewer.leftControls).insertBefore(helpButton, perfettoSelector);
},

_init: async function(initialViewportRange) {
_init: async function() {
if (this._isStreaming) {
// TODO(yinzz) cleanup hosts and process filter code later when the new filtering rolls out
if (!this._showFilterForm) {
Expand All @@ -758,11 +758,7 @@
this._createDetailFilter();
this._createPerfettoButton();
}
let initialRequestedRange = null;
if (initialViewportRange) {
initialRequestedRange = this._calcFetchRange(initialViewportRange);
}
this._loadTrace(initialRequestedRange, /* replaceModel= */ true);
this._loadTrace(null, /* replaceModel= */ true);
},

_loadTrace: async function(requestedRange, replaceModel) {
Expand Down Expand Up @@ -848,6 +844,8 @@
var zoomFactor =
tf_component_traceviewer.length(this._loadedRange) /
tf_component_traceviewer.length(fetch);
// if fetch range is invalid, do not request data
if (!tf_component_traceviewer.isValidRange(fetch)) return;
if (
!tf_component_traceviewer.within(preserve, this._loadedRange) ||
zoomFactor > tf_component_traceviewer.ZOOM_RATIO
Expand Down
Loading