Bad interaction with Android TV Core Services leading to stutter



Hello Kodi Community

I am running Kodi 20.5 from the Google Play Store on a Sony Bravia 4K UR3 TV (full model number: KD-49X8000H). I am streaming videos from a Raspberry Pi via wired ethernet, using the SMB protocol. Somewhen in the past few months I started noticing intermediary stutters in both sound and video. These stutters happen approximately every 3-4 minutes.

I spent some time debugging and noticed that whenever the stutter happens, [kworker/0:2H-mmc_complete] shows up high in the top output (run via adb shell). I first wiped all kodi settings and later on did a reset on the Android level but the problem remained after a reinstallation of just kodi without adding further updates. However, I did notice com.google.android.tvrecommendations activity shortly before a stutter happens, and sure enough disabling this package (Called “Android TV Core Services” in the list of system applications) made the problem go away.

I believe this is a bad interaction between Kodi and Android TV Core Services. I do not have the same problem with other apps, for example watching the same content in the same setup with VLC. I do not see mmc_complete activity in adb top when I am not watching something via kodi.

One suspicion I have is that Kodi feeding information about the current playback status is linked to the problem. In adb logcat I see lines like these:

04-10 23:31:03.179  3285  3285 V AvrcpMediaPlayerWrapper: onPlaybackStateChanged(): org.xbmc.kodi : PlaybackState {state=3, position=2431473, buffered position=0, speed=1.0, updated=2713377, actions=-1, custom actions=[], active item id=-1, error=null}

Disabling Android TV Core Services made the playback status on the home screen go away.

I am posting this in the hope that maybe others have seen similar issues and either can provide more clues how to further pin down the problem or make use of my workaround. Interestingly the same media content seems to play OK with kodi and Android TV Core Services enabled from a USB drive plugged into the TV itself.

Some things I tested without success during my debugging:

  • Edit caching settings. Neither disabling caching entirely nor making a bigger memory cache or disk cache helped. (Though since VLC and even kodi with the workaround work fine I believe my hardware and network setup is OK)
  • Try NFS instead of SMB. No change.
  • Try to move the kodi data directory to a USB drive via xbmc_env.properties and separately by formatting the USB drive as internal memory extension and telling android to move Kodi there.
  • Play with various fps and synchronize playback to display settings.
  • Disable HW decoding
  • Tried different content, in particular lower bitrate ones. It didn’t make a noticeable difference.

Some more system data:
The Android version on my TV is Android 10. Linux kernel 4.19.75. The last update is about a year old. The system has 2 GB of RAM, which are about 70% utilized according to Kodi’s system summary. (top says 1.9G used, of which ~500 MB are disk cache, and free memory hovers around 100-200mb.) The system for some reason has 100 mb swap, which fill up over time. I don’t know where this swap is located nor can I disable it because I don’t have root access. If I had root I’d love to make use of /proc/sys/vm/block_dump…