Fills and Labels stopped working in latest beta191 (GPU)

We found that our fills and labels dont show up anymore in the latest beta191 when switching to GPU. Here is a repro project.

Translation produces the fill, outline and label layers without warnings. Offline inspection also confirmed that native tile cutting preserves the polygon and label attribute, and geometry preparation produces a fill bucket with four vertices and six indices. The fill therefore appears to reach geometry preparation, but disappears during rendering.

There are no PMTiles overrides, external data sources, projection converters or highlights in this reproduction. Live style changes use a fresh MapStyle with SetStyleAsync, retaining the source and GPU host.

Could you investigate the polygon fill drawing path on this native grid? We also observed missing labels in our application, but that issue does not reproduce here and should be treated separately.

GpuFillRepro.zip (6.0 KB)

I just saw beta192 has been released - tested, and fills work again. Labels are still broken in our application. None show up. Investigating further.

Labels still disappear in our application when switching to GPU, while classic rendering displays them correctly. Labels work in the standalone repro, so we have not isolated this remaining issue to the SDK.

Below is our application’s label path. The attached files contain the complete translation and style-copying helpers.

We construct the classic TextStyle from the selected field, font and color:

var style = new TextStyle(
    LabelingField,
    new GeoFont(splitStyle[0], fontSize, GetFontStyle()),
    new GeoSolidBrush(ParseGeoColor(ColorText)));

if (GeoType == GeoType.Point)
    style.TextPlacement = TextPlacement.AutoPlacement;
else
    style.OffsetFromLine =
        (float)Math.Max(LineStyle.OutlineWidth + 3 + fontSize / 3, 7);

if (HasNonTextCustomStyles(layer))
{
    layer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = null;
    layer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(style);
}
else
{
    layer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = style;
}

Before this, we remove existing top-level TextStyle entries from CustomStyles. Geometry setup sets:

zoom.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

Notice that our OffsetFromLine assignment applies to polygons as well as lines. The standalone repro does not set it.

For GPU rendering, we create an independent runtime layer/reader and copy the classic styles. This copying also happens before restyling:

featureLayer.ZoomLevelSet =
    FeatureLayerRenderStyles.CopyZoomLevels(original.ZoomLevelSet);

featureLayer.Opacity = original.Opacity;

Here is the actual copying implementation. In particular, the copied zoom levels are stored in CustomZoomLevels:

internal static ZoomLevelSet CopyZoomLevels(ZoomLevelSet original)
{
    ZoomLevelSet copy = new()
    {
        TileSize = original.TileSize,
        MaxExtent = original.MaxExtent == null
            ? null
            : (RectangleShape)original.MaxExtent.CloneDeep()
    };

    foreach (ZoomLevel level in original.GetZoomLevels())
    {
        ZoomLevel cloned = new(level.Scale)
        {
            IsActive = level.IsActive,
            Name = level.Name,
            UseLegacyLabeling = level.UseLegacyLabeling,
            ApplyUntilZoomLevel = level.ApplyUntilZoomLevel,
            DefaultAreaStyle =
                (AreaStyle)level.DefaultAreaStyle?.CloneDeep(),
            DefaultLineStyle =
                (LineStyle)level.DefaultLineStyle?.CloneDeep(),
            DefaultPointStyle =
                (PointStyle)level.DefaultPointStyle?.CloneDeep(),
            DefaultTextStyle =
                (TextStyle)level.DefaultTextStyle?.CloneDeep()
        };

        foreach (Style style in level.CustomStyles)
            cloned.CustomStyles.Add(style.CloneDeep());

        copy.CustomZoomLevels.Add(cloned);
    }

    return copy;
}

The GPU source uses our native EPSG:25832 grid:

FeatureSourceVectorTileSource source = new(
    new RectangleShape(0, 10_000_000, 1_000_000, 0),
    GeographyUnit.Meter)
{
    SourceId = "agk_" + layerId.ToString("N"),
    MaxConcurrentEncodes = 1
};

source.MaxDataZoom = source.TileMatrixSet.TileMatrices.Count - 1;
source.FeatureSources.Add("features", featureLayer.FeatureSource);

For opaque layers, we translate once. For translucent layers containing labels, we translate geometry and labels separately so labels remain fully opaque. Both translations share the same source:

internal static GpuLayerTranslation Translate(
    FeatureLayer layer,
    FeatureSourceVectorTileSource source)
{
    Collection<double> scales = source.TileMatrixSet.GetScales();
    ZoomLevelSet originalStyles = layer.ZoomLevelSet;
    double originalOpacity = layer.Opacity;

    ZoomLevelSet labelStyles = originalOpacity < 1
        ? FeatureLayerRenderStyles.CopyForPass(
            originalStyles, labelsOnly: true)
        : null;

    if (labelStyles == null
        || !FeatureLayerRenderStyles.HasLabels(labelStyles))
    {
        return new(TranslateShapes());
    }

    try
    {
        layer.ZoomLevelSet = FeatureLayerRenderStyles.CopyForPass(
            originalStyles, labelsOnly: false);

        FeatureLayerTranslation shapes = TranslateShapes();
        shapes.Source.SourceId = shapes.SourceId;

        layer.ZoomLevelSet = labelStyles;
        layer.Opacity = 1;

        FeatureLayerTranslation labels =
            FeatureLayerTranslator.Translate(
                layer, shapes.Source, scales);

        return new(shapes, labels);
    }
    finally
    {
        layer.ZoomLevelSet = originalStyles;
        layer.Opacity = originalOpacity;
    }

    FeatureLayerTranslation TranslateShapes() =>
        FeatureLayerTranslator.Translate(layer, source, scales);
}

CopyForPass and HasLabels are included in the attached FeatureLayerRenderStyles.cs. The split is not used at 100% layer opacity.

We compose a fresh MapStyle for each change. The wrapper adds both translations when a separate label pass exists:

internal void AddTo(MapStyle style)
{
    style.AddFeatureLayer(shapes);

    if (labels != null)
        style.AddFeatureLayer(labels);
}

After adding the translations, we set visibility on every translated layer, including labels:

translation.AddTo(composed);

foreach (var translatedLayer in translation.Layers)
{
    composed.SetLayerVisibility(
        translatedLayer.Id,
        layer.MapLayerIsVisible);
}

Initial display uses new GpuBasemap(composed). Subsequent style changes use:

await basemap.SetStyleAsync(composed);

The runtime reader and vector source remain alive across restyles. Translation warnings cause classic fallback rather than silently accepting an incomplete translation.

Could you check whether anything in this path explains the difference from the working repro—particularly the copied CustomZoomLevels, polygon OffsetFromLine, or composition of the separate label translation?

Hi Julian,

The fills were ours. A change in beta191 sent every fill built through the C# API down a path where it lost its colour, and beta192 puts it back.

On the labels, all three of the things you pointed at are clear:

Polygon OffsetFromLine is dropped on purpose — a polygon label is placed as a point, and the offset is only read for line placement. Two translations sharing one source is fine: the second registration keeps the name when the source is the same object. And CustomZoomLevels is fine too — I built your shape here, one layer with its ZoomLevelSet swapped between a shapes pass and a labels pass, levels copied into CustomZoomLevels, every translated layer then told it is visible, and the label layer compiles and stays visible, including when a shape layer is hidden.

So can you try beta190 and let me know if it works? If your labels come back on 190, the cause is one of those three and we can keep digging in. If they are still missing on 190, this did not start with the upgrade and we are looking in the wrong place.

Thanks,
Ben

Hi Ben, we tried beta182 and still saw no labels on GPU. Is that good enough?
Additionally, we also noticed that our highlights don’t work anymore in the latest beta:

Native-grid highlights rejected and GPU teardown tasks outlive their resources

On beta193, our map uses an EPSG:25832 tile grid with root bounds
(-4500000, 0) – (5500000, 10000000). Static feature layers render through
FeatureSourceVectorTileSource. We publish selection polygons, lines and points
through retained InMemoryGeometrySource objects attached with
MapStyle.AddGeometry(source).

All three highlight types remain invisible, even after panning or zooming. Classic
highlight overlays display the same selections correctly. SetStyleAsync rejects
the style with this explanation:

This map’s coordinates are on a projected grid (-4500000, 0) - (5500000, 10000000), and a data overlay reaches the engine through a conversion whose target is web mercator. Its values would be laid down on a plane the map is not on - drawn, in the wrong place, and without complaint. Data overlays are available on a mercator map.

Could dynamic geometry accept coordinates in the host’s native grid, without
converting them to Web Mercator? This is needed for frequently changing selections
without translating and recutting tiled snapshots.

Our application incorrectly retried this rejection by replacing the GPU host.
We have corrected that routing: classic highlight overlays stay above the GPU
basemap, and the unsupported registrations are no longer submitted. During those
replacements, however, the SDK also produced repeated unobserved task exceptions:

ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Threading.SemaphoreSlim'.
  at System.Threading.SemaphoreSlim.Release(Int32 releaseCount)
  at ThinkGeo.Gpu.GpuMapController.a(E, MatrixCell, CancellationToken)

ObjectDisposedException: The CancellationTokenSource has been disposed.
  at System.Threading.CancellationTokenSource.get_Token()
  at ThinkGeo.Gpu.GpuMapController.I()

Please ensure host disposal waits for or safely cancels in-flight tile work before
disposing its synchronization resources, and observes task failures.

Hi Julian,

Beta182 answers it the other way round: it is older than 190, so the labels did not start failing
with the upgrade. The three things I checked stay clear, and comparing betas is no longer the
right axis — the difference is between your application and the repro, where labels do work.

So: have GPU labels ever worked in your application? The thread only says classic renders them
correctly. If they have never appeared on GPU this is not a regression, and we should compare your
label path against the repro instead. If you want to narrow it yourself, start from the working
repro and add your pieces one at a time until they disappear.

The disposal exceptions are fixed in beta194. Host disposal was releasing the token source and
the tile gates while tile work was still using them. It now cancels without releasing them, so
neither exception can occur.

Native-grid highlights work as of beta194. A tile grid can now name its coordinate system, and
so can a geometry source. When both name the same one the geometry is drawn as it is — nothing is
converted, because your coordinates are already the map’s own:

var grid = TileMatrixSet.CreateTileMatrixSet(
    512, new RectangleShape(-4500000, 10000000, 5500000, 0), new Projection(25832), 20);

var tiles = new FeatureSourceVectorTileSource(grid);
tiles.FeatureSources.Add("static", yourFeatureSource);

var selection = new InMemoryGeometrySource(new Projection(25832));
style.AddGeometry(selection);

Both halves have to name it. A source that names none is still assumed to be web mercator and
refused on a projected map — but now by name, telling you which two systems disagree. The unit
comes from the projection, so metres and degrees can no longer contradict each other.

Thanks,
Ben

Hi Ben:

I downloaded the latest beta197.

Labels show again! However, we found following issues (You previously already fixed them, but they reappeared?):

As you can see, labels are squished - we enabled them while zoomed in, and after zooming out they are at the edge instead of the center. Panning, Zooming etc. does not fix this either, I need to completely remove / toggle visibility of the layer for the labels to fix themselves:

Be aware, CPU does NOT have this issue. The labels are correctly positioned the first time there.

Hi Julian,

It’s recreated and fixed in beta199, have a try.

Thanks,
Ben

1 Like