-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[core] don't hide icons if text is an empty string #11206
Conversation
a4d7ede
to
88032a7
Compare
I think there's actually a very subtle difference from the GL JS logic here. GL JS says "if you have a collision box, try to place it", and in But on gl-native, this new logic says "if you have a non-empty shaping, try to place your mapbox-gl-native/src/mbgl/layout/symbol_layout.cpp Lines 254 to 257 in 8a283b0
mapbox-gl-native/src/mbgl/layout/symbol_instance.cpp Lines 33 to 35 in 8a283b0
Did the new test fail before you made these changes? It seems to me like they may not be necessary (although we should rationalize the behavior between JS and native, I'm starting to think the current native behavior may be more correct?). As it stands, we'll create a collision box but then not use it. |
@ChrisLoer good point. I need to dig into this more
Yep, the test fails without these changes |
I just added a native ignore for this for #11156, let's remember to take that out when we merge the fix here. |
88032a7
to
6f1586e
Compare
Ok, so, there are three cases we care about: no text, empty string of text, text. native master creates:
However, they never get used because this is only true when the text is a non-empty string. So while there are internal differences between native master and old -js, they have the same behaviour. I think it might be fine to continue treating an empty string of text the same as undefined text. Both would never be tested for collisions. Do you see any good reason to start treating empty strings differently? I pushed a fix that is equivalent to the previous fix but simpler. It just changes the per-bucket data presence check to a per-feature check. If this looks good, I'll change -js to match this approach (which shouldn't change -js behaviour). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, sounds good to me, thanks for digging in. I like the simplicity of the new approach, and it should be a cheap lookup even though it's in an inner loop...
🤔 I wish I could think of a better name for "iconWithoutText", it's not really clear that it's focused on whether a collision happens.
As for whether an empty string should be treated as "undefined" vs "defined but 0-length", I feel like "empty string can be a valid/defined string" is generally a more natural convention. If someone defines the text to be set to the result of some variable, they're going to expect "this symbol has text", and not expect there to be different behavior if the variable happens to evaluate to an empty string. But it's hard for me to see how it would make any practical difference in this case.
port of mapbox/mapbox-gl-js#6164