-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bearing of the puck being reset on settings change. #1144
Conversation
ccf9287
to
7682290
Compare
lastLocation?.let { | ||
updateCurrentPosition(it) | ||
} | ||
updateCurrentBearing(lastBearing) | ||
locationLayerRenderer.addLayers(positionManager) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this should be called after updateCurrentBearing
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. Otherwise renderer may run render pass before the updateCurrentBearing will be called thus will use incorrect default zero bearing.
The call sequence becomes :
main thread : locationLayerRenderer.addLayers -> layers are added
render thread : render pass -> no bearing value is set, resets to default
main thread : updateCurrentBearing -> will be applied on the next render pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block will only be executed during init but in your screen recording, it's a long-lasting period. Wondering whether this is the root cause for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Init is called every time location settings are changed. For the recording I've triggered location component settings change every 700 milliseconds, e.g. in the LocationComponentActivity I've added
val runnable = object : Runnable {
override fun run() {
binding.mapView.location.pulsingMaxRadius = 1f
binding.mapView.postDelayed(this, 700L)
}
}
binding.mapView.post(runnable)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then it makes sense.
@@ -8,6 +8,7 @@ internal class LocationIndicatorLayerWrapper(layerId: String) : LocationLayerWra | |||
layerProperties["id"] = Value(layerId) | |||
layerProperties["type"] = Value("location-indicator") | |||
layerProperties["location-transition"] = buildTransition(delay = 0, duration = 0) | |||
layerProperties["bearing-transition"] = buildTransition(delay = 0, duration = 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually the change I'm not 100% sure about, though it seems that iOS does the same and it disable core bearing animations that otherwise are applied.
Waiting for the comments here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexshalamov perhaps you could comment here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Location indicator layer properties are transitionable. Bearing and position is interpolated if user sets new value. If interpolation will be always done on SDK level, we could consider making these properties non-transitionable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@macdrevx could you please share how is it used on iOS https://github.com/mapbox/mapbox-maps-ios/blob/9f0e9605b081e45dce808a53f70b5eb0747858ab/Sources/MapboxMaps/Location/Puck/Puck2D.swift#L116 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We disable transitions on iOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@macdrevx is the user able to enable it though? Seems there's a public property for that https://github.com/mapbox/mapbox-maps-ios/blob/c95b14f16c9462f1a1241245ad6abd4d51d3b4f3/Sources/MapboxMaps/Style/Generated/Layers/LocationIndicatorLayer.swift#L94.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the user able to enable it though? Seems there's a public property for that
@yunikkk the location component is built on top of the low level style APIs, so yes, user could overwrite whatever style properties in the runtime if they want to, however I think that's out of the scope of the LocationComponentPlugin.
Currently the bearing of the location indicator layer is driven by the platform animation system, and the gl-native transition should be set to 0, and I believe the default transition should be 0 already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: seems the default transition is not 0, as mentioned in the PR description, which is 300 milliseconds in duration. So we should set it specifically to 0.
Tests are still failing (as well as couple of other bots). |
cb46f7d
to
afb939e
Compare
bf419ac
to
bf4346a
Compare
"[interpolate, [exponential, 0.5], [zoom], 0.5, [literal, [$MODEL_SCALE_CONSTANT, $MODEL_SCALE_CONSTANT, $MODEL_SCALE_CONSTANT]], 22.0, [literal, [1.0, 1.0, 1.0]]]", | ||
valueSlot.captured.toString() | ||
) | ||
val value = valueSlot.captured.toString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any comments what happens below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well since we can't compare the whole string (it contains formatted double values that may be slightly different - we compare start and end of the strings, then parse double values and compare relative to ULP (smallest possible double value increment)
...ncomponent/src/test/java/com/mapbox/maps/plugin/locationcomponent/LocationPuckManagerTest.kt
Outdated
Show resolved
Hide resolved
...ncomponent/src/test/java/com/mapbox/maps/plugin/locationcomponent/LocationPuckManagerTest.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nits
ca4efb3
to
7c2e162
Compare
Summary of changes
The fix resolves the issue with puck bearing, that can jump to zero on when location component settings are changed. The wrong animation looks in the following way :
puck-bearing-jumping.mp4
There are two issues causing such behaviour.
First - we add layer on the map before applying current bearing value. Renderer, which is running in parallel on the background thread, may (and sometimes does) actually run rendering before bearing is applied, thus jumping to the default (0) bearing.
Second -
bearing-transition
property is not set and defaults to animating during 300 milliseconds. I'm not actually sure about this one since after the first fix it seems not necessary, but iOS for example resets this to zero https://github.com/mapbox/mapbox-maps-ios/blob/9f0e9605b081e45dce808a53f70b5eb0747858ab/Sources/MapboxMaps/Location/Puck/Puck2D.swift#L129. Seems it is some sort of outdated bearing animation in GL native that is not used since we do animations on platforms directly. @mapbox/maps-android please advice herePull request checklist:
@JvmOverloads
,@file:JvmName
, etc).mapbox-maps-android
changelog:<changelog></changelog>
.v10.[version]
release branch fix / enhancement, merge it tomain
firstly and then port tov10.[version]
release branch.PRs must be submitted under the terms of our Contributor License Agreement CLA.