media: MediaSessionService never destroyed

Media3 Version

Media3 1.0.1

Devices that reproduce the issue

Android emulator API 33

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Not tested

Reproduction steps

I first mentioned this issue in #346.

  1. Connect MediaController in one process to MediaSession (via MediaSessionService) in another process.
  2. Perform some amount of player interaction, like starting and pausing playback.
  3. Release MediaController on client.
  4. Observe MediaController being disconnected on server side.
  5. For good measure, manually release MediaSession and Player from MediaSession.Callback.onDisconnected()
  6. Wait for a long time (30+ minutes)
  7. Observe that MediaSessionService.onDestroy() still has not been called

Notably this issue does not occur when there is no player interaction, i.e. Player and MediaSession created but not really used, e.g. no call to prepare().

Expected result

MediaSessionService.onDestroy() called shortly after MediaController released.

Actual result

MediaSessionService.onDestroy() never called.

Media

N/A

Bug Report

  • You will email the zip file produced by adb bugreport to dev.exoplayer@gmail.com after filing this issue.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 1
  • Comments: 16 (5 by maintainers)

Commits related to this issue

Most upvoted comments

I have just run into this issue myself. I am glad to read here confirmation that stopSelf() needs to be called explicitly. I don’t have a problem with it working this way, but can I request that the documentation be updated?

What MediaSessionService documentation says:

The service will be destroyed when all sessions are released, or no controller is binding to the service while the service is in the background.

The “released” link points at MediaController.release(). There is some more relevant info in the preceding paragraph.