maxrave-dev / maxrave-dev/SimpMusic

App restarts by itself during background audio playback — IllegalStateException: Underflow in restore (Android 16)

Open
#1,873 1 comment 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

Bug Report: App restarts by itself during background music playback — IllegalStateException: Underflow in restore


Environment

  • App version: SimpMusic 1.1.1
  • Device: HONOR ELP-NX9
  • Android: 16 (SDK 36)
  • Repro frequency: consistent during background playback

Description

While listening to music in the background (screen off / app not in foreground, no video or visualizer involved), the app crashes and restarts by itself with no user interaction.

The crash exception is:

java.lang.IllegalStateException: Underflow in restore — more restores than saves

This happens during view rendering when Android resumes the app's UI (e.g. after the system redraws the activity or the notification/player UI). The stack trace points to an unbalanced Canvas.save() / Canvas.restore() call in a custom view's draw cycle.


Steps to Reproduce

  1. Install SimpMusic 1.1.1 on HONOR ELP-NX9 (Android 16 / SDK 36)
  2. Start playing any song
  3. Leave the app in the background (press Home or lock screen)
  4. Wait — app crashes and restarts by itself, interrupting playback

Expected Behavior

App continues playing music in the background without crashing or restarting.

Actual Behavior

App crashes and auto-restarts during background playback. No user interaction needed to trigger it.


Timeline of user actions before crash

2026-03-20 16:26:31 — MainActivity created
2026-03-20 16:26:31 — MainActivity resumed
2026-03-20 16:27:17 — MainActivity paused  ← app sent to background
2026-03-20 16:28:02 — MainActivity resumed  ← system brought it back (crash incoming)
2026-03-20 16:28:59 — CRASH

Note: the crash happens ~57 seconds after the system resumed MainActivity — likely triggered when Android redraws the UI after returning from background.


Stack Trace

java.lang.IllegalStateException: Underflow in restore - more restores than saves
	at android.graphics.Canvas.restore(Canvas.java:673)
	at i2.c.p(r8-map-id-3c5db09a77b14f996c26362322e1ef2be37fb38d6e9c13eab77a818cf1c6ea07:3)
	at b3.l0.d(r8-map-id-...:815)
	at l2.c.d(r8-map-id-...:47)
	at b3.a.d(r8-map-id-...:134)
	at l2.g.x(r8-map-id-...:35)
	at l2.c.f(r8-map-id-...:55)
	at b3.m0.Y(r8-map-id-...:16)
	at y.m1.g(r8-map-id-...:230)
	at b3.m0.c(r8-map-id-...:52)
	at b3.j1.X0(r8-map-id-...:50)
	at b3.i1.b(r8-map-id-...:27)
	at z1.q.d(r8-map-id-...:310)
	at b3.h1.invoke(r8-map-id-...:315)
	at b3.a.d(r8-map-id-...:780)
	at c3.y.dispatchDraw(r8-map-id-...:74)
	at android.view.View.draw(View.java:26590)
	at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:757)
	at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:873)
	at android.view.ViewRootImpl.draw(ViewRootImpl.java:7994)
	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:6356)
	at android.app.ActivityThread.main(ActivityThread.java:10759)

Additional Notes

  • No video or visualizer is active — pure audio playback only.
  • The crash is triggered by the UI redraw when the system resumes MainActivity from background, not by any user action.
  • This is a bug in the app's drawing code, not a device issue. The Canvas.restore() is being called more times than Canvas.save() during the view redraw after resume.
  • Possibly related to the player UI / Now Playing card or any custom view that redraws on onResume().

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

No source file or test is named. Start by reproducing background audio playback on Android 16 and trace the MainActivity resume/redraw path from the provided stack trace, focusing on the player UI or custom view. Done means background playback no longer crashes with an unbalanced Canvas restore.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.