BimmerGestalt / AAIdrive

Implementations of some Android Auto features as unofficial IDrive apps
MIT License
551 stars 90 forks source link

Widescreen map (and screen mirroring) crashes the headunit on EntryEvo_ID5 #536

Open unlive74 opened 2 years ago

unlive74 commented 2 years ago

Thank you for this opportunity to test the maps. This is wonderful. First bug report: maps are falling. Sometimes with Spotify view from 9:24 logcat_02-22-2022_09-29-02.zip

hufman commented 2 years ago

Thank you for the quick test! From the log, it looks like MyBMW itself is telling AAIdrive to shut down and reconnect. Of the three connection sessions, I don't see a matching number of Bluetooth disconnect/reconnections, so I suspect MyBMW's watchdog is closing the connection for some reason. Does it work longer if you have recently restarted the phone, perhaps to increase the available ram?

[02-22 09:18:57.172 4334:4503 I/CachedBluetoothDevice]
updating profiles for BMW 37069

[02-22 09:21:09.058 4299:5016 W/bt_rfcomm]
port_rfc_closed: RFCOMM connection closed, index=29, state=3 reason=Closed[19], UUID=1101, bd_addr=..., is_server=0

[02-22 09:21:09.073 27832:8470 W/CarProber]
Exception while pinging car

[02-22 09:21:09.126 27832:27832 I/IDriveConnectionListen]
Received car announcement: com.bmwgroup.connected.accessory.ACTION_CAR_ACCESSORY_DETACHED

[02-22 09:21:15.731 4334:4503 I/CachedBluetoothDevice]
updating profiles for BMW 37069

[02-22 09:21:16.108 27832:27832 I/IDriveConnectionListen]
Received car announcement: com.bmwgroup.connected.accessory.ACTION_CAR_ACCESSORY_ATTACHED bmw 14@127.0.0.1:4007

[02-22 09:23:14.107 27832:13059 I/CarThread]
Shutting down thread MusicAppService due to RuntimeException: org.apache.etch.util.TimeoutException: timeout waiting for de.bmw.idrive.BMWRemoting._result_rhmi_setData(-1822907036)

[02-22 09:23:14.300 27832:27832 I/IDriveConnectionListen]
Received car announcement: com.bmwgroup.connected.accessory.ACTION_CAR_ACCESSORY_DETACHED

[02-22 09:23:20.678 27832:27832 I/IDriveConnectionListen]
Received car announcement: com.bmwgroup.connected.accessory.ACTION_CAR_ACCESSORY_ATTACHED bmw 14@127.0.0.1:4007

[02-22 09:23:20.890 4334:4503 I/CachedBluetoothDevice]
updating profiles for BMW 37069

[02-22 09:27:36.856 27832:8470 W/CarProber]
Exception while pinging car

[02-22 09:27:36.863 27832:27832 I/IDriveConnectionListen]
Received car announcement: com.bmwgroup.connected.accessory.ACTION_CAR_ACCESSORY_DETACHED

[02-22 09:27:53.521 4334:4503 I/CachedBluetoothDevice]
updating profiles for BMW 37069
unlive74 commented 2 years ago

I'll try tomorrow morning (it's already night now) to reboot the phone and try again. Strangely, when the cards dropped, there was no disconnect, just the cards logo disappeared in the ConnectedDrive menu and then appeared again.

jezikk82 commented 2 years ago

Hi, I compiled my own version with added keys to mapbox but in the app/car I don't see any options about mapbox, only gmap. Can you add instruction on how to have gmap and mapbox in car.

hufman commented 2 years ago

Similar to the gmap build variant, the mapbox code adds a mapbox option to the Build Variants panel. They share the same unlabelled icon in the car and have roughly the same features and options, but the map and search results come from the respective gmaps or mapbox libraries. I do need to add an icon to the Map tab in the phone UI as a clue to what brand is providing the maps data. Do you see the mapbox options in the Build Variants panel? You might need to use the File>Sync with Gradle option to update the list.

jezikk82 commented 2 years ago

I see mapbox option in build variants. Will test it today.

Is it/Will be possible to have both maps present in car ? So you can choose on the go, what to use.

hufman commented 2 years ago

No, supporting both map providers in the same build is not planned. Of the few people who are inclined and capable of building the gmap build, very few would also want to also include the lower-quality mapbox information.

unlive74 commented 2 years ago

When viewing the map and playing in Spotify today, entrynav2 froze - the sound disappeared and the image of the map froze. At the same time, when I turned off the bluetooth on my Samsung s8, entrynav2 remained the same, only restarting entrynav2 helped. Maybe my old phone is running out of memory? logcat_02-26-2022_11-34-01.zip around 11:32

hufman commented 2 years ago

Is there perhaps some commonality of the IDrive versions that are experiencing this? Can you share the IDrive Version from the Car Information tab? My car (which seems to be working fine) is running EntryEvo_ID5_2007_Release_ID5_2007-510-2012A Build 33-Rev:210125 2020-03-12

unlive74 commented 2 years ago

hmi.type: BMW ID6L hmi.version: EntryEvo_ID5_2007_Release ID5_2007-510-2012A Build 33 - Rev:210125 2020-03-12 10:34:41 navi: false tts: false vehicle.type: F39

hufman commented 2 years ago

I wonder, is it a memory pressure thing, causing MyBMW to lock up? My Galaxy S9 with 4GB of ram hasn't experienced this problem ever. Does it work slightly better after a fresh reboot of the phone?

berseker commented 2 years ago

Screenshot_20220331-214141_AAIdrive_1 I have the same behaviour reported by unlive74.. phone Is a redminote 7 by Xiaomi, 4gb ram

unlive74 commented 2 years ago

By the way, I still use MyBMW 1.4.3, later builds periodically do not start a connection with the car until I launch the application on my smartphone. All greens are off. I think 4 Gb is critically small.

bogdan-calapod commented 2 years ago

When viewing the map and playing in Spotify today, entrynav2 froze - the sound disappeared and the image of the map froze. At the same time, when I turned off the bluetooth on my Samsung s8, entrynav2 remained the same, only restarting entrynav2 helped. Maybe my old phone is running out of memory? logcat_02-26-2022_11-34-01.zip around 11:32

Also encountered this while using screen mirroring with Spotify in the background. I'm going to try with YouTube music - maybe there's some memory leak with Spotify?

Galaxy S21 5G Android 12 OneUI 4.1 with 8 GB RAM + 8GB RAM Plus setting

bogdan-calapod commented 2 years ago

@unlive74 by any chance do you also have a SmartWatch linked to your phone? I'm thinking maybe the Bluetooth connection can't handle a watch and the idrive connection in parallel?

unlive74 commented 2 years ago

@bogdan-calapod There are no additional bluetooth devices. Absolutely clean phone - stock firmware, recently did a factory reset ... ByBMW 1.4.3 (newer builds are periodically unloaded from memory)

bogdan-calapod commented 2 years ago

Hmm, I'm on My BMW 2.3.3 (latest) and except from when running screen mirroring or the new integrated map I've never had OOM errors

berseker commented 2 years ago

I have same issues of unlive74, i have usually a MiBand4 Always connected with the phone. I noticed that if i use mirroring or Mapbox only, usually i have no issues. If i listen my MP3 collection with musicolet at the same time, 90 % of times i get some freezing as described by unlive74, or sometimes the music goes on but the system Is freezed ( no Song swiching, no cover changing on id6 tiles, no possibility to change connected app..) Sorry but up until now my phone does not have root anymore so i struggle to get good output from logcat

bogdan-calapod commented 2 years ago

@berseker I'm seeing the same behavior, even with YouTube Music, might be something related to playing music whilst doing casting causing a memory leak?

bogdan-calapod commented 2 years ago

@unlive74 @berseker by any chance do you also use widgets on your home screen?

I have quite some widgets set up, maybe they fill up the memory and the os prioritizes them for some reason?

@hufman do you use many widgets on your home screen?

hufman commented 2 years ago

I use no home screen widgets on my Galaxy S9

berseker commented 2 years ago

I use only the Google search bar widget.. in any case i really would like to help more but i noticed that my phone not rooted basically gives me a logcat of a Few seconds , It doesnt show any history.. do you have suggestions to give me? (Or must i root the phone?)

hufman commented 2 years ago

The logcat buffer size can be adjusted from within the Developer Tools section of the Settings. Have you noticed any correlation between the Widescreen mode of the map and the crash chances? I wonder if (especially for @unlive74's headunit crash) the JPG file size is using up too much memory in the infotainment system, and perhaps it might crash less often if the JPG is smaller and not-widescreen. Perhaps @berseker's car has a slightly newer version and so it only restarts the Bluetooth connection of his car in this situation instead of locking up entirely.

unlive74 commented 2 years ago

I have 2 widgets - weather and google search. The size of the map does'nt affect the freezes, the map hangs in the same way, sometimes it happens if spotify or another music source is turned off. Soon I'll need to go to the dealer, I'll ask him to update the program in my Entrynav2, maybe it will help. Although the correct and logical step is to change the phone, 4 Gb is too small.

berseker commented 2 years ago

As far as i can see, unlive74 hmi release Is more recent than mine

bogdan-calapod commented 2 years ago

Went for a short drive with the older screen mirroring apk (the one with the smaller display view) with YouTube (not music) in background and after disabling the Samsung adaptive battery.

Happy to report that I haven't experienced any background crashes.

bogdan-calapod commented 2 years ago

So I drove around a couple of hours with waze via screen mirroring (small window) and it worked just fine, meanwhile the large map or large version of screen mirroring always locks up after a couple of minutes or so - I feel like the problem is related to processing the larger image somehow 🀔

unlive74 commented 2 years ago

@bogdan-calapod And what happens in those few minutes before the app freezes? It seems to me if the problem is in large files, then this should happen faster?

bogdan-calapod commented 2 years ago

Music stops if it is playing, and afterwards it seems that the car gets really confused and can't connect to any Bluetooth devices anymore unless a reboot is done.

Disconnecting works but reconnecting keeps sending Another Bluetooth operation is in progress messages until I stop the car and leave it off for a couple of minutes so that iDrive reboots.

By large files, are you referring to the large "view", as in the larger transfer that the phone has to do to the car ?

The fact that the car also locks up makes me think that there's something going wrong on the car side as well, somehow. Maybe the amount of data is too much for the car's Bluetooth to handle ?

@hufman would it make sense that USB Apps connection would not cause issues if the problem is the large "file size" ? I'm going to test this out tomorrow 🀔

hufman commented 2 years ago

I'm not sure! Both the map and the screen mirroring send higher quality JPGs over USB, so the filesize theory would suggest it should happen faster over USB. Otherwise it's the same protocol and same commands that are being sent to the car...

bogdan-calapod commented 2 years ago

So if it happens faster with the large map over USB, or if it happens over USB even with the small mirroring screen, it would mean that one possible solution would be to lower the JPEG quality, right ?

I'll test out today and get back with results

bogdan-calapod commented 2 years ago

I'm seeing the same behavior on USB as well 😕

bogdan-calapod commented 2 years ago

Disabled wide screen map and 3d buildings and it worked great for a 30min drive, whereas before it would lock up - so it's clearly something to do with processing the larger JPEG image

hufman commented 2 years ago

Try out this experiment build which adds a 30ms delay after each frame, to see if that gives enough time for the car to flush out whatever buffers and not crash. It should be a negligible change, especially over Bluetooth!

unlive74 commented 2 years ago

I tried this build - 10 minutes I enjoyed life, then - everything is as usual. :(

bogdan-calapod commented 2 years ago

Seems to work a bit better for me, at least for a short drive. Only thing I see is that the map window is a bit smaller now compared to the store version ![Uploading 20220419_145020.jpg
]()

Edit - it locked up after around 10 minutes, so same behavior as @unlive74 saw :(

hufman commented 2 years ago

Thank you for the help testing! I am still entirely unable to reproduce this bug :( Do we think that the slight delay in framerate causes enough of a benefit to be merged to the main branch? Does the normal build last the same 10 minutes or much shorter? Does it work better if you close the window every so often and go back to the map?

The map size difference is because the store version has the bmw_xl branch currently, while this map_delay branch is right off of the main branch.

bogdan-calapod commented 2 years ago

For me it doesn't seem to make a big difference, but if it helps with performance in some cases while not changing anything in others, I'd say it's a good idea to merge it.

Does the same change apply to screen mirroring, or would that add-on need to be updated separately?

hufman commented 2 years ago

Screen Mirroring would need the same fix applied separately, most likely. The RHMIDimensions library is shared (pending final measurements before updating that library in Screen Mirroring) but this bug would probably be in the separate code base.

bogdan-calapod commented 2 years ago

So the lockup issue is somewhere in the maps part of the app? I'm seeing the same lockup with the latest screen mirroring apk (the one that made the display bigger) but it works perfectly for pretty long drives with the original smaller display version.

In my testing I've only seen the issue in the maps with the wide-screen option turned on, so I'm thinking the bug would be in the RHMIDimensions library?

hufman commented 2 years ago

That's an interesting correlation! Screen Mirroring doesn't have the widescreen option, always going as big as possible, and it's interesting that Screen Mirroring only started having troubles after getting bigger, while the not-widescreen map never has troubles. The change to expand Screen Mirroring didn't fully involve a change in RHMIDimensions, it mainly just started applying negative-padding like the map does. I'm still leaning towards something about the jpg or image size. Does the problem seem related to image complexity and JPG quality? Does it happen more often over USB (which has a higher JPG quality and thus byte size), or with satellite view (very complex image)? If not, it might be only related to decoded image size in some way.

bogdan-calapod commented 2 years ago

I couldn't see any corellation between the amount of detail in the image and the crash rate - @unlive74 what is your experience?

hufman commented 2 years ago

Try out this test build that reduces the screen height and doesn't display under the top statusbar of the car. It's about 60px of reduced height, multiplied by the width of the screen, and might change how often the car headunit crashes. @bogdan-calapod what IDrive version are you running? I'm still trying to figure out a pattern, so I know whether to add this workaround automatically or what.

berseker commented 2 years ago

I tested the same as bogdan & I can confirm that with "small" map (not fullscreen), via bluetooth only, also listening MP3 music via Musicolet all the time, I drove around 45 km without any issues with normal map, satellite image map, 3d buildings on & off. So as per my experience, there is something strange with fullscreen map going on

my test was run with release 1.3.2-119-ec19e73-custom_dimensions 13 apr 2022 03:11:11

@hufman you posted while I was writing. I will try this new build & report

bogdan-calapod commented 2 years ago

I'm on EntryEvo_ID5_1907_Release (would be nice to be able to copy this from the car info screen 😅) I think it's the same as the one @berseker runs, as we had similar behaviors multiple times

unlive74 commented 2 years ago

Now I tested the build 1.3.2-119-1879e2c-map_withoutpadding. I removed the 3D buildings, leaving only traffic.The fullscreen map fell immediately - literally 10 seconds after the start. After that, there was a problem with establishing a bluetooth connection: it wasn't possible to connect with "apps" - rebooting the phone didn't help, it was solved after removing the bluetooth connection and re-pairing. And by the way, this is not the first time I have to do this shamanism after the maps freeze. The small map worked fine for about an hour.

upd: I ride for three days with a small map - no problems.

bogdan-calapod commented 2 years ago

Same here - worked for ~2 minutes in wide-screen mode and then crashed. Half width map seems more stable (went for a pretty short drive so can't say it won't crash, but for 10 minutes it worked okay)

Side note - I feel like the 60px off the top make the Navi look more "native", I like it 😀

Edit - the small map crashed after about 15 min.

berseker commented 2 years ago

I used it for around 20km (short trip) but without issues. I will further test since it seems it works only for me ;D I noticed only some minor "adjustments" that may be fixed, see below picture.

image

bogdan-calapod commented 2 years ago

@berseker what phone are you using? Any special settings?

berseker commented 2 years ago

Xiaomi Redminote 7 with custom android 11 rom (arrowOS)

hufman commented 2 years ago

I added a warning in the Phone UI if the car is detected with EntryEvo, saying that widescreen mode might be unstable, which should be enough of a disclaimer to unblock the release. I haven't heard of any other models that are having these troubles, even with Mapbox saying there are currently 120 monthly users.