Skip to content

Comments

Wait until style has loaded before doing things to it#339

Merged
bsudekum merged 2 commits intomasterfrom
wait-for-style
Jul 7, 2017
Merged

Wait until style has loaded before doing things to it#339
bsudekum merged 2 commits intomasterfrom
wait-for-style

Conversation

@bsudekum
Copy link
Contributor

@bsudekum bsudekum commented Jul 6, 2017

Attempts to fix the black lines in #338.

I think in some cases,

if streetsSources.isEmpty {
let source = MGLVectorSource(identifier: "mapboxStreetsv7", configurationURL: URL(string: "mapbox://mapbox.mapbox-streets-v7")!)
style.addSource(source)
streetsSources.append(source)
}
if let mapboxSteetsSource = streetsSources.first, style.layer(withIdentifier: roadLabelLayerIdentifier) == nil {
let streetLabelLayer = MGLLineStyleLayer(identifier: roadLabelLayerIdentifier, source: mapboxSteetsSource)
streetLabelLayer.sourceLayerIdentifier = "road_label"
streetLabelLayer.lineOpacity = MGLStyleValue(rawValue: 1)
streetLabelLayer.lineWidth = MGLStyleValue(rawValue: 20)
streetLabelLayer.lineColor = MGLStyleValue(rawValue: .white)
style.insertLayer(streetLabelLayer, at: 0)
}
could be causing a race condition if the style is not fully loaded.

/cc @frederoni @1ec5 @zijiazhai

@bsudekum bsudekum requested review from 1ec5 and frederoni July 6, 2017 17:52
@objc(navigationMapView:shouldUpdateTo:)
func navigationMapView(_ mapView: NavigationMapView, shouldUpdateTo location: CLLocation) -> CLLocation? {

guard hasFinishedLoadingStyle else { return nil }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the style hasn’t finished loading, we can’t manipulate the style in order to query it for street names, but we should still run the rest of this method in order to snap the user’s location to the route.

In fact, that’s what the code already does: it checks for a non-nil style before manipulating the style. style would be nil until the style has finished loading.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you’re actually right about needing to track hasFinishedLoadingStyle separately. style is nil until the style finishes loading, but sources such as Streets may take a little longer to load. But instead of guard, we need to modify the existing giant if statement.

@bsudekum
Copy link
Contributor Author

bsudekum commented Jul 7, 2017

@1ec5 fixed

@bsudekum bsudekum merged commit 8829bf2 into master Jul 7, 2017
@1ec5 1ec5 added this to the v0.5.0 milestone Jul 9, 2017
@bsudekum bsudekum deleted the wait-for-style branch July 10, 2017 16:53
ericrwolfe pushed a commit that referenced this pull request Jul 21, 2017
* Begin adding telem events

* fix

* add timezone

* Update

* Add remaining events

* conditional import

* Move back to core

* make private

* Consolidate telemetry state, outline full telemetry spec

* Update date format

* Store more state; add device

* Updated telemetry event handling

* Round events

* Add dialog view controller

* Reset telemetry session if route updated after arrival

* Remove logs; trailing closure syntax

* Add userId to feedback event

* Hide feedback dialog after 0.5s

* Moar trailing closure

* Add temporary pod dependency on Mapbox-iOS-SDK

* Pass nil feedback description for now

* Extend locations collected

* Fix location serialization

* Reduce locations collected

* More battery level precision

* remove battery enable flag

* Add snapshot to reroute event

* Add update + cancel feedback functions

* Screenshots as jpeg

* Wait until style has loaded before doing things to it (#339)

* Fix location permissions and adopt iOS 11 description

* Fixed bugs in closestCoordinate and addArrow functions. (#284)

* Defer simulated location updates until next run loop (#344)

* Did arrive once (#347)

* add back

* Use telem library

* add init

* add

* add release

* fix string

* updater

* fix

* update args

* add framework

* add certs

* move certs

* struct

* more struct

* add

* add to tests

* add to obj-c

* remove

* update

* bump

* Add upcoming step information

* Remove telem staging token check (handled upstream)

* Add previous step information

* Only capitalize first character of step maneuver keys

* copy framework

* trailing

* add framework

* add access token

* fix

* make optional

* rename

* update event lib

* name not version

* Better types

* Update

* No telem in sim

* add back

* Dont pass in access token

* fix

* Switch to nested step dictionary in feedback events

* Add debug metrics user info key

* Fix feedback event types

* Moved all event dictionary generation to MMEEventsManager

* Move feedback event dict update logic

* Bump

* Pin to MapboxDirections.swift 0.10.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants