maxrave-dev / maxrave-dev/SimpMusic

Playing a video and then minimizing the app causes a crash

Open
#2,016 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
11.4k
Forks
599
Avg merge
3d 18h
Merged PRs (30d)
7

Description

Duplicate Check
  • I confirm I searched for existing reports and found no duplicates.
Describe the Bug

Fixed with new version

Working now thank you but having a new problem
Playing a video and then minimizing the app causes a crash

I hv analysed this and it's , specifically related to the Media3 ExoPlayer library.
The key issue is:
IllegalStateException: Session ID must be unique. ID=com.mxavie.media3.service.SimpleMediaService.

Steps to Reproduce
  1. Key Error:
    java.lang.IllegalStateException: Session ID must be unique. ID=com.mxavie.media3.service.SimpleMediaService
  2. Fix for the Code:
    In SimpleMediaService.java (or SimpleMediaService.kt), ensure the Session ID is dynamic. Example:
    kotlin
    val sessionId = "media_session_${System.currentTimeMillis()}" // Unique ID
    val mediaSession = MediaSession.Builder(context, player)
    .setSessionId(sessionId)
    .build()
  3. Release the Media Session Properly:
    Add this to onDestroy():
    kotlin
    override fun onDestroy() {
    mediaSession?.player?.release()
    mediaSession?.release()
    mediaSession = null
    super.onDestroy()
    }
  4. Update the AndroidManifest.xml:
    Ensure the service is declared like this:
    xml
  5. Test for Edge Cases:

    Rapid app restarts (open/close the app multiple times quickly).

    Background/foreground transitions (minimize the app while media is playing).

Hope this is helpful. 👆

Expected Behavior

The app should handle media playback without crashes, duplicate sessions, or resource leaks, ensuring a smooth and stable experience.

The SimpleMediaService should initialize and run smoothly without throwing IllegalStateException.

The app should never create multiple instances of SimpleMediaService simultaneously.

Lastly The app should recover gracefully from interruptions example incoming calls, app switches.

App Version

1.2.1

Android Version

Android 13

Device Model

Samsung a12

Custom ROM
  • I am using a custom ROM
Custom ROM Name (if applicable)

No response

Screenshots (optional)
Image
Log / Error Details

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with SimpleMediaService.java or SimpleMediaService.kt and the corresponding AndroidManifest.xml service declaration. Reproduce playback followed by minimizing on Android 13, then inspect MediaSession lifecycle and session-ID handling; done means the transition no longer crashes and rapid restarts and interruptions remain stable.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.