-
Notifications
You must be signed in to change notification settings - Fork 429
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
CastPlayer
produces ForegroundServiceStartNotAllowedException
on media item transition
#245
Comments
Thanks for the report. The service is put to/removed from foreground when I can't think of why that should happen when the player transitions playback from one item to the next. Even when a seek is performed within or across media items,
Accordingly, this seems to be a potential source of the problem, but I'm not sure I understand how. As far as I understand, we have the following scenarios:
The only thing I can think of is that 'adjusting playWhenReady' involves switching One way to verify what is happening would be that you add an |
Thank you for the response @marcbaechinger . I'll investigate more our autoplay logic, but it's pretty basic oneliner -
I added |
Yeah, agreed the But good call regarding the playback error! I haven't taken this case into account. We (the Media3 team) need to think about this case well. Auto re-starting in the background wouldn't work like you say. This would remove the service from and put it back to the foreground. Thanks for bringing this up! Having the logs from |
Okay, so I got some logs from latest release.
I'll be looking into more cases, but if you need any full logs from these cases, I can send it via email. |
Thanks for the analysis. We definitely should look into googlequicksearchbox - Yeah, as you mention. Known issue on Android 12. InternalError - This is actually an obvious one when thinking about it. I haven't noticed this yet though, so thanks for reporting. There is not much we can do about it with the current best practice implementation that is to take the service out of the foreground when not playing. The exception, and the resumption of playback after the error causes interrupts the playback and a retry will cause the I have updated #111 accordingly and I rename this issue to focus on the |
CastPlayer
produces ForegroundServiceStartNotAllowedException
on media item transition
Thank you once again. I just have to mention few things. After receiving an internal error we don't actually try restarting playback by ourselves. We have And |
Thanks for clarification. What is the playback state doing when this happens? Because I'd only expect a fatal error changing the playback state to The case I mentioned regarding retry after a
That's odd. I'll test this. Thanks for mentioning. |
What I can see from the logs:
|
With the scenario above, the service should not be taken off the foreground as far as I can tell. Being in state We need to investigate this. Many thanks for your detailed report. Much appreciated. |
I can confirm that the This explains why the service is taken off the foreground and then produces the reported exception. We will look into |
#minor-release Issue: androidx/media#245 PiperOrigin-RevId: 510456793
#minor-release Issue: #245 PiperOrigin-RevId: 510456793
#minor-release Issue: androidx/media#245 PiperOrigin-RevId: 510456793 (cherry picked from commit a231ff4)
Closing this issue as it is fixed as per commits above. |
Great news, thank you! |
Media3 Version
1.0.0-beta03
Devices that reproduce the issue
Various devices running android 12 and android 13
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Not tested
Reproduction steps
Wasn't able to reproduce it myself but I'm still reporting this because it was mentioned in #111 that we should report it if it happens on Android 13. According to crashlytics this happens 100% in background. By the logs I see various scenarios how this happens but most common one is when player is auto transitioning to next item.
Some additional info that might help indicate the problem:
MediaController
when user goes to backgroundplayWhenReady
if user has turned off/on autoplay. (But doubt this is causing any issues since crashes happen not only when item is transitioning)onTaskRemoved
we are doingstopSelf
ifplayer.playWhenReady != true
onUpdateNotification
, but we are setting a customMediaNotification.Provider
I can provide any additional info or logs if needed
Expected result
Not getting
ForegroundServiceStartNotAllowedException
and successfully continuing playback in background.Actual result
Media
Bug Report
adb bugreport
to [email protected] after filing this issue.The text was updated successfully, but these errors were encountered: