mapbox-maps-android
mapbox-maps-android copied to clipboard
Map not updating on certain Xiaomi devices using Android Auto
Environment
- Android OS version: 12 SKQ1.211006.001
- Devices affected: tested with Xiaomi Poco F3, probably all Xiaomi devices running Android 12
- Maps SDK Version: for our app we currently are using 10.3.0-rc.1, also tested with the one provided in your Android Auto sample app.
Observed behavior and steps to reproduce
As soon as the main app is not running in foreground on the phones screen the map on Android Auto will stop updating. Other components like speed limits, instructions and so on still update. I just ran the provided Android Auto Example app, as soon as I switch to some other app or turn off the phone screen map updates on Android Auto stop. The position icon and camera are not moving anymore and will only get back to work when the app is running in foreground again.
Expected behavior
Map updates on Android Auto while the app is not in foreground or the phones screen is turned off.
Notes / preliminary analysis
I followed https://dontkillmyapp.com/xiaomi to make sure the app doesn't get killed by the system.
I tried to update the dependencies of the sample app to see if it changes anything, but the issue is still the same.
com.mapbox.navigation:ui-androidauto:0.2.0
com.mapbox.search:mapbox-search-android-ui:1.0.0-beta.30
com.mapbox.navigation:android:2.5.0-rc.1
I've uploaded a video showing the issue, you can see that the Android Auto screen seems to freeze but the current speed is still updated. As soon as the app is in foreground on the phones screen it jumps to the current location.
https://user-images.githubusercontent.com/646435/171581735-f9a1d2f9-254e-4a82-8da5-79095065f6c1.mov
Hi @g4rb4g3 this issue is in the example app, so I transferred the issue.
Here's a fix for it https://github.com/mapbox/mapbox-navigation-android-examples/pull/92
Hi @kmadsen
This happens in our production app too and there we do not use Android Auto lib, but pure map box. So this will not fix our issue i think.
We just used the sample app to verify that it's not an issue with our code.
@kmadsen As @SamuelBrucksch mentioned we have that issue in our own app so it is not related to the sample app. Still I tried your mapbox/mapbox-navigation-android-examples#92 PR but that did not change anything. As soon as the app is not running in foreground map updates stop. And as I wrote in the first post we face that issue on certain Xiaomi devices, it is working fine on other phones like my Pixel 3a running Android 12. So please move this issue back over to the mapbox/mapbox-maps repo and have a look at it there. Thank you! EDIT: Forgot to mention that I use a mock GPS app, so I'm not using any replay or something like that.
As additional information... We have 3 custom layers where we draw static data onto the map, like speed limit. The speed limit layer is still updating, so the rendering does not seem to completely stop when the main app is in background. However the map and the locationpuck is frozen.
Still I tried your https://github.com/mapbox/mapbox-navigation-android-examples/pull/92 PR but that did not change anything
Ok thanks for trying it. I found a different issue in the example repository then.
Still I tried your https://github.com/mapbox/mapbox-navigation-android-examples/pull/92 PR but that did not change anything. As soon as the app is not running in foreground map updates stop. And as I wrote in the first post we face that issue on certain Xiaomi devices, it is working fine on other phones like my Pixel 3a running Android 12.
As additional information... We have 3 custom layers where we draw static data onto the map, like speed limit. The speed limit layer is still updating, so the rendering does not seem to completely stop when the main app is in background. However the map and the locationpuck is frozen.
The camera and location have specific configuration in order to make it work correctly. The example repository is responsible for configuration. For example the AndroidManifest must specify the android:foregroundServiceType
. Considering that the speed limit is updating, that indicates that the location is continuing to update.
@g4rb4g3 @SamuelBrucksch can you provide more information on what exactly you are seeing? I'm looking for someone with a Xiaomi
device that can reproduce this issue. But some logs would be helpful.
Can you add logs around the camera update to ensure a location is sent to the location puck and camera, and the Mapbox sdk it is ignoring it? The maps repository has a minimal androidauto example app that should help us determine if it is a maps issue
https://github.com/mapbox/mapbox-maps-android/blob/6b0b4a0925f4655bab7c4bdc443a33343d65c881/android-auto-app/src/main/java/com/mapbox/maps/testapp/auto/car/CarCameraController.kt#L106
Fixed an issue in the navigation examples repo, but transferring this one back to maps as there may be an issue specific to Xiaomi devices
@kmadsen Thank you for pointing me to the other sample app I like it a lot since it doesn't work at all on the Xiaomi device. 😉 It doesn't have any activity so if you just launch the app on Android Auto it is stuck on the position it got while starting up. I added some logging and you can see that the new position is incoming. I also added 2 listeners one for renderFrameStarted and another one for renderFrameFinished. Additionally I added an activity I can launch on the phone to make the map updates work. You can check out all my changes to the app here.
So from the logs you can see that there are quite some call for addOnRenderFrameStartedListener and addOnRenderFrameFinishedListener in the beginning (app started on Android Auto only). Once everything settled you can see many of these: 2022-06-07 10:44:25.374 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D changePositionListener, got new position Point{type=Point, bbox=null, coordinates=[14.0318107, 48.2240837]} 2022-06-07 10:44:25.375 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D changeBearingListener, got new bearing 0.0 2022-06-07 10:44:25.438 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameStartedListener 2022-06-07 10:44:25.440 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D changePositionListener, got new position Point{type=Point, bbox=null, coordinates=[14.031682699600694, 48.224026310360316]} 2022-06-07 10:44:25.442 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D changeBearingListener, got new bearing -7.598346638515068 2022-06-07 10:44:25.458 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameFinishedListener 2022-06-07 10:44:25.461 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D changePositionListener, got new position Point{type=Point, bbox=null, coordinates=[14.031651669195607, 48.224012397718035]} 2022-06-07 10:44:25.465 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D changeBearingListener, got new bearing -9.440370377946238 2022-06-07 10:44:25.475 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameStartedListener
So a new position is arriving but addOnRenderFrameStartedListener and addOnRenderFrameFinishedListener are called once per gps update mostly.
Only when I launch the activity on the phone you can see that the listeners are reporting like we would expect them to and map updates start working on Android Auto. 2022-06-07 10:44:30.381 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D changePositionListener, got new position Point{type=Point, bbox=null, coordinates=[14.02916881403077, 48.22313784773048]} 2022-06-07 10:44:30.381 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D changeBearingListener, got new bearing 237.4023516861871 2022-06-07 10:44:30.389 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameFinishedListener 2022-06-07 10:44:30.402 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameStartedListener 2022-06-07 10:44:30.406 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameFinishedListener 2022-06-07 10:44:30.416 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameStartedListener 2022-06-07 10:44:30.422 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameFinishedListener 2022-06-07 10:44:30.432 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameStartedListener 2022-06-07 10:44:30.437 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameFinishedListener 2022-06-07 10:44:30.450 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameStartedListener 2022-06-07 10:44:30.453 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameFinishedListener 2022-06-07 10:44:30.465 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameStartedListener 2022-06-07 10:44:30.469 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameFinishedListener 2022-06-07 10:44:30.473 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameStartedListener 2022-06-07 10:44:30.477 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameFinishedListener 2022-06-07 10:44:30.481 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameStartedListener 2022-06-07 10:44:30.486 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameFinishedListener 2022-06-07 10:44:30.497 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameStartedListener 2022-06-07 10:44:30.505 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameFinishedListener 2022-06-07 10:44:30.514 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameStartedListener 2022-06-07 10:44:30.517 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameFinishedListener 2022-06-07 10:44:30.522 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameStartedListener 2022-06-07 10:44:30.526 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameFinishedListener 2022-06-07 10:44:30.530 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameStartedListener 2022-06-07 10:44:30.534 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameFinishedListener 2022-06-07 10:44:30.539 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameStartedListener 2022-06-07 10:44:30.542 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameFinishedListener 2022-06-07 10:44:30.556 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameStartedListener 2022-06-07 10:44:30.556 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameFinishedListener 2022-06-07 10:44:30.566 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameStartedListener 2022-06-07 10:44:30.571 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D addOnRenderFrameFinishedListener 2022-06-07 10:44:30.576 10388-10388 CarCameraController com.mapbox.maps.testapp.auto D changePositionListener, got new position Point{type=Point, bbox=null, coordinates=[14.02916881403077, 48.22313784773048]}
Is there any update on this issue? Any fix in sight? I use same phone as @g4rb4g3 - Poco F3 with Android 12 (latest update). I want to use ABRP with AndroidAuto but I need to have the app open and active on my phone all the time. Cheers, Andreas
@kmadsen could you please give an update on the process of this? We are getting more and more reports from Xiaomi users. As this seems to be reproducible easily, could you please rank this a bit higher so we can release an update for the affected users before the summer holidays start?
@pengdev @tobrun @kmadsen can anyone please comment on this? This should really affect the usage of this library for a lot of users, if it can't work on Xiaomi unless the phone screen is on...
Hi @SamuelBrucksch thanks for reporting the issue, we are still trying to get access to a compatible Xiaomi device to reproduce this issue, will keep you posted about the progress.
@pengdev it isn't just xiaomi. Have the same issues on my huawei p30 pro
Hi, @pengdev and @kmadsen, for what it's worth I'm also not sure how device-specific this is. I have the same problem on a Samsung S21. (I arrived here from this bug thread on the ABRP forum)
More and more reports incoming on this. We had to buy a Poco F3 ourself to replicate the problem. If you can't find anyone with a phone please order one so you can fix this.
Hi, @pengdev and @kmadsen, for what it's worth I'm also not sure how device-specific this is. I have the same problem on a Samsung S21. (I arrived here from this bug thread on the ABRP forum)
Samsung is a separate issue and not related to this. A fix will be available soon.
We got another report from Xiaomi Mi11 pro. So it seems like any Xiaomi device on Android 12 will do.
Got the same Problem on an older Huawai p20 with Android 10 on it
I've ordered a Poco F3 but it'll be here tomorrow at some point
I've ordered a Poco F3 but it'll be here tomorrow at some point
If it helps out with Huawai I will donate a bit 😁
I have a Xiaomi Poco F3. I was not able to reproduce on the out of the box version - on Android 11. I also tested with multiple mock GPS location apps (GPS Locations and Mock GPS with joystick).
Poco F3 with Android 12 (latest update)
I'm updating the phone to test the latest update with Android 12, but posting this because it does work on certain Xiaomi builds.
https://user-images.githubusercontent.com/3021882/180613960-63fdbbe6-0917-4b0f-8a5a-a700da347d0e.mov
@kmadsen Thanks for the update, as pointed out in the first post the issue happens on Android 12 for sure. I did not test it with Android 11 since I did the update straight after unpacking it.
The system updates available are for the MIUI, so I updated to MIUI 12.5.6 and it worked again.
I'm not seeing an option to upgrade to Android 12, but am seeing an option to upgrade the MIUI (next is 13.0.4.0). EDIT reading online, and sounds like this should also update to Android 12 🤔
Yes MIUI 13 is Android 12. People told us this issue started after the update, so according to them it still worked on Android 11.
Ok sounds good, thanks! I'm about to go on a hike (test drive to the trailhead), so after the update I'll be able to see the issues on a few apps. Will dig into potential solutions when I'm back by a computer.
It's still working for me after the update, on the desktop head unit. I'm getting the same result as the video here https://github.com/mapbox/mapbox-maps-android/issues/1413#issuecomment-1193151608
Model: M2012K11AG MIUI version: 13.0.4Stable, 13.0.4.0(SKHMIXM) Android version: 12 SKQ1.211006.001 Android security update 2022-06-01
I'm still going for a test drive to see the non-mocked locations. But is there potentially, another setting that needs to be enabled/disabled in order to reproduce this? For example, the GPS Locations suggests this and I haven't enabled that yet.
On Android 10 it won't work also.
We only used the sample apps as they are and didn't do anything else. The phone screen must be off for the not moving map to show.
OK I am able to reproduce the OP issue locally. I'm unable to reproduce in the android-auto-app as mentioned here https://github.com/mapbox/mapbox-maps-android/issues/1413#issuecomment-1148398491. My repo steps require you to first, have an open mobile app and then close it.
EDIT: I updated the log to prove the animation is animating from start
to start
when app is backgrounded.
Devices reproduced on
Xiaomi MIUI 13.0.4 Android version 12 SKQ1.211006.001
Repo steps
- Launch an app with an Activity (qa-test-app or android-auto-app)
- Launch the desktop head unit (for example: $ make car)
- Kill the mobile app (or put app in background)
- Animations have stopped working
- Scroll the map
- Try to recenter the map, notice the animation will not work
Looks like an animation issue
I am able to fix the recenter button by removing the usage of AnimatorSet
mapboxMap.setCamera(cameraOptions)
return AnimatorSet()
// return ifNonNull(pluginImpl) {
//
// flyFromLowZoomToHighZoom(cameraOptions, it, transitionOptions)
// } ?: fromLowZoomToHighZoom(cameraOptions, transitionOptions)
Video and logs
I added a log animator to the MapboxNavigationCameraTransition. The logs include an expected update (animates a value from 5.0 to 10.0). When the activity is backgrounded, the value animator will still be triggered but it animates from 5.0 to 5.0. Resulting in no movement from the animations.
https://user-images.githubusercontent.com/3021882/180879867-15a3c473-a308-48f0-bb7c-f437ed5cee06.mov
inner class LogAnimator : ValueAnimator() {
init {
addPauseListener(
onResume = { logI("onResume", "kyle_debug") },
onPause = { logI("onPause", "kyle_debug") },
)
addListener(
onStart = { logI("onStart", "kyle_debug") },
onCancel = { logI("onCancel", "kyle_debug") },
onEnd = { logI("onEnd", "kyle_debug") },
onRepeat = { logI("onRepeat", "kyle_debug") },
)
addUpdateListener {
logI("onUpdate ${it.animatedValue as Float}", "kyle_debug")
}
setFloatValues(5f, 10f)
}
}
2022-07-25 15:08:03.006 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onStart
2022-07-25 15:08:03.006 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 5.0
2022-07-25 15:08:03.006 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 5.0
2022-07-25 15:08:03.025 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 5.0
2022-07-25 15:08:03.041 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 5.03501
2022-07-25 15:08:03.068 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 5.139059
2022-07-25 15:08:03.079 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 5.321965
2022-07-25 15:08:03.099 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 5.557135
2022-07-25 15:08:03.108 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 5.8664484
2022-07-25 15:08:03.121 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 6.227397
2022-07-25 15:08:03.146 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 6.60408
2022-07-25 15:08:03.157 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 7.031547
2022-07-25 15:08:03.172 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 7.447644
2022-07-25 15:08:03.192 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 7.8910856
2022-07-25 15:08:03.210 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 8.297399
2022-07-25 15:08:03.223 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 8.704385
2022-07-25 15:08:03.243 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 9.05287
2022-07-25 15:08:03.253 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 9.3752775
2022-07-25 15:08:03.270 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 9.624731
2022-07-25 15:08:03.287 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 9.824441
2022-07-25 15:08:03.306 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 9.94537
2022-07-25 15:08:03.320 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 9.998766
2022-07-25 15:08:03.336 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 10.0
2022-07-25 15:08:03.336 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onEnd
2022-07-25 15:08:04.022 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onStart
2022-07-25 15:08:04.022 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 5.0
2022-07-25 15:08:04.022 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 5.0
2022-07-25 15:08:05.052 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onCancel
2022-07-25 15:08:05.052 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onEnd
2022-07-25 15:08:05.055 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onStart
2022-07-25 15:08:05.055 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 5.0
2022-07-25 15:08:05.055 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onUpdate 5.0
2022-07-25 15:08:06.043 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onCancel
2022-07-25 15:08:06.044 qa_test_app I/Mapbox: [nav-sdk]: [kyle_debug] onEnd
I just updated my phone to the latest firmware: MIUI: MIUI Global 13.0.7 Stable (SKHEUXM) Android 12 SKQ1.211006.001
Still seeing the same behavior like in the first post. I added some logging to MapboxNavigationCameraTransition.kt and I see the same, as soon as the screen is off or the app is not in foreground the centerAnimator gets the same coordinates over and over. https://user-images.githubusercontent.com/646435/180968316-9ffaeec4-9090-43d6-997c-5218f52f6900.mp4
To create some nice screen captures you can use scrcpy
Good idea with scrcpy :). Next, wanted to find if something in Mapbox SDKs is canceling the animations. Here is an empty project, reproducing the issue without a Mapbox SDK hellocar.zip
This is most likely an issue with the MIUI
system disabling animations. I am still unable to reproduce on Pixel 4XL which is running Android 12.
https://user-images.githubusercontent.com/3021882/181044841-4c1883fe-9561-4c0f-b2fd-e65465141722.mov
class MainSession : Session() {
--snip--
init {
lifecycle.addObserver(object : DefaultLifecycleObserver {
override fun onCreate(owner: LifecycleOwner) {
var lastAnimator: ValueAnimator? = null
lifecycle.coroutineScope.launch {
while (isActive) {
lastAnimator?.cancel()
lastAnimator = LogAnimator().apply { start() }
delay(1000)
}
}
}
})
}
}