[PR #1774] [MERGED] Significantly improve Android UI performance when resuming from background #1692

Closed
opened 2026-04-25 00:00:39 +02:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/advplyr/audiobookshelf-app/pull/1774
Author: @FreedomBen
Created: 1/7/2026
Status: Merged
Merged: 2/8/2026
Merged by: @advplyr

Base: masterHead: dont-queue-background-display-events


📝 Commits (2)

  • 5250adb Don't queue display events while backgrounded
  • 140bc7f Skip progress updates when backgrounded

📊 Changes

2 files changed (+44 additions, -0 deletions)

View changed files

📝 android/app/src/main/java/com/audiobookshelf/app/managers/SleepTimerManager.kt (+14 -0)
📝 android/app/src/main/java/com/audiobookshelf/app/plugins/AbsAudioPlayer.kt (+30 -0)

📄 Description

Brief summary

Significantly improve UI performance when resuming from background

When the app is backgrounded, diplay events were queued and could build up over time, leading to a sluggish resume when the app was foregrounded as the queue was processed. As these updates are all stale by the time the app is foregrounded, we should ignore them to prevent a long resume process.

Which issue is fixed?

Fixes #1773

Pull Request Type

Android only

In-depth Description

  • Track if we are foregrounded or not so we know when to ignore display events
  • Don't queue metadata updates when backgrounded since there is no display to update and these end up queued
  • On resume (when being foregrounded) send current state to UI so it stays in sync
  • Short-circuit player progress updates when backgrounded
  • On resume (foregrounding) add short imperceptible delay before sending progress updates to allow web view time to initialize so we don't send the event too soon (fixes race condition)

This does not affect the notification tray indicator.

How have you tested this?

Yes, tested on Pixel 8 Pro over the course of a few days (~ 12 listening sessions spread across multiple hours, including overnight)

Screenshots

No UI changes


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/advplyr/audiobookshelf-app/pull/1774 **Author:** [@FreedomBen](https://github.com/FreedomBen) **Created:** 1/7/2026 **Status:** ✅ Merged **Merged:** 2/8/2026 **Merged by:** [@advplyr](https://github.com/advplyr) **Base:** `master` ← **Head:** `dont-queue-background-display-events` --- ### 📝 Commits (2) - [`5250adb`](https://github.com/advplyr/audiobookshelf-app/commit/5250adb36e8961ab54a123108e574050abad7a14) Don't queue display events while backgrounded - [`140bc7f`](https://github.com/advplyr/audiobookshelf-app/commit/140bc7fbc5c29f4c725f4e193c713c1d26c8c1a8) Skip progress updates when backgrounded ### 📊 Changes **2 files changed** (+44 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `android/app/src/main/java/com/audiobookshelf/app/managers/SleepTimerManager.kt` (+14 -0) 📝 `android/app/src/main/java/com/audiobookshelf/app/plugins/AbsAudioPlayer.kt` (+30 -0) </details> ### 📄 Description ## Brief summary Significantly improve UI performance when resuming from background When the app is backgrounded, diplay events were queued and could build up over time, leading to a sluggish resume when the app was foregrounded as the queue was processed. As these updates are all stale by the time the app is foregrounded, we should ignore them to prevent a long resume process. ## Which issue is fixed? Fixes #1773 ## Pull Request Type Android only ## In-depth Description - Track if we are foregrounded or not so we know when to ignore display events - Don't queue metadata updates when backgrounded since there is no display to update and these end up queued - On resume (when being foregrounded) send current state to UI so it stays in sync - Short-circuit player progress updates when backgrounded - On resume (foregrounding) add short imperceptible delay before sending progress updates to allow web view time to initialize so we don't send the event too soon (fixes race condition) This does not affect the notification tray indicator. ## How have you tested this? Yes, tested on Pixel 8 Pro over the course of a few days (~ 12 listening sessions spread across multiple hours, including overnight) ## Screenshots No UI changes --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-04-25 00:00:39 +02:00
adam closed this issue 2026-04-25 00:00:39 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf-app#1692