diff options
author | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2024-05-07 08:34:18 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-05-07 08:34:18 +0000 |
commit | 16f039d5ac2c7a6aa93c1dfc65af3fd6ece7e571 (patch) | |
tree | 03c3700214eb78efa491b45b7312ab04920d0a19 | |
parent | b4ecb22eb48d1b3368c6410b4c182804eef3d65b (diff) | |
parent | cbf8c20ac2ac6502e82ed065ee16aacb4074a8df (diff) | |
download | perfetto-16f039d5ac2c7a6aa93c1dfc65af3fd6ece7e571.tar.gz |
Merge "ui: fix counter track invalidate handling" into main
-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 ?? ''; } |