Skip to content

fix: move bitmap decoding off main thread in onArtwork#57

Merged
chrisuthe merged 1 commit intomainfrom
fix/artwork-decode-off-main-thread
Mar 8, 2026
Merged

fix: move bitmap decoding off main thread in onArtwork#57
chrisuthe merged 1 commit intomainfrom
fix/artwork-decode-off-main-thread

Conversation

@chrisuthe
Copy link
Copy Markdown
Owner

Summary

  • Moves BitmapFactory.decodeByteArray and scaleArtwork from mainHandler.post to Dispatchers.IO via the existing serviceScope coroutine
  • State assignment (currentArtwork) and updateMediaSessionArtwork remain on the main thread since serviceScope uses Dispatchers.Main
  • Prevents UI jank when large artwork images are received over the wire

Test plan

  • Connect to a SendSpin server that sends binary artwork data
  • Verify artwork appears in the notification and lock screen controls
  • Verify no ANR or frame drops during artwork transitions
  • Verify artwork clears correctly when server sends empty payload

@chrisuthe chrisuthe merged commit e9c9642 into main Mar 8, 2026
The onArtwork() callback was decoding and scaling bitmap data on the
main thread via mainHandler.post, which can cause UI jank on large
images. Move the decode and scale operations to Dispatchers.IO using
the existing serviceScope coroutine, keeping only the state assignment
and MediaSession update on the main thread.
@chrisuthe chrisuthe deleted the fix/artwork-decode-off-main-thread branch March 8, 2026 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant