Skip to content

Commit f475559

Browse files
underootgithub-actions[bot]
authored andcommitted
Symbol UBO uniforms update with 0-duration transition
GitOrigin-RevId: 576f15281661723089e261d38fff7cfc65d47b04
1 parent 23948cd commit f475559

6 files changed

Lines changed: 178 additions & 1 deletion

File tree

src/data/bucket/symbol_property_binder_ubo.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ export class SymbolPropertyBinderUBO {
170170
cachedConstantUniforms: ConstantUniformValues | null;
171171
cachedConstantRenderZoom: number | null;
172172
cachedConstantBrightness: number | null | undefined;
173+
// Identity of the layer.paint object the cache was computed from. layer.recalculate() produces a
174+
// fresh paint object on every Style.update() a paint/config change triggers, so an identity change
175+
// means constant paint values may have changed. Guards against a stale cached color when a paint
176+
// update does not come with a live transition (e.g. root transition {duration: 0}); see #13702.
177+
cachedConstantPaint: object | null;
173178

174179
// Tracks current active appearance per vtFeatureIndex (main-thread only, excluded from serialization).
175180
activeAppearanceByVtIndex?: Map<number, SymbolAppearance | null>;
@@ -214,6 +219,7 @@ export class SymbolPropertyBinderUBO {
214219
this.cachedConstantUniforms = null;
215220
this.cachedConstantRenderZoom = null;
216221
this.cachedConstantBrightness = undefined;
222+
this.cachedConstantPaint = null;
217223

218224
this.activeAppearanceByVtIndex = null;
219225

@@ -1016,9 +1022,13 @@ export class SymbolPropertyBinderUBO {
10161022

10171023
// Cache hit: zoom factors depend on renderZoom too, so we must also invalidate on
10181024
// renderZoom change when any property is zoom-dependent.
1025+
// cachedConstantPaint guards against stale constant colors when a paint update arrives without
1026+
// a live transition (e.g. root transition {duration: 0}); layer.recalculate() produces a fresh
1027+
// layer.paint object whenever a paint/config change is applied.
10191028
// Truthy check (not !== null) because the field may be undefined after worker→main
10201029
// transfer (constructor is not called during deserialization, omitted fields stay undefined).
10211030
if (this.cachedConstantUniforms &&
1031+
this.cachedConstantPaint === this.layer.paint &&
10221032
this.cachedConstantBrightness === brightness &&
10231033
((!hasCameraExpr && !hasZoomDep) || this.cachedConstantRenderZoom === renderZoom)) {
10241034
return this.cachedConstantUniforms;
@@ -1092,6 +1102,7 @@ export class SymbolPropertyBinderUBO {
10921102
this.cachedConstantUniforms = result;
10931103
this.cachedConstantRenderZoom = renderZoom;
10941104
this.cachedConstantBrightness = brightness;
1105+
this.cachedConstantPaint = this.layer.paint;
10951106
return result;
10961107
}
10971108

@@ -1144,4 +1155,4 @@ export class SymbolPropertyBinderUBO {
11441155
// 'layer' is omitted because SymbolStyleLayer is not serializable. It must be re-assigned on
11451156
// the main thread before any main-thread method (getConstantUniformValues, bind, etc.) is called.
11461157
// See draw_symbol.ts: `buffers.uboBinder.layer = layer` before drawSymbolElements().
1147-
register(SymbolPropertyBinderUBO, 'SymbolPropertyBinderUBO', {omit: ['layer', 'cachedConstantUniforms', 'cachedConstantRenderZoom', 'cachedConstantBrightness', 'activeAppearanceByVtIndex', 'featureVertexRangesFromId', 'featureVertexRangesFromVtIndex']});
1158+
register(SymbolPropertyBinderUBO, 'SymbolPropertyBinderUBO', {omit: ['layer', 'cachedConstantUniforms', 'cachedConstantRenderZoom', 'cachedConstantBrightness', 'cachedConstantPaint', 'activeAppearanceByVtIndex', 'featureVertexRangesFromId', 'featureVertexRangesFromVtIndex']});
1.39 KB
Loading
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"network": [
3+
[
4+
"probeNetwork - default - end",
5+
1,
6+
84942
7+
],
8+
[
9+
"probeNetwork - default - start",
10+
0,
11+
0
12+
]
13+
],
14+
"gfx": [
15+
[
16+
"probeGFX - default - end",
17+
1,
18+
3,
19+
5,
20+
1,
21+
[
22+
18667,
23+
18667
24+
],
25+
[
26+
196716,
27+
196716
28+
],
29+
[
30+
768,
31+
768
32+
]
33+
]
34+
]
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"network": [
3+
[
4+
"probeNetwork - default - end",
5+
1,
6+
84942
7+
],
8+
[
9+
"probeNetwork - default - start",
10+
0,
11+
0
12+
]
13+
],
14+
"gfx": [
15+
[
16+
"probeGFX - default - end",
17+
1,
18+
3,
19+
5,
20+
1,
21+
[
22+
18667,
23+
18667
24+
],
25+
[
26+
196716,
27+
196716
28+
],
29+
[
30+
768,
31+
768
32+
]
33+
]
34+
]
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"network": [
3+
[
4+
"probeNetwork - default - end",
5+
1,
6+
84942
7+
],
8+
[
9+
"probeNetwork - default - start",
10+
0,
11+
0
12+
]
13+
],
14+
"gfx": [
15+
[
16+
"probeGFX - default - end",
17+
1,
18+
0,
19+
0,
20+
0,
21+
[
22+
0,
23+
0
24+
],
25+
[
26+
0,
27+
0
28+
],
29+
[
30+
0,
31+
0
32+
]
33+
]
34+
]
35+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"version": 8,
3+
"metadata": {
4+
"test": {
5+
"description": "Regression test for public-13702: setPaintProperty on symbol text-halo-color must render even when the style has a root-level zero-duration transition. Without the fix the halo stays white (cached constant symbol paint is never invalidated when no transition is live); with the fix it renders red.",
6+
"width": 64,
7+
"height": 64,
8+
"operations": [
9+
[
10+
"setPaintProperty",
11+
"symbol",
12+
"text-halo-color",
13+
"red"
14+
]
15+
]
16+
}
17+
},
18+
"transition": {
19+
"duration": 0,
20+
"delay": 0
21+
},
22+
"sources": {
23+
"geojson": {
24+
"type": "geojson",
25+
"data": {
26+
"type": "Point",
27+
"coordinates": [
28+
0,
29+
0
30+
]
31+
}
32+
}
33+
},
34+
"glyphs": "local://glyphs/{fontstack}/{range}.pbf",
35+
"layers": [
36+
{
37+
"id": "background",
38+
"type": "background",
39+
"paint": {
40+
"background-color": "black"
41+
}
42+
},
43+
{
44+
"id": "symbol",
45+
"type": "symbol",
46+
"source": "geojson",
47+
"layout": {
48+
"text-field": "ABC",
49+
"text-font": [
50+
"Open Sans Semibold",
51+
"Arial Unicode MS Bold"
52+
]
53+
},
54+
"paint": {
55+
"text-color": "black",
56+
"text-halo-width": 2,
57+
"text-halo-color": "white"
58+
}
59+
}
60+
]
61+
}

0 commit comments

Comments
 (0)