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

Fix map stuttering by switching render call to use setNeedsDisplay #411

Merged
merged 8 commits into from
Sep 3, 2020

Conversation

julianrex
Copy link
Contributor

@julianrex julianrex commented Sep 3, 2020

This PR fixes #350, where the map "stutters" while being animated. The issue is reproducible in iOS 14 beta 2 onwards (as of 2020/9/3).

The PR supersedes changes made for similar bug first reported in mapbox/mapbox-gl-native#14232 (FB5350728) and:

  • switches from calling -[GLKView display] directly (via the CADisplayLink call), to calling -[GLKView setNeedsDisplay],
  • adds development os_signposts for performance analysis,
  • adds a few debug options to the development app Mapbox GL.

Background

This issue is seen when enabling CAEAGLLayer.presentsWithTransaction and calling -[GLKView display] from a CADisplayLink. presentsWithTransaction is used to synchronize the UIView annotations to the map. The stutter that is seen is the CPU blocking with wait for next drawable. The issue can also be reproduced with a blank map (essentially just a glClear).

This effect can be mitigated by setting preferredFramesPerSecond to 30.

This issue has been reported as FB8549369.

@julianrex julianrex marked this pull request as ready for review September 3, 2020 20:06
@julianrex julianrex requested a review from 1ec5 as a code owner September 3, 2020 20:06
@julianrex julianrex requested review from a team, nishant-karajgikar, knov and fabian-guerra and removed request for 1ec5 and a team September 3, 2020 20:06
@julianrex julianrex added this to the release-z (xcode12-ios14) milestone Sep 3, 2020
@julianrex julianrex self-assigned this Sep 3, 2020
@julianrex julianrex changed the title Switch render call to use setNeedsDisplay Fix map stuttering by switching render call to use setNeedsDisplay Sep 3, 2020
@@ -168,6 +148,7 @@ void bind() override {
}

#ifdef MGL_RECREATE_GL_IN_AN_EMERGENCY
// TODO: Fix or remove
// See https://github.com/mapbox/mapbox-gl-native/issues/14232
void MGLMapViewOpenGLImpl::emergencyRecreateGL() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing we should never be getting into this situation where we need to recreate the glView anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤞
I did test this function, but it's currently broken, and it was never a good option anyway, and an even worse one for this particular issue. Let's remove in a future PR.

@julianrex julianrex merged commit 0044577 into master Sep 3, 2020
@julianrex julianrex deleted the jrex/update-render-calls branch September 3, 2020 20:54
katydecorah pushed a commit that referenced this pull request Sep 4, 2020
* master:
  Release 6.2.0 beta.1 prep (#417)
  Update for Xcode 12 release (#415)
  Switch background snapshot to periodic. (#412)
  Fix map stuttering by switching render call to use setNeedsDisplay (#411)
  Add a flag to enforce using catched tiles (#416)
  Improve header documentation for MGLObservable (#398)
  Expose styling options for the user location annotation. (#403)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

On iOS 14 MGLAnnotationView slows down map significantly
2 participants