-
-
Notifications
You must be signed in to change notification settings - Fork 529
Open
Description
Bug report
Describe the bug
When creating a MediaItem with artUri: null, the app crashes with a NullPointerException in AudioService.loadArtBitmap(). The crash occurs because LruCache.put() does not accept null values.
Steps to reproduce
- Create a
MediaItemwithartUriset tonull:
MediaItem(
id: 'some-id',
title: 'Title',
artist: 'Artist',
artUri: null, // <-- This causes the crash
);- Play the media item
- App crashes
Stack trace
java.lang.NullPointerException: key == null || value == null
at android.util.LruCache.put(LruCache.java:169)
at com.ryanheise.audioservice.AudioService.loadArtBitmap(AudioService.java:242)
at com.ryanheise.audioservice.AudioService.setMetadata(AudioService.java:790)
at com.ryanheise.audioservice.AudioServicePlugin$AudioHandlerInterface.lambda$onMethodCall$2$com-ryanheise-audioservice-AudioServicePlugin$AudioHandlerInterface(AudioServicePlugin.java:842)
at com.ryanheise.audioservice.AudioServicePlugin$AudioHandlerInterface$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
at java.lang.Thread.run(Thread.java:1012)
Expected behavior
The library should gracefully handle null artUri without crashing. Media items without artwork are a valid use case.
Suggested fix
In AudioService.java, add a null check before caching the bitmap:
Bitmap bitmap = loadArtBitmap(artUri);
if (bitmap != null && artUri != null) {
artBitmapCache.put(artUri, bitmap);
}Environment
- audio_service version: latest
- Platform: Android
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels