MKPolyline not displayed on IOS 14.1, works fine on IOS 13.7

Problem: The MKPolyline is not displayed on the screen in the scenario described below.

Using Swift I have added a MapKit MapView MKTileOverlay and try add, and display, a Polyline on top of it using:
  1. mapView.addOverlay(tracklogPolyline)

  2. mapView.addOverlay(tracklogPolyline, level: MKOverlayLevel.aboveLabels)

I also tried "let overlays = self.mapView.overlays" followed by "self.mapView.insertOverlay(self.homeNavRoute.polyline, above: overlays[overlays.count-1])"

Above mentioned works OK on my Xcode IOS 14.1 simulator and on IOS 13.7 hardware. It FAILS on IOS 14.1 hardware, both on iPhone (for example iPhone XS) and iPad.

Debugging info:
MapView.overlays (let overlays = mapView.overlays) shows that the 2 expected overlays are present, one MKTileOverlay at overlays[0] and the MKPolyline on overlays[1] so that is good. But as stated above the MKPolyline fails to show on IOS 14.1 iPhone and iPad. I am using the regular out of the box renderer; MKPolylineRenderer(overlay: overlay)

Also:
When I display the MKPolyline without adding the MKTileOverlay it works OK in all cases.

I am using Xcode 12.1 to build and run the code.

Question1: Is this a known bug?
Question2: What is the solution ?
Could you show the code ? Including everything dealing with MKTileOverlay.
My code is all over the place but I will try to provide the key snippets. I don't have a small demo version that you can run att. I hope this helps.

Part1:
self.mapView.removeOverlay(self.navigationRoute.polyline)
self.navigationRoute = response.routes[0]
self.navigationRoute.polyline.title = "navigationRoute"
self.mapView.addOverlay(self.navigationRoute.polyline, level: MKOverlayLevel.aboveLabels)
let distance = self.navigationRoute.distance
let expectedTime = self.navigationRoute.expectedTravelTime/60
let navDistance = self.formatDistance(distance: distance, round10m: true)
self.navLabel.text = "Nav \(navDistance) \(expectedTime)"

Part2:
if let overlay = openTopo {
mapView.addOverlay(overlay, level: MKOverlayLevel.aboveRoads)
}

Part3:
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
if (overlay is MKTileOverlay) {
return MKTileOverlayRenderer(overlay: overlay)
}
}
See above for my answer about code code fragments.
So the following fails:
  1. I have an standard mapView

  2. on top of that I have an OpenTopo overlay that covers the entire standard map

  3. I try to display the route MKpolyline on top the OpenTopo map.

Now the MKPolyline (3) is not shown on IOS 14.1 hardware (ok on 13.7 hardware and the Xcode 14.1 simulator)

When I do:
  1. have an standard mapView

  2. Display the route MKpolyline on top of the standard map

The MKPolyline is shown ok on both IOS 13.7 and 14.1 hardware.
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
let renderer = MKPolylineRenderer(overlay: overlay)
if (overlay is MKPolyline) {
renderer.strokeColor = .red
renderer.lineWidth = 5.0
renderer.alpha = 1.0 // changed 0.8 to 1.0, now it works
}
}

I found in another thread that the workaround is to set renderer.alpha to 1.0
I changed rederer.alpha from 0.8 to 1.0 and indeed that indeed works.
So the bug is that .alpha fails in the above mentioned scenario.

See
662219: iOS 14.0 Regression - MKPolyline is not shown on top of a MKTileOverlay
This is indeed the workaround

alpha default is 1.0
What happens if you don't set alpha at all ?

The code you showed in Part3 was quite different:
Code Block
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
let renderer = MKPolylineRenderer(overlay: overlay)
if (overlay is MKPolyline) {
renderer.strokeColor = .red
renderer.lineWidth = 5.0
renderer.alpha = 1.0 // changed 0.8 to 1.0, now it works
}
}


So the change is not just the alpha value ?
To fix the problem the only change was:
renderer.alpha = 1.0 // change alpha from 0.8 to 1.0

Answer to question that was asked: When I do not specify renederer.alpha it also works fine.
Needless to say my goal is to specify transparency so that the underlaying layer can been seen. That fails so for now I use .alpha 1.0

This works ok:
func mapView( mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
let renderer = MKPolylineRenderer(overlay: overlay)
renderer.strokeColor = .red
renderer.lineWidth = 5.0
renderer.alpha = 1.0
return renderer
}

This also works ok:
func mapView(
mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
let renderer = MKPolylineRenderer(overlay: overlay)
renderer.strokeColor = .red
renderer.lineWidth = 5.0
// renderer.alpha = 1.0
return renderer
}

This fails:
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
let renderer = MKPolylineRenderer(overlay: overlay)
renderer.strokeColor = .red
renderer.lineWidth = 5.0
renderer.alpha = 0.8 // <<<=== on IOS 14.1 this will cause the MKPolyline fail to show, works OK on iOS 13.7
return renderer
}

I had exactly the same issue when I was testing on device with iOS 14.1, although my code was in objective C. Changing the Alpha from 0.9 to 1.0 worked for me.
The MapKit engineering team would appreciate a bug report with a small buildable Xcode project showing the differences you're seeing between iOS 13 and iOS 14. Please share the FB number here.
The problem is now fixed. After building with Xcode 12.3 and run the code on IOS 14.3 it works fine. I set .alpha to 0.65 & it works ok now.
MKPolyline not displayed on IOS 14.1, works fine on IOS 13.7
 
 
Q