iOS 13.2 removing overlay from MapKit causing map to flicker
Asked Answered
S

6

7

I am using mapKit in my app and I have several functions that render graphics using layers of overlays. Now, with iOS 13.2 update, when I move the map (with any method) functions that remove a single overlay and redraw the overlay as the map moves - cause all the graphics in the map to flicker - as if they are all being redrawn. One of the methods for moving the map is 'didUpdateLocations' by the locationManager.

I can't post code, because the code is split up over so many sub functions all called in different combinations. But I have tested many ways to verify that the graphics flicker just from the single action of adding or removing an overlay. And I have evaluated the overlay being added or removed to verify that it is only a single small graphic (MKPolyline) - not the set of graphics/overlays on the map.

So basically, there seems to be something wrong with the addOverlay function - redrawing all overlays.., or something like this...

Anyone else experiencing this issue with iOS13.2?

Succinylsulfathiazole answered 2/11, 2019 at 19:59 Comment(4)
Update: I noticed that the graphics that are flickering are only the graphics nearest to the centre of the map (where my single graphic is being redrawn). Even weirder; some of the flickering happens to only half of a line graphic. Thereby suggesting that it is OS or mapKit related, because my app would be redrawing the whole line anytime it was drawn.Succinylsulfathiazole
In my case the tiles underlying the bounding box of the overlay I remove are flickering. I have a heading line updating each second, and with the MKPolyline not being able to update coordinates, removing and adding a new is the only option.Ailin
I have the same problem - stable app in the app store for years using MKPolygons. iOS 13.1 works without any flicker, iOS 13.2 has major flickering when adding and removing polygons. This is a new MapKit issue. Perhaps there is a new procedure for updating the map?Rooks
Can't we update the Shape or Renderer instead of removing and adding it back? Since I am also facing the same issue.Bourse
A
1

iOS 13.4 fixed the problem for my app - finally!

Ailin answered 27/3, 2020 at 6:29 Comment(0)
D
4

A similar thing is happening to me. I have an app that hasn't changed in several months, but when I upgraded to iOS 13.2, it started misbehaving. The app has a mapView that renders MKTileOverlays. A 2x2 grid of tiles that surrounds the center blue dot is blinking continuously at a rate of once per second, at all zoom levels. I was able to capture the screen (on an iPhone) right when it blinked, and I can see it's showing a number of tiles at higher zoom levels.

In the picture below, the map is at zoom level 14. I outlined the 2x2 blinking tiles in green. When it blinks, several tiles at zoom level 16 (outlined in orange) and zoom level 17 (outlined in purple) appear.

The higher zoom-level tiles only appear if I previously zoomed up to that level in those areas. Otherwise, the 2x2 blinking grid is empty.

enter image description here

Update:

Here is the reply I received from Apple Developer Technical Support on 12/5/2019...

What you’re seeing is a known bug in MapKit. I wanted to pass along some additional information to help reduce how often you may see this in your real app. A common pattern that some apps use in the MKMapView usage is to do frequent updates to their overlays, such as removing all overlays at once, and then adding some subset (or all) of them back. In particular, if this is done to the hot code paths for user driven events, such as pinching and zooming the map, the blinking tile behavior is exacerbated.

In the case of the sample [provided by P. Stern], this is the location manager’s location update, which can be called at 60 Hertz in some circumstances. You can do something like a distance comparison and only update the polyline if there’s a significant enough change in the coordinate since the last time you replaced the polyline to be meaningful to the user for your trail use case. Applying this to your real app, please audit the points where you add and remove overlays, and try to reduce the number of times those methods get called. This won’t eliminate the tile blinking problem, but may reduce its frequency as a way to mitigate the effects of our issue.

When looking at your overlays, also consider why you need to add and remove overlays from the map, and if there are opportunities to do so in bulk, but rarely. Another common pattern I see often is trying to keep track of the overlays to keep memory usage down, and continually updating the overlays added to the map to reflect only those relevant to the user’s location or visible map rectangle. However, the MKOverlay objects themselves are usually not large, because they are only a coordinate and a bit of data, so the memory saved by these techniques is often in the kilobyte to low megabyte range, which isn’t much improvement when an app with a map needs 100 MB just for the map, let alone the rest of the app’s data and view controllers.

Final Update:

The issue seems to have been resolved by Apple. I am using iOS 13.7 (Xcode 12) and the blinking is no longer occurring. It may have been fixed in iOS 13.4 as Zifigo noted.

Doggone answered 17/11, 2019 at 8:17 Comment(5)
Update: I narrowed down the cause, but still don't have a solution. Like the other commenters noticed, the blinking occurs when I remove and add an overlay near the blue dot. The overlay is an MKPolyline that traces the location of the phone as it moves. Since MKPolyline is read-only, I have to remove it and add a new one, when the location updates.Doggone
any success? tried to play with exchangeOverlays but no luck so far... :FExpendable
I opened a Technical Support Incident (TSI). I will post Apple's response when I get it. Support is closed right now, until December 1st.Doggone
@P.Stern could you please post Apple's response if they already answeredCopeland
I received Apple's reply, and entered it as an update, above. I will ask Apple if there is a ticket open to track the issue.Doggone
C
2

Same thing happens to me. From iOS13.2, adding an overlay (any kind, like tileoverlay, polyline) will cause all overlays refreshed, flickering.

So, I add all overlays to map, and change renderer's alpha to hide/show them, kind of temporary solution.

Chapbook answered 8/11, 2019 at 16:42 Comment(1)
Can you show a bit of code how you actually solved this.Bourse
V
1

I found two necessary conditions

  1. using MKTileOverlay as customed tile
  2. remove a MKOverlay Object
Vern answered 25/12, 2019 at 6:10 Comment(0)
A
1

iOS 13.4 fixed the problem for my app - finally!

Ailin answered 27/3, 2020 at 6:29 Comment(0)
N
1

I am seeing this issue in iOS 15.

Obviously this solution isn't ideal, but it works for our use case and prevents the flickering. Perhaps it will save someone else some time.

mapView.addOverlay(currentLine)
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(200)) {
    self.mapView.removeOverlay(newLine)
}
Nosh answered 22/1, 2022 at 15:53 Comment(0)
C
0

Adding an overlay will cause all overlays reloaded, which causes flickering. To minimize flickering, minimize number of overlay additions. Instead of replacing an overlay with new one, implement an overlay renderer that observers important overlay properties and redraws the overlay when needed invalidating the old path.

Cardigan answered 24/7, 2020 at 16:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.