From 7ad0ce618a61dab4c82f845bc4fdb35a411a89d2 Mon Sep 17 00:00:00 2001 From: Hans-Peter Lehmann Date: Mon, 29 Jun 2026 22:46:50 +0200 Subject: [PATCH] Run widget updates from a background thread (#8553) ### Description Run widget updates from a background thread Closes #8546 ### Checklist - [x] I have read the contribution guidelines: https://github.com/AntennaPod/AntennaPod/blob/develop/CONTRIBUTING.md#submit-a-pull-request - [x] I have performed a self-review of my code, going through my changes line by line and carefully considering why this line change is necessary - [x] I have run the automated code checks using `./gradlew checkstyle lint` - [x] My code follows the style guidelines of the AntennaPod project: https://antennapod.org/contribute/develop/app/code-style - [x] I have mentioned the corresponding issue and the relevant keyword (e.g., "Closes: #xy") in the description (see https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) - [x] If it is a core feature, I have added automated tests --- .../antennapod/playback/service/Media3PlaybackService.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/playback/service/src/main/java/de/danoeh/antennapod/playback/service/Media3PlaybackService.java b/playback/service/src/main/java/de/danoeh/antennapod/playback/service/Media3PlaybackService.java index 4529c7895..449ccc197 100644 --- a/playback/service/src/main/java/de/danoeh/antennapod/playback/service/Media3PlaybackService.java +++ b/playback/service/src/main/java/de/danoeh/antennapod/playback/service/Media3PlaybackService.java @@ -290,7 +290,8 @@ public class Media3PlaybackService extends MediaLibraryService { PlaybackService.isRunning ? PlayerStatus.PLAYING : PlayerStatus.PAUSED, (int) player.getContentPosition(), (int) player.getDuration(), player.getPlaybackParameters().speed); - WidgetUpdater.updateWidget(Media3PlaybackService.this, widgetState); + Schedulers.io().scheduleDirect(() -> + WidgetUpdater.updateWidget(Media3PlaybackService.this, widgetState)); updatePlaybackPreferences(); // Auto-enable sleep timer when playback starts @@ -385,7 +386,8 @@ public class Media3PlaybackService extends MediaLibraryService { WidgetUpdater.WidgetState widgetState = new WidgetUpdater.WidgetState(currentPlayable, Util.shouldShowPlayButton(player) ? PlayerStatus.PAUSED : PlayerStatus.PLAYING, (int) position, (int) duration, speed); - WidgetUpdater.updateWidget(this, widgetState); + Schedulers.io().scheduleDirect(() -> + WidgetUpdater.updateWidget(this, widgetState)); long currentTime = System.currentTimeMillis(); if (currentTime - lastPositionSaveTime >= POSITION_SAVE_INTERVAL_MS) { saveCurrentPosition();