-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[core] fix flickering caused by incorrect ClipIDs #12982
Conversation
I tested this one quickly and can't reproduce issues mentioned in #11877 🚀 |
@mollyperp Can you please kindly clarify the following?
|
@mollymerp I'm wondering — could this also fix #12452? That problem also seems related to clip ids (a flicker of buffers outside of tiles on zoom). |
@mourner yep looks like it could be the same issue. will check and let you know. |
@@ -64,7 +64,7 @@ void ClipIDGenerator::update(std::vector<std::reference_wrapper<Renderable>> ren | |||
uint8_t count = 1; | |||
for (auto& it : renderables) { | |||
auto& renderable = it.get(); | |||
if (!renderable.used) { | |||
if (!renderable.used || !renderable.needsClipping) { |
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.
Any feeling on !(renderable.used && renderable.needsClipping)
instead? It has the same results as the above expression for all four bool, bool
permutations.
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.
Interesting nit @sansumbrella — I'm curious about your reasoning behind this comment? In general I find code reviews to be most helpful when they express suggestions about improving functionality, efficiency, or readability, rather than simply suggesting a different way to write the same thing (with the same or, theoretically, slightly worse performance) — unless there's some other motivation behind this suggestion, in which case please share such reasoning while reviewing!
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.
I personally prefer how the existing code is with (!renderable.used || !renderable.needsClipping)
. The logic is easier to understand when glancing at it.
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.
Sorry to parachute in earlier; this is a simple readability question.
I find compound conditionals a little head-scratchy no matter how they are written, and a series of ands
is easier for me to read than a series of !ors
. But as @lbud pointed out, the short-circuit in the !ors
sequence works in favor of the common case here—where we expect to perform clipping.
I'll provide more context on my reviews in the future; and will also introduce myself so I'm not a stranger jumping on your work. I'm excited to see this fix, since I saw the issue in the sales/customer slack channels.
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.
Confirmed that the test produces the overflowing ref
values that we've identified as the cause for the failed clipping before this patch is applied:
{ Renderable{ 7/36/49+0, mask=00000011,ref=00000100 },
Renderable{ 7/36/48+0, mask=00000011,ref=00000011 },
Renderable{ 7/35/48+0, mask=00000011,ref=00000001 },
Renderable{ 7/35/49+0, mask=00000011,ref=00000010 },
Renderable{ 7/37/48+0, mask=00000011,ref=00000101 },
Renderable{ 7/37/49+0, mask=00000011,ref=00000110 } }
Notice how the ref
value goes all the way to 00000110
, overflowing the mask 00000011
.
Bug was introduced in #10198 |
we missed a check for RenderTile.needsClipping when generating the new ClipIDs for some tiles, resulting in incorrect clipping that caused flickering in some cases
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.
Confirmed that this fixes all of the issues we were seeing in the iOS examples — thanks! (I couldn’t help myself with a tiny changelog nit. 🧐)
platform/ios/CHANGELOG.md
Outdated
@@ -10,6 +10,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT | |||
* Added an `MGLSymbolStyleLayer.symbolZOrder` property for forcing point features in a symbol layer to be layered in the same order that they are specified in the layer’s associated source. ([#12783](https://github.com/mapbox/mapbox-gl-native/pull/12783)) | |||
* Fixed a crash when a style layer `*-pattern` property evaluates to nil for a particular feature. ([#12896](https://github.com/mapbox/mapbox-gl-native/pull/12896)) | |||
* Fixed an issue with view annotations (including the user location annotation) and the GL map lagging relative to each other. ([#12895](https://github.com/mapbox/mapbox-gl-native/pull/12895)) | |||
* Fixed an issue where fill and line layers would occasionally flicker on zoom due to a bug in `ClipIDGenerator` ([#12982](https://github.com/mapbox/mapbox-gl-native/pull/12982)) |
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.
Small nit: since these changelogs are meant to be end-developer facing, it’s usually not necessary to mention internal implementation details. In this case, I’d suggest lopping off the “due to a bug in ClipIDGenerator
” part, as that’s only relevant to us.
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.
62061e1 looks good to me
fix #12981
need to add unit test and possibly render tests