Skip to content

Commit

Permalink
Handle CPU tracks having no slices (#33)
Browse files Browse the repository at this point in the history
The CPU Slices track controller did not expect to see a CPU track having
no slices whatsoever. The exception arising from processing the
unexpected NULL in the query result resulted in subsequent attempts to
set up the controller again and thus create the same view again.

Signed-off-by: Christian W. Damus <[email protected]>
  • Loading branch information
cdamus authored Sep 13, 2023
1 parent deb4203 commit 9f0755f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ui/src/tracks/cpu_slices/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
} from '../../common/canvas_utils';
import {colorForThread} from '../../common/colorizer';
import {PluginContext} from '../../common/plugin_api';
import {LONG, NUM} from '../../common/query_result';
import {LONG, NUM, NUM_NULL} from '../../common/query_result';
import {
TPDuration,
TPTime,
Expand Down Expand Up @@ -81,7 +81,15 @@ class CpuSliceTrackController extends TrackController<Config, Data> {
const queryLastSlice = await this.query(`
select max(id) as lastSliceId from ${this.tableName('sched')}
`);
this.lastRowId = queryLastSlice.firstRow({lastSliceId: NUM}).lastSliceId;
const lastRowId = queryLastSlice.firstRow({lastSliceId: NUM_NULL})
.lastSliceId;
if (lastRowId === null) {
// There are no slices whatsoever to present.
this.lastRowId = -1;
this.maxDur = 0n;
return;
}
this.lastRowId = lastRowId;

const row = queryRes.firstRow({maxDur: LONG, rowCount: NUM});
this.maxDur = row.maxDur;
Expand Down

0 comments on commit 9f0755f

Please sign in to comment.