Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Prevent black flash when loading styles #3101

Closed

Description

@tomtaylor

I've set a background colour on my MGLMapView, to the background of the Streets style, so it looks a little less jarring when loading. However, it still flashes black while loading the map for the first time. It'd be great if it could keep the background colour until the style is fully loaded.

Activity

  1. 1ec5 commented on Nov 23, 2015

    @1ec5
    Contributor

    This would be fixed by #3096 I believe.

  2. added
    iOS
    on Nov 23, 2015
  3. tomtaylor commented on Nov 23, 2015

    @tomtaylor
    Author

    Ah ha, thanks.

  4. abpopov commented on Dec 9, 2015

    @abpopov

    I solve this by this code
    mapView.layer.backgroundColor =[[UIColor clearColor] CGColor];

  5. added this to the ios-v3.1.0 milestone on Jan 15, 2016
  6. friedbunny commented on Jan 15, 2016

    @friedbunny
    Contributor

    Fixed by #3096.

  7. 1ec5 commented on Jan 15, 2016

    @1ec5
    Contributor

    The fix in #3096 only takes effect if you set MGLMapView.opaque = NO; otherwise, UIKit considers the behavior to be undefined if the map view fails to draw its entire bounds. So setting opaque = NO is the recommended way to deal with the black flash.

  8. mxcl commented on Nov 30, 2016

    @mxcl

    isOpaque should be false by default since that is the behavior of almost all UIKit views since iOS 7 almost four years ago. The black flash alone is why my boss decided that we would use Google Maps instead. :P

  9. 1ec5 commented on Nov 30, 2016

    @1ec5
    Contributor

    As of the iOS 10 SDK, UIView.isOpaque is true by default, and so is MKMapView.isOpaque.

    The black flash you’re seeing is more likely the style’s background layer being rendered before the other layers come in, since the other layers likely require fetching vector tiles. (This is the phase in which MapKit would render a graticule: see #119.)

    The background color of a style usually matches the color of land, although Mapbox Satellite and Satellite Streets have black as their background color. You can configure the background color by customizing a style in Mapbox Studio or, as of the upcoming Mapbox iOS SDK v3.4.0 beta, by modifying (mapView.style.layers.last as? MGLBackgroundStyleLayer)?.backgroundColor inside MGLMapViewDelegate.mapView(_:didFinishLoadingStyle:).

    If you’re seeing a noticeable black flash despite the style’s background color being set to something lighter, I agree that we should revisit this issue and find a better solution.

  10. mxcl commented on Dec 1, 2016

    @mxcl

    UIView, probably, the majority of UIKit, certainly not. It is easy enough to test, almost all of my apps are clear background views (UILabel, UITableView, UIButton, UI*) and I get no black flashes due to opaqueness being true.

    The black flash you’re seeing is more likely the style’s background layer being rendered before the other layers come in, since the other layers likely require fetching vector tiles. (This is the phase in which MapKit would render a graticule: see #119.)

    I set isOpaque to false and the black flash stopped…

  11. 1ec5 commented on Dec 1, 2016

    @1ec5
    Contributor

    I don’t mean to be stubborn; just wondering whether we’re missing something that allows MapKit to default to being opaque but still avoid the black flash. I’ve opened #7256 to track defaulting isOpaque to NO, as you’ve requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugiOS

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions