Skip to content

Conversation

@JunDai
Copy link
Contributor

@JunDai JunDai commented May 9, 2020

Description

Fix #2942

The locationComponent is initialized until navigationMapboxMap been created. So not assign mapboxMap variable until style is loaded and everything is set up.

    override fun onMapReady(mapboxMap: MapboxMap) {
        mapboxMap.setStyle(Style.MAPBOX_STREETS) {
            mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(15.0))
            navigationMapboxMap = NavigationMapboxMap(mapView, mapboxMap, true)
            this.mapboxMap = mapboxMap
        }
  • I have added any issue links
  • I have added all related labels (bug, feature, new API(s), SEMVER, etc.)
  • I have added the appropriate milestone and project boards

Testing

Please describe the manual tests that you ran to verify your changes

  • I have tested locally (including SNAPSHOT upstream dependencies if needed) through testapp/demo app and run all activities to avoid regressions
  • I have tested via a test drive, or a simulation/mock location app
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have updated the CHANGELOG including this PR

@kmadsen
Copy link
Contributor

kmadsen commented May 10, 2020

Is this needed by any other examples?

}

override fun onMapReady(mapboxMap: MapboxMap) {
this.mapboxMap = mapboxMap
Copy link
Contributor

Choose a reason for hiding this comment

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

Some crashes are exchanged with no-op bugs?

@LukasPaczos
Copy link

The locationComponent is initialized until navigationMapboxMap been created.

That's definitely the reason of the crash.

I think it might be easier to understand the fix if LocationComponent#isLocationComponentActivated was used before calling

activityRef.get()?.mapboxMap?.locationComponent?.forceLocationUpdate(it)
instead of reshuffling the initialization of variables.

@JunDai
Copy link
Contributor Author

JunDai commented May 11, 2020

The locationComponent is initialized until navigationMapboxMap been created.

That's definitely the reason of the crash.

I think it might be easier to understand the fix if LocationComponent#isLocationComponentActivated was used before calling

activityRef.get()?.mapboxMap?.locationComponent?.forceLocationUpdate(it)

instead of reshuffling the initialization of variables.

sounds good, changed the fix and verified it works!

@JunDai
Copy link
Contributor Author

JunDai commented May 11, 2020

Is this needed by any other examples?

no, I checked our other examples.

@langsmith langsmith changed the title fix #2942 Fixing examples test app LocationComponent race condition May 11, 2020
@langsmith
Copy link
Contributor

Above the class FasterRouteActivity : AppCompatActivity(), OnMapReadyCallback { line, can we add:

/**
 * This example shows how to use the Navigation SDK's [FasterRouteObserver]
 * and display the observer's faster routes that are returned if the 
 * device goes off of the original [DirectionsRoute].
 */

@langsmith langsmith self-requested a review May 11, 2020 16:49
@JunDai JunDai merged commit d70ff01 into master May 11, 2020
@JunDai JunDai deleted the jd-fix-2942 branch May 15, 2020 23:28
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.

Examples crash with Style loading race condition

4 participants