lovegaoshi / react-native-track-player

A fully fledged audio module created for music apps. Provides audio playback, external media controls, chromecast support, background mode and more!
https://react-native-track-player.js.org/
Apache License 2.0
2 stars 12 forks source link

[Android Auto] Event.RemoteBrowse behaves weired #26

Closed schoetty closed 10 months ago

schoetty commented 11 months ago

Screencast_TrackPlayer_AndroidAuto_RemoteBrowse.webm

Describe the Bug The RemoteBrowse event doesn't fire for the first two elements (tabs in the example project, but also applies to list items) after an audio has played.

Steps To Reproduce

  1. Open the example Project on Android Auto.
  2. Start an audio
  3. Switch between tabs. The first two don't trigger Event.RemoteBrowse

Replicable on Example App? Yes

lovegaoshi commented 11 months ago

thats confusing... I dont have the dev setup on hand, will look over the weekend.

does android studio logcat emit Timber.tag("GVA-RNTP").d("RNTP received loadChildren req: %s", parentMediaId) for the first two tabs? I want to say podverse was fine, this is the demo I did and the podcast tab content update is done via RemoteBrowse

where it was still updating after the podcasts were played

schoetty commented 11 months ago

Sadly, loadChildren is not executed in said cases, so "RNTP received loadChildren req: %s", parentMediaId is not logged either.

It is interesting that it seems to work in podverse.

You're using slightly different versions of KotlinAudio and Trackplayer in podverse, right? Maybe one of the differences is causing this side effect.

I noticed the problem when I refactored our app. I wanted, similar to podverse, that initially only the basic navigation (the tabs) for android auto would be set in trackplayer and then the data would be updated on each RemoteBrowse event. Unfortunately, this does not work properly when the events are missing.

lovegaoshi commented 11 months ago

i wasnt able to reproduce this with the example app:( I did synced up to RNTP's main again, as well as KA. maybe this did the trick? podverse's KA is a bit customized mostly because podverse is staying at RNTP v4 rc04, though KA did have a few quite big metadata handling changes since... pardon the poor quality rntp.webm

schoetty commented 11 months ago

Hey @lovegaoshi! To further isolate the problem I tested the current develop branch of podverse on my system. Here the problem also occurs. It shows the same wrong behavior as in my project and the example project. Since we are using the same Android Auto emulator, the problem could be due to the mobile device or the android version used. I am using a Pixel 5 and a Pixel 7a, both with the latest Android 14 for testing. Which Android version is running on your test device/emulator?

lovegaoshi commented 11 months ago

it was samsung S21 + android 13, here's pixel 7 + android 14 (UI1A.231005.007), still seems normal to me:( am I not reproducing it right?

pixel7

schoetty commented 10 months ago

it was samsung S21 + android 13, here's pixel 7 + android 14 (UI1A.231005.007), still seems normal to me:( am I not reproducing it right?

In your screencasts everything works normally. This is really confusing.

lovegaoshi commented 10 months ago

from the podverse feedbacks so far i dont think this has been reported yet:( i will ask podverse to keep an eye out too

schoetty commented 10 months ago

I did another test today just to make sure it wasn't my development setup. I deployed the app to my phone via the Play store and tried it with a real Android Auto device. Unfortunately, the issue occurs in this case as well :man_shrugging:.

lovegaoshi commented 10 months ago

hmm... I watched the videos again and I saw in your env when RemotePlay triggered, RemoteBrowse on the first two tabs also fired. On mine they didnt.

I'm not sure why though... arent we both using the latest commit from the example app?

I noticed there can be an infinite loop scenario in RemoteBrowse when calling TP.setBrowseTree within it. For podverse this was at the History tab and I ended up using a simple debounce https://github.com/podverse/podverse-rn/pull/1928/files#diff-2dcab85da4f5a4f80b50152ec9193f717dbb38244509d742c2ee65cb3f444661R65 still doesnt explain why the example app behaves differently on our setups... Or it could be I needed to be on tab3 and playback? I can try later today

lovegaoshi commented 10 months ago

just tried, tab location is not it:S still all seems normal

schoetty commented 10 months ago

In my testing today, I found the following: When an audio is loaded from the rntp app, I get the "wrong" event behavior. When an audio is loaded from another app (e.g. Google podcasts), the events behave correctly with onClick. I made a screencast of this for clarification:

Video

P.S. Sorry, i just saw that the mouse cursor is not visible on the screencast. i hope it is still clear.

lovegaoshi commented 10 months ago

oh ok! i did reproduce with https://github.com/schoetty/react-native-track-player/tree/dev-android-auto. still no idea why yet, but could you update/test RNTP dependency to https://github.com/lovegaoshi/react-native-track-player/tree/dev-android-auto ? that recently synced fork works fine on my end.

schoetty commented 10 months ago

The tests today were at commit 34e5d259be518a55bf9909aaeb582cd1237ac61a. I have retested the current state (31170ae) but come to the same conclusion. I even cleared the gradle cache. But without success.

lovegaoshi commented 10 months ago

might be my gradle cache then, i'll load up on another computer later today

lovegaoshi commented 10 months ago

@schoetty I have bad and even worse news :( The bad news is I did reproduce this issue, but couldnt get it "working" again on my samsung phone. my pixel is still fine. And yes the issue is exactly as you described: when mediaSession is currently playing, the first 2 browsable items in root are automatically fired and the results are "cached," preventing further onloadchildren calls. when mediaSession is not playing anymore this is "released" and onLoadChildren is called again. The even worse news is this is NOT specific to RN; I forked google's media player example repo UAMP and it's behaving the same. bad on samsung, good on pixel. Now i'm believed this is some very obscure phone setting i'm not aware of... before i magically figure out the solution, the best workaround I can think of is to sacrifice a tab slot and use the first two MediaItem in / to be playable items; this makes them hidden in the "More" menu and you get 3 good tabs at least (which for podverse it will do for now...).

ss

p

lovegaoshi commented 10 months ago

after sacrificing my car data I found out my samsung "works" again now by uninstalling and reinstalling android auto the app:/ win some lose some.

schoetty commented 10 months ago

So, today I installed the latest beta version of the Android Auto app (10.7.134154) on my Pixel 5 and that has solved the problem with the events.

lovegaoshi commented 10 months ago

:/I'm fairly sure this is an android auto bug/hidden configuration.