Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[core] fix flickering caused by incorrect ClipIDs #12982

Merged
merged 5 commits into from
Oct 3, 2018
Merged

Conversation

mollymerp
Copy link
Contributor

fix #12981

need to add unit test and possibly render tests

@mollymerp mollymerp added the Core The cross-platform C++ core, aka mbgl label Sep 27, 2018
@LukasPaczos
Copy link
Contributor

I tested this one quickly and can't reproduce issues mentioned in #11877 🚀

@mb12
Copy link

mb12 commented Sep 27, 2018

@mollyperp Can you please kindly clarify the following?

  1. Is it possible to explain why/how incorrect clip id results in flickering visual artifacts? Is the flicker result of an over zoomed parent tile overlapping onto some other tile because it has not been clipped?

  2. Also is it possible to why clipping is needed for correct rendering ( at a logical level) and how it works?

@mourner
Copy link
Member

mourner commented Sep 27, 2018

@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).

@mollymerp
Copy link
Contributor Author

@mourner yep looks like it could be the same issue. will check and let you know.

@mollymerp
Copy link
Contributor Author

@mourner just confirmed this change also fixes #12452 🎉

@friedbunny friedbunny added the needs changelog Indicates PR needs a changelog entry prior to merging. label Sep 27, 2018
@@ -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) {

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.

Copy link
Contributor

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!

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.

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.

Copy link
Member

@kkaefer kkaefer left a 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.

@kkaefer
Copy link
Member

kkaefer commented Oct 2, 2018

Bug was introduced in #10198

Molly Lloyd added 3 commits October 2, 2018 10:45
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
@mollymerp
Copy link
Contributor Author

@kkaefer thanks for the review – can you also 👍 the change in 62061e1 before I merge?

@friedbunny friedbunny removed the needs changelog Indicates PR needs a changelog entry prior to merging. label Oct 2, 2018
Copy link
Contributor

@friedbunny friedbunny left a 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. 🧐)

@@ -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))
Copy link
Contributor

@friedbunny friedbunny Oct 2, 2018

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.

Copy link
Contributor

@ansis ansis left a 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

@mollymerp mollymerp merged commit f4ffcaa into master Oct 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl rendering
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[core] ClipIDGenerator bug causing flicker on fill (probably all clipped) layers when using multiple sources