maplibre / maplibre-native

MapLibre Native - Interactive vector tile maps for iOS, Android and other platforms.
https://maplibre.org
BSD 2-Clause "Simplified" License
1.01k stars 296 forks source link

Text rendering issue in symbol layer when map is rotated/tilted #2788

Open westnordost opened 2 weeks ago

westnordost commented 2 weeks ago

Describe the bug

When the map is tilted or rotated, text labels in a symbol layer are sometimes not rendered at all or rendered in a warped way. (As seen in the video) the warping seems to persist when rotating back to tilt=0, rotation=0

https://github.com/user-attachments/assets/7c24179a-d3a1-4796-ab85-1cf8423dbea1

(This video was made with Android 9, Moto X4.)

https://github.com/user-attachments/assets/43990869-703a-44c4-837c-df16c7039cf8

To Reproduce Reproducible with https://github.com/streetcomplete/StreetComplete/releases/tag/v59.0-alpha2

Style affected:

SymbolLayer("pin-cluster-layer", SOURCE)
  .withFilter(all(
    gte(zoom(), 13f),
    lte(zoom(), CLUSTER_MAX_ZOOM),
    gt(toNumber(get("point_count")), 1)
  ))
  .withProperties(
    iconImage("cluster-circle"),
    iconSize(sum(literal(0.5f), division(log2(get("point_count")), literal(10f)))),
    textField(get("point_count")),
    textFont(arrayOf("Roboto Regular")),
    textOffset(arrayOf(0f, 0.1f)),
    textSize(sum(literal(15f), division(log2(get("point_count")), literal(1.5f)))),
    iconAllowOverlap(true),
    textAllowOverlap(true),
)

Expected behavior Text renders correctly

Platform information:

Additional context

Originally reported in https://github.com/streetcomplete/StreetComplete/issues/5859

So far, the same issue could NOT be reproduced for the following layer, even though it is also a symbol layer with text:

SymbolLayer("overlay-symbols", SOURCE)
  .withFilter(all(
    gte(zoom(), 17f),
    isPoint()
  ))
  .withProperties(
    iconImage(get("icon")),
    iconSize(interpolate(linear(), zoom(), stop(17, 0.5f), stop(19, 1f))),
    textField(get("label")),
    textFont(arrayOf("Roboto Regular")),
    textAnchor(Property.TEXT_ANCHOR_TOP),
    textOffset(switchCase(has("icon"), literal(arrayOf(0f, 1f)), literal(arrayOf(0f, 0f)))),
    textSize(16 * context.resources.configuration.fontScale),
    textColor(if (isNightMode) "#ccf" else "#124"),
    textHaloColor(if (isNightMode) "#2e2e48" else "#fff"),
    textHaloWidth(2.5f),
    iconColor(if (isNightMode) "#ccf" else "#124"),
    iconHaloColor(if (isNightMode) "#2e2e48" else "#fff"),
    iconHaloWidth(2.5f),
    textOptional(true),
    iconAllowOverlap(true),
    textAllowOverlap(step(zoom(), literal(false), stop(21, true))),
    symbolZOrder(Property.SYMBOL_Z_ORDER_SOURCE),
  )

This suggests that certain properties may trigger the issue and it can not be reproduced with just any text on any symbol layer.

mtpdog commented 2 weeks ago

I have the same issue. It started from the version 11.1.0. The latest stable version without this issue is 11.0.2-pre0. According to my short tests 11.2.0 also have some additional weird tile loading issue (some tiles are blinking even when they are already loaded). Probably this is a related rendering bug.

louwers commented 2 weeks ago

cc @sjg-wdw

louwers commented 2 weeks ago

I tried to reproduce this in our test app. No luck so far...

https://github.com/maplibre/maplibre-native/commit/3cf9a8ea9aceb79b8b6edca09f1d0556378e4297

image

@westnordost Can you try removing the expressions which use logarithms?

mtpdog commented 1 week ago

Can you try removing the expressions which use logarithms?

According to my test this doesn't seem to be related to exponential interpolation. I have the same issue with linear interpolation and without interpolation at all.

westnordost commented 1 week ago

I removed everything from the layer style except this

        SymbolLayer("pin-cluster-layer", SOURCE)
            .withFilter(all(
                gte(zoom(), 13f),
                lte(zoom(), CLUSTER_MAX_ZOOM),
                gt(toNumber(get("point_count")), 1)
            ))
            .withProperties(
                textField(get("point_count")),
                iconAllowOverlap(true),
                textAllowOverlap(true),
            ),

and it is still reproducible with this.

Note that I wasn't able to reproduce this issue with things such as shop names or housenumbers yet

louwers commented 1 week ago

@westnordost Could you try reproducing it with https://github.com/maplibre/maplibre-native/commit/3cf9a8ea9aceb79b8b6edca09f1d0556378e4297 ?

westnordost commented 1 week ago

Hm, I didn't check out and setup this project on my computer yet. You want to see if it is maybe device-specific? After all, you already found that you cannot reproduce it with https://github.com/maplibre/maplibre-native/commit/3cf9a8ea9aceb79b8b6edca09f1d0556378e4297 . To see if it is device-specific, I think it would be quicker if you installed https://github.com/streetcomplete/StreetComplete/releases/tag/v59.0-alpha4 on your test device, zoomed out after the quests were downloaded until the clusters are visible and then rotate, push around and tilt the map to see if you have the same effect on your test device. (No checking-out+setup of my project necessary :-P)

westnordost commented 1 week ago

@mtpdog are you using clustering?

louwers commented 1 week ago

Sure I can do that!

Looks device specific. No problem on Samsung S10 with LineageOS (Android 12).

image

westnordost commented 1 week ago

Hm, weird. Note, though that it does occur not always on rotation, you have to push it around, zoom in and out, maybe tilt a bit. I didn't find if there is any specific thing that triggered it (other than definitely: rotation, but I don't know the second magic ingredient). I for example wasn't able to reproduce it on my Samsung S10e with LineageOS (Android 13) in some village that had few quests (=small and few cluster bubbles), only in some city with many quests. But this might as well have been coincidence.

Also, I was never able to reproduce on my phone what you can see in the first video posted in the issue. For me, the numbers only sometimes vanish, but never warp.

westnordost commented 1 week ago

Devices on which it was confirmed that it can be reproduced so far (I will update this post as new information from users comes in):

Warping text:

Missing text:

mnalis commented 1 week ago

I also occasionally had warping on Android 14 (Samsung Galaxy S23+) like this:

https://github.com/user-attachments/assets/039d07ea-0bf5-4cef-871d-f14856e5fde3

mtpdog commented 1 week ago

are you using clustering?

No, I don't. But I use custom fonts from my "glyphs" folder.

mtpdog commented 1 week ago

My suggestion is to examine changes made between versions 11.0.2-pre0 (the last working one) and 11.1.0 (this already includes warping).

sjg-wdw commented 1 week ago

A lot going on in this thread, but I think at the core is a problem with clustering. Do we have any good clustering tests?