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

On iOS 14 MGLAnnotationView slows down map significantly #350

Closed
flashspys opened this issue Jul 24, 2020 · 16 comments · Fixed by #411
Closed

On iOS 14 MGLAnnotationView slows down map significantly #350

flashspys opened this issue Jul 24, 2020 · 16 comments · Fixed by #411
Assignees
Labels
p0 rendering Related to rendering

Comments

@flashspys
Copy link
Contributor

The addition of even one custom MGLAnnotationView make the map unusable. The attached image shows the profiler where the mapbox rendering call is taking the most of the cpu. There is only a basic map showing one custom annotation. On iOS 13 this runs butter smooth. The Map is displayed via a UIViewRepresentable in SwiftUI.

image

Steps to reproduce

  1. On iOS 14, create a MGLMapView and display one custom MGLAnnotationView.

Expected behavior

Map runs smooth

Actual behavior

Map is unusable slow

Configuration

The used custom MGLAnnotationView:

class CustomAnnotationView: MGLAnnotationView {
    override func layoutSubviews() {
        super.layoutSubviews()
        layer.cornerRadius = bounds.width / 2
        layer.borderWidth = 2
        layer.borderColor = UIColor.white.cgColor
    }
}

Mapbox SDK version: 6.0.0
iOS versions: iPad OS 14 / iOS 13.6
Device/simulator models: iPad Pro 1st Gen (iOS 14 device) / iPhone Xs (iOS 13 device)
Xcode version: 12.0 b2

@knov
Copy link
Contributor

knov commented Jul 28, 2020

cc @tmpsantos @alexshalamov

@behdaad
Copy link

behdaad commented Aug 1, 2020

In my experience, even building with Xcode 11 (iOS SDK 13) and installing the IPA on a device running iOS 14 causes the same issue.
Update:
Our app shows many annotations (~20) on the map whenever user changes the map center. They can do it very fast, like moving a little and stopping, and it causes a lot of network requests and a lot of clearing and adding annotations. For which we are seeing lags and short freezes.

This functionality is also implemented in our app using Google Maps, which produces different results. It doesn't lag and freeze, but rendering annotations sort of falls behind the moves of the map and eventually catches up with rendering when user stops moving the map around.

I'm going to cancel any outstanding requests to our backend whenever user quickly moves the app and see if it improves performance. (Yes I know we should've done it in the first place, but we never had such problem on iOS 13 and earlier)

I'll post updates in this thread whenever I find more.

@ShRoO0oM
Copy link

Same here, I have a bad lag on iOS 14 devices when showing Annotation. We haven't any problem on iOS 13 or earlier.

@knov knov added p0 and removed status: triage labels Aug 19, 2020
@julianrex
Copy link
Contributor

@flashspys can you provide your sample app (looks like you're using our mapbox-maps-swiftui-demo)?

We have not been able to reproduce this yet, using the SwiftUI sample application, with many UIView annotations, and using your CustomAnnotationView above (built with Xcode 12 b5).

@flashspys
Copy link
Contributor Author

flashspys commented Aug 25, 2020

@julianrex Please have a look at this commit: flashspys/mapbox-maps-swiftui-demo@9c1963e

This makes the map on my iPad Pro (10.5 inch) on iOS 14b5 unusable laggy. At the moment it got a bit better, but the panning and espacially the zooming is still horrible.

@julianrex
Copy link
Contributor

julianrex commented Aug 25, 2020

@flashspys thanks - I just updated the device from beta 1 to beta 6, and now see the same issue.

@knov knov added this to the xcode12-ios14 milestone Aug 25, 2020
@julianrex
Copy link
Contributor

@flashspys can you confirm you first saw this with iOS 14 beta 2?

@julianrex julianrex added the rendering Related to rendering label Aug 26, 2020
@julianrex
Copy link
Contributor

This appears to be a continuation of an iOS stuttering issue first seen in iOS 12.2, related to synchronizing UIViews (most likely annotation views) to the map view rendering, enabled via CAEAGLLayer.presentsWithTransaction 😞 .

@flashspys @behdaad @mohammadz74 (or anyone else suffering), while we continue to investigate solutions, can you please try setting:

mapView.preferredFramesPerSecond = MGLMapViewPreferredFramesPerSecondLowPower

and let us know if you continue to see any stuttering?


For reference:

@flashspys
Copy link
Contributor Author

The issue continues with beta 6. Setting mapView.preferredFramesPerSecond = MGLMapViewPreferredFramesPerSecond.lowPower definitely helps, there is no stuttering like before, just the "normal" but constant 30-fps stuttering.

@arthurschiller
Copy link

Same issue here with iOS 14 Beta 6 and iPad Pro 2020. It seems a little better on my iPhone XS (same OS version), probably because of the lower framerate. Would be great to get this fixed before the iOS 14 release.

@knov knov assigned knov and julianrex and unassigned knov Aug 31, 2020
@swsong12
Copy link

swsong12 commented Sep 3, 2020

Same issue here. IOS 14 Beta 6 (iphone XS Max)

@julianrex
Copy link
Contributor

We have a PR (#411) that will land in the next release. We would appreciate it if you could test the release as soon as possible and let us know of any issues you see compared with 6.1.0. Thanks!

@behdaad
Copy link

behdaad commented Sep 4, 2020

Thanks @julianrex, will definitely test it as soon as it's available.

@julianrex
Copy link
Contributor

6.2.0-beta.1 has been released. You'll need to use Xcode 12 beta 6 if you intend to submit an app to TestFlight.

@swsong12
Copy link

swsong12 commented Sep 5, 2020

Great 👍 It seems like this issue has been fixed (for us at least, iPhone XS MAX)

@jfcartkeep
Copy link

We have a PR (#411) that will land in the next release. We would appreciate it if you could test the release as soon as possible and let us know of any issues you see compared with 6.1.0. Thanks!

@julianrex Can this fix be done on the previous release 5.9.0? If I use the stable release of iOS SDK for mapbox navigation, I am lock on this old release because of the MapboxMobileEvents requirement.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p0 rendering Related to rendering
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants