Skip to content

Commit

Permalink
Clamp computed world range to absolute range
Browse files Browse the repository at this point in the history
Clamp the computed requested world range (which adds a buffer to the
left and right of the view range) to the limits of the absolute range.

This prevents unnecessary row updates because the row's provided model
range is always clamped.

Reject row data received during full search for an outdated world range.

Signed-off-by: Patrick Tasse <[email protected]>
  • Loading branch information
PatrickTasse committed Sep 19, 2024
1 parent 2ea4281 commit 1ef4e42
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
11 changes: 5 additions & 6 deletions timeline-chart/src/layer/time-graph-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ export class TimeGraphChart extends TimeGraphChartLayer {
}
const visibleRowIds = this.getVisibleRowIds(VISIBLE_ROW_BUFFER);
const { viewRange } = this.unitController;
const worldRange = this.stateController.computeWorldRangeFromViewRange();
const resolutionFactor = fine ? FINE_RESOLUTION_FACTOR : this._coarseResolutionFactor;
const resolution = (resolutionFactor * Number(this.unitController.viewRangeLength)) / this.stateController.canvasDisplayWidth;
// Compute the visible rowIds to fetch. Fetch all visible rows if update flag is set,
Expand All @@ -517,16 +518,11 @@ export class TimeGraphChart extends TimeGraphChartLayer {
!rowComponent.providedModel ||
viewRange.start < rowComponent.providedModel.range.start || // This logic can be updated for pre-rendering before we reach the end.
viewRange.end > rowComponent.providedModel.range.end || // This logic can be updated for pre-rendering before we reach the end.
!isEqual(this.stateController.worldRange, rowComponent.providedModel.range) ||
!isEqual(worldRange, rowComponent.providedModel.range) ||
resolution < rowComponent.providedModel.resolution || !isEqual(rowComponent.providedModel.filterExpressionsMap, this._filterExpressionsMap)
);
});
if (rowIds.length > 0) {
// When we fetch data, update the world range from the current view range.
// Only on coarse renders
// Only if we are updating all rows and not increasing vertical height. See: https://github.com/eclipse-cdt-cloud/theia-trace-extension/pull/832#issuecomment-1259902534.
const allRowsUpdated = rowIds.length === visibleRowIds.length;
const worldRange = allRowsUpdated ? this.stateController.computeWorldRangeFromViewRange() : this.stateController.worldRange;
const additionalParams: { [key: string]: any } = {};
if (this._filterExpressionsMap) {
additionalParams['filter_query_parameters'] = {'filter_expressions_map': this._filterExpressionsMap, 'strategy': fullSearch ? 'DEEP' : 'SAMPLED'};
Expand Down Expand Up @@ -606,6 +602,9 @@ export class TimeGraphChart extends TimeGraphChartLayer {
this.stateController.worldRange = request.worldRange;
this.stateController.worldZoomFactor = this.stateController.zoomFactor;
this.stateController.resetScale();
} else if (!isEqual(request.worldRange, this.stateController.worldRange)) {
// response discarded because world range updated
return Promise.reject(new Error("Request for outdated world range"));
}
this.addOrUpdateRows(rowData);
if (this.isNavigating) {
Expand Down
10 changes: 8 additions & 2 deletions timeline-chart/src/time-graph-state-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,14 @@ export class TimeGraphStateController {

computeWorldRangeFromViewRange() {
const deltaV = this.unitController.viewRange.end - this.unitController.viewRange.start;
const start = this.unitController.viewRange.start - BIMath.multiply(deltaV, this.unitController.worldRenderFactor);
const end = this.unitController.viewRange.end + BIMath.multiply(deltaV, this.unitController.worldRenderFactor);
let start = this.unitController.viewRange.start - BIMath.multiply(deltaV, this.unitController.worldRenderFactor);
let end = this.unitController.viewRange.end + BIMath.multiply(deltaV, this.unitController.worldRenderFactor);
if (start < 0) {
start = BigInt(0);
}
if (end > this.unitController.absoluteRange) {
end = this.unitController.absoluteRange;
}
return { start, end };
}

Expand Down

0 comments on commit 1ef4e42

Please sign in to comment.