Skip to content

Commit 4c399d8

Browse files
mournergithub-actions[bot]
authored andcommitted
Fix a performance regression with incremental setFeatureState
GitOrigin-RevId: 3844f65796dd9ccff2022aec015bf92254b902a8
1 parent 920bba0 commit 4c399d8

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/source/source_state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class SourceFeatureState {
167167

168168
for (const id in tiles) {
169169
const tile = tiles[id];
170-
tile.refreshFeatureState(painter);
170+
tile.refreshFeatureState(painter, featuresChanged);
171171
}
172172
}
173173
}

src/source/tile.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import type Context from '../gl/context';
4242
import type {CanonicalTileID, OverscaledTileID} from './tile_id';
4343
import type Framebuffer from '../gl/framebuffer';
4444
import type Transform from '../geo/transform';
45-
import type {FeatureStates} from './source_state';
45+
import type {FeatureStates, LayerFeatureStates} from './source_state';
4646
import type {Cancelable} from '../types/cancelable';
4747
import type {FilterSpecification} from '../style-spec/types';
4848
import type {TilespaceQueryGeometry} from '../style/query_geometry';
@@ -674,12 +674,12 @@ class Tile {
674674
}
675675
}
676676

677-
refreshFeatureState(painter?: Painter) {
677+
refreshFeatureState(painter?: Painter, states?: LayerFeatureStates) {
678678
if (!this.latestFeatureIndex || !(this.latestFeatureIndex.rawTileData || this.latestFeatureIndex.is3DTile) || !painter) {
679679
return;
680680
}
681681

682-
this.updateBuckets(painter);
682+
this.updateBuckets(painter, false, states);
683683
}
684684

685685
hasAppearances(painter: Painter) {
@@ -692,7 +692,7 @@ class Tile {
692692
return false;
693693
}
694694

695-
updateBuckets(painter: Painter, isBrightnessChanged?: boolean) {
695+
updateBuckets(painter: Painter, isBrightnessChanged?: boolean, states?: LayerFeatureStates) {
696696
if (!this.latestFeatureIndex) return;
697697
if (!painter.style) return;
698698

@@ -708,8 +708,8 @@ class Tile {
708708
const sourceLayerId = bucketLayer['sourceLayer'] || '_geojsonTileLayer';
709709
const sourceCache = painter.style.getLayerSourceCache(bucketLayer);
710710

711-
let sourceLayerStates: FeatureStates = {};
712-
if (sourceCache) {
711+
let sourceLayerStates: FeatureStates = (states && states[sourceLayerId]) || {};
712+
if (!states) { // only fetch the full state if it's not an incremental state update
713713
sourceLayerStates = sourceCache._state.getState(sourceLayerId, undefined) as FeatureStates;
714714
}
715715

0 commit comments

Comments
 (0)