diff options
author | Lalit Maganti <lalitm@google.com> | 2024-05-06 14:35:42 +0100 |
---|---|---|
committer | Lalit Maganti <lalitm@google.com> | 2024-05-06 14:35:42 +0100 |
commit | cbf8c20ac2ac6502e82ed065ee16aacb4074a8df (patch) | |
tree | b721189ed8d28e79174582f47c925a4776da5c76 | |
parent | bfd465a5e6d77db584464a27dc7861842659a798 (diff) | |
download | perfetto-cbf8c20ac2ac6502e82ed065ee16aacb4074a8df.tar.gz |
ui: fix counter track invalidate handling
We were not correctly setting the limits/recreating the table when
the counter track properties were changed: make sure to do this.
Change-Id: Ife62cbc78e85def06c064e97c5c8c1e84df65eea
Bug: 338237477
-rw-r--r-- | ui/src/frontend/base_counter_track.ts | 65 |
1 files changed, 37 insertions, 28 deletions
diff --git a/ui/src/frontend/base_counter_track.ts b/ui/src/frontend/base_counter_track.ts index 91b0939ec..990e6a36d 100644 --- a/ui/src/frontend/base_counter_track.ts +++ b/ui/src/frontend/base_counter_track.ts @@ -451,33 +451,7 @@ export abstract class BaseCounterTrack implements Track { async onCreate(): Promise<void> { this.initState = await this.onInit(); - - const displayValueQuery = await this.engine.query(` - create virtual table ${this.getTableName()} - using __intrinsic_counter_mipmap(( - SELECT - ts, - ${this.getValueExpression()} as value - FROM (${this.getSqlSource()}) - )); - - select - min_value as minDisplayValue, - max_value as maxDisplayValue - from ${this.getTableName()}( - trace_start(), trace_end(), trace_dur() - ); - `); - - const {minDisplayValue, maxDisplayValue} = displayValueQuery.firstRow({ - minDisplayValue: NUM, - maxDisplayValue: NUM, - }); - - this.limits = { - minDisplayValue, - maxDisplayValue, - }; + this.limits = await this.createTableAndFetchLimits(false); } async onUpdate(): Promise<void> { @@ -498,7 +472,6 @@ export abstract class BaseCounterTrack implements Track { const {visibleTimeScale: timeScale} = globals.timeline; // In any case, draw whatever we have (which might be stale/incomplete). - const limits = this.limits; const data = this.counters; @@ -859,6 +832,10 @@ export abstract class BaseCounterTrack implements Track { ); } + if (this.limits === undefined) { + this.limits = await this.createTableAndFetchLimits(true); + } + const queryRes = await this.engine.query(` SELECT min_value as minDisplayValue, @@ -907,6 +884,38 @@ export abstract class BaseCounterTrack implements Track { raf.scheduleRedraw(); } + private async createTableAndFetchLimits( + dropTable: boolean, + ): Promise<CounterLimits> { + const dropQuery = dropTable ? `drop table ${this.getTableName()};` : ''; + const displayValueQuery = await this.engine.query(` + ${dropQuery} + create virtual table ${this.getTableName()} + using __intrinsic_counter_mipmap(( + select + ts, + ${this.getValueExpression()} as value + from (${this.getSqlSource()}) + )); + select + min_value as minDisplayValue, + max_value as maxDisplayValue + from ${this.getTableName()}( + trace_start(), trace_end(), trace_dur() + ); + `); + + const {minDisplayValue, maxDisplayValue} = displayValueQuery.firstRow({ + minDisplayValue: NUM, + maxDisplayValue: NUM, + }); + + return { + minDisplayValue, + maxDisplayValue, + }; + } + get unit(): string { return this.getCounterOptions().unit ?? ''; } |