Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MusicService.kt to FIX [4.0.1] Crash: com.doublesymmetry.track… #2385

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mayank-paryani
Copy link

…player.service.MusicService.startAndStopEmptyNotificationToAvoidANR

Update MusicService.kt to FIX [4.0.1] Crash: com.doublesymmetry.trackplayer.service.MusicService.startAndStopEmptyNotificationToAvoidANR

#2244 (reference)

…player.service.MusicService.startAndStopEmptyNotificationToAvoidANR

Update MusicService.kt to FIX [4.0.1] Crash: com.doublesymmetry.trackplayer.service.MusicService.startAndStopEmptyNotificationToAvoidANR 

doublesymmetry#2244 (reference)
@lovegaoshi
Copy link
Contributor

lovegaoshi commented Oct 18, 2024

but this doesnt fix any of the underlying problem. if ur app actually crashes with this, this try catch block isnt fixing anything. so for people reporting this "fixes" their problem, this ANR/crash actually does not affect UX to begin with.

While I mostly guessed my answer in the issue thread, it is indeed correct - the reason for startAndStopEmptyNotificationToAvoidANR is to prevent the android limitation that a playback service must start playback within X seconds of it being started. and since MusicModule creates the service when setupPlayer is called, no media playback can be guaranteed and thus this function is used.

And back to the question - why ru seeing this? several possibilities:

  1. your service creation is so late and somehow the activity gets pushed in the background. which is quite unlikely for most people adopted the example app's setup.
  2. your service crashed and attempted to be restarted while your app is in the background state. this is very relevant especially since the 5 seconds no playback kill service option that was recently added. Although I dont think it is actually the case here, as this will severely affect UX and it doesnt appear to be so.

In addition, at least with a full media3 service migration, MusicService appeared to be started by the system automatically as UI will bind to the declared mediaSession, via multiple MediaButton intent/onStartCommand calls.

TLDR: its either an app setup problem that YOU did, or you can try keeping your MusicService alive for as long as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants