mapbox-navigation-ios icon indicating copy to clipboard operation
mapbox-navigation-ios copied to clipboard

Noticeable Black Flash Before NavigationMapView Loads

Open billyking991 opened this issue 3 years ago • 4 comments

Mapbox Navigation SDK version

2.6.0

Steps to reproduce

Please see attached video for the example. I've had the following code in viewDidLoad for Mapbox Navigation V0 and V1 (2 years) with no issues.

navigationMapView = NavigationMapView(frame: CGRect(x: 0.0, y: 0.0, width: mapHolder.frame.size.width, height: mapHolder.frame.size.height)) navigationMapView.delegate = self navigationMapView.userLocationStyle = .puck2D() navigationMapView.navigationCamera.viewportDataSource = NavigationViewportDataSource(mapView.mapView, viewportDataSourceType: .raw) navigationMapView.navigationCamera.follow() mapHolder.addSubview(navigationMapView)

Now that I'm updating the app to Mapbox Navigation V2, I'm seeing a noticeable black flash after the navigationMapView is added to the UIView and before it loads (or at least I'm guessing that's what's happening).

I've tried changing the NavigationMapView backgroundColor to UIColor.white. I've also tried adding it to the UIView holder in viewWillAppear and viewDidLoad with no luck. Any ideas? Again, this has not been a problem in the last 2 years with V0 and V1. Just ironing out issues before release. Thank you for your help!

https://user-images.githubusercontent.com/5864607/185236156-f157e15e-b4ca-4e58-a475-e7db73d8f6fb.MOV

Expected behavior

NavigationMapView should load smoothly without a black flash.

Actual behavior

There is a noticeable black flash after the NavigationMapView is added as a subview to the UIView holder, but before the map loads.

Is this a one-time issue or a repeatable issue?

repeatable

billyking991 avatar Aug 17 '22 20:08 billyking991

This also seems to be happening when the NavigationViewController first launches as well. There is a distinct black flash that occurs before it starts finding the location and orienting itself. Not an emergency, but it doesn't look right. This did not occur in the V0 and V1 NavigationViewControllers.

billyking991 avatar Aug 18 '22 14:08 billyking991

@billyking991, I cannot reproduce this issue. Can you please provide more context on how you initially add NavigationMapView/NavigationViewController? E.g. what is mapHolder in your example? Is it just a placeholder view? Also how do you apply access token?

Here's example I use when trying to reproduce the issue:

class ViewController: UIViewController {
    
    var navigationMapView: NavigationMapView!

    override func viewDidLoad() {
        super.viewDidLoad()
        
        navigationMapView = NavigationMapView(frame: view.bounds)
        navigationMapView.userLocationStyle = .puck2D()
        navigationMapView.navigationCamera.viewportDataSource = NavigationViewportDataSource(navigationMapView.mapView,
                                                                                             viewportDataSourceType: .raw)
        navigationMapView.navigationCamera.follow()
        view.addSubview(navigationMapView)
    }
}

And here's result:

https://user-images.githubusercontent.com/1496498/186004471-ea560e3a-2036-4444-943e-b99a04c6bf37.mov

MaximAlien avatar Aug 22 '22 19:08 MaximAlien

Thank you for getting back to me.

The token is stored in the Info.plist files as an MBXAccessToken.

The view holder is a UIView.

I create the navigationMapView in viewDidLoad like this:

mapView = NavigationMapView(frame: CGRect(x: 0.0, y: 0.0, width: mapHolder.frame.size.width, height: mapHolder.frame.size.height)) mapView.delegate = self mapView.userLocationStyle = .puck2D() mapView.navigationCamera.viewportDataSource = NavigationViewportDataSource(mapView.mapView, viewportDataSourceType: .raw) mapView.navigationCamera.follow() mapHolder.addSubview(mapView)

Honestly, this is more of me just being picky about how things look. It's never happened like this before in either V0 or V1. Not a huge issue, but I'd love to figure it out and fix it.

It seems to happen a bit less if I put:

mapHolder.addSubview(mapView)

in viewDidLoad, but that feels a bit like a hack.

Any ideas? Again, not a crazy emergency.

billyking991 avatar Aug 22 '22 19:08 billyking991

@mapbox/maps-ios do you have any ideas here? Anything that might cause this blinking issue on Maps SDK side?

MaximAlien avatar Sep 19 '22 17:09 MaximAlien