Android Bad interaction with Android TV Core Services leading to stutter
#1
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...
Reply
#2
Thanks for tracing that down. Could you please open an issue on our github (adding adb and debug.log?), so that we don't loose track? My assumption is that we store this on local disk (while mmc interrupt could also be from an sdhci wlan card) and we should definitely avoid that
I think it's a remnant from the past used for bluetooth interaction, but that definitely should not be doing something as long as no BT controllable devices are connected.

Thanks again.
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply
#3
Sure thing, I'll file a bug report and will try to correlate the stutter with the approximate location in the logs. It might take me a day or two to get around to collect them though.

I don't think the mmc interrupts are linked to wifi. I have the TV connected via ethernet and wifi disabled (not just not connected) and also disabled the wifi location scanning option (I forgot what it is called exactly). Of course I can't rule out that Sony's platform is doing something stupid behind my back.
Reply
#4
(2024-04-11, 10:19)stefandoesinger Wrote: Sure thing, I'll file a bug report and will try to correlate the stutter with the approximate location in the logs. It might take me a day or two to get around to collect them though.

I don't think the mmc interrupts are linked to wifi. I have the TV connected via ethernet and wifi disabled (not just not connected) and also disabled the wifi location scanning option (I forgot what it is called exactly). Of course I can't rule out that Sony's platform is doing something stupid behind my back.

Yeah - I also don't think so, but I wonder about the CPU spike. There is no reason for an eMMC to spike, besides ... misconfigured DMA, cpu only mode, etc. - for WLAN it's quite common, especially if it's a Wifi / BT Combo chip. and As AVRCP is linked to Bluetooth - it could actually still be some SDIO interrupts tunneled via SDHC with a broken NAPI driver ... Does the error go away if you also entirely disable Bluetooth?
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply
#5
I think I tested disabling bluetooth (it was a bit tricky because the remote is bluetooth, so I had to use a USB keyboard) and I don't remember it getting rid of the problem. I'll recheck when I record the logs. I am also not sure if I disabled wlan (as opposed to not being connected to anything) and bluetooth at the same time or separately.

Is there a way to disable AVRCP in Kodi to check my theory that they are related to the bug - preferably without recompiling it?

Btw I mentioned in my original post that the problem started somewhen in the past months. I don't remember it happening when I bought the TV in late 2021 and set up Kodi. Kodi and the Android system saw some updates over time. We didn't use it much for over a year and the problem popped up when we used it again earlier this year. I tried downgrading to Kodi 19.0 but it showed the same problem - so I suspect it got introduced by one of the system updates, but I don't have hard proof.
Reply
#6
It's the other way round :-(. For some Leanback Support (iirc) kodi basically answers all those calls ...
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply
#7
We have similar issue in all Homatics R4k plus  boxes, in ATV12 firmware with 4K tvs in fw testing groups.
We tryed all possible kodi versions too, issue is same.
When playing any media, hd or 4K , after some time, once 20 min later, once 2 hours later
the framerate go down ( we can see that, in kodi log overlay what we switched on earlier)
Normal usage the 23,976 hz movie show 23,4-24,4 FPS,
when the issue coming, go down to 12-16 FPS and the movie will hard stuttering..
Once stop the playing  and start again, the issue gone.
This issue is so random, very hard to debug.
On time play movie 2 hour, no issue, next movie 2 hour no isssue.
Sometimes after half hour, coming the stuttering, sometimes later.
No issues in streaming apps..

So when you freeze the Android TV Core Services, your issue not present?
Maybe I can try theat.
Reply
#8
(2024-04-12, 07:18)frodo19 Wrote: We have similar issue in all Homatics R4k plus  boxes, in ATV12 firmware with 4K tvs in fw testing groups.
We tryed all possible kodi versions too, issue is same.
When playing any media, hd or 4K , after some time, once 20 min later, once 2 hours later
the framerate go down ( we can see that, in kodi log overlay what we switched on earlier)
Normal usage the 23,976 hz movie show 23,4-24,4 FPS,
when the issue coming, go down to 12-16 FPS and the movie will hard stuttering..
Once stop the playing  and start again, the issue gone.
This issue is so random, very hard to debug.
On time play movie 2 hour, no issue, next movie 2 hour no isssue.
Sometimes after half hour, coming the stuttering, sometimes later.
No issues in streaming apps..

So when you freeze the Android TV Core Services, your issue not present?
Maybe I can try theat.
Are you sure that your issue is actually similar? The OP has them every 3 to 4 minutes, not only after 2 hours. But never the less ... if someone wants to shortly kill the Leanback Support / patching it out - it's a first test.
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply
#9
Im not sure if that full similar, but I would try all was possibe..
That interesting is, this issue not come in the same boxes, with ATV11 firmwares.
Reply
#10
My 3-4 minute interval is fairly random, but certainly not every few hours. And I don't have to stop and restart the playback. Though now that I am trying to record logs it happened only twice in half an hour, which is a bit annoying - and the second time was after I cancelled the logcat write.

I filed https://github.com/xbmc/xbmc/issues/24980 with logs attached
Reply
#11
I have this stuttering to, with my nvidia shield 2015. Stuttering so badly after 10-20mins that i need to switch to vlc to watch.
Reply
#12
Come on guys - when I see the next "me too" without any Debug Log highjacking other people's threads, which are MediaSession related - I will simply close these threads. We are 10 years into the Android game ... and 10 years the forum kindly asks before posting to provide a Debug Log. A "me too" does not help at all.

See the OP as a very good example, he provided everything and even started debugging by himself, so don't highjack his thread, just cause I reply here.
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply
#13
So OP's orignal issue vanished after TV reboot, wife out of home with her IPhone.

As you two guys have the "same bug" as the OP -> we can close it now anyways as solved ....
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply
#14
Yeah close this thread here. Anyone who sees similar problems on a Sony device can find more details of my investigation in the linked bug report. As fritsch says be careful about concluding that your bug has the same cause though because movie stutter is a very generic problem that can have many reasons.
Reply
#15
This AVRCP thingy goes on my nerves since some years actually ... I sent a PR so that when we have video playback that the stuff is only updated once per minute and not twice per second. Let's see if someones usecase gets broken ...
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply

Logout Mark Read Team Forum Stats Members Help
Bad interaction with Android TV Core Services leading to stutter0