fix: ImagesData.firstOrNull throws RangeError on empty backDrop list#979
Closed
Beary-Handsome wants to merge 2 commits intoDonutWare:developfrom
Closed
fix: ImagesData.firstOrNull throws RangeError on empty backDrop list#979Beary-Handsome wants to merge 2 commits intoDonutWare:developfrom
Beary-Handsome wants to merge 2 commits intoDonutWare:developfrom
Conversation
When primary is null and backDrop is an empty list (e.g. an Episode whose Jellyfin item has no backdrop images at all), `backDrop?[0]` indexes an empty list and throws RangeError. The whole semantic of a 'firstOrNull' getter is to return null when the collection is empty. Replaced with package:collection's firstOrNull extension (already imported in this file), which has the correct empty-list behavior. Symptom this fixes: on platforms where MediaControlsWrapper.play synchronously evaluates `playBackItem.images?.firstOrNull` (any non-Web desktop / mobile build), the unhandled RangeError escapes through the playback init future chain and aborts video pipeline init while audio (already buffered) keeps playing. Reported under DonutWare#57, DonutWare#159, DonutWare#215, DonutWare#429 and likely related.
PR/development builds were producing debug APKs, which on Android run without AOT compilation and ship with the DEBUG ribbon. Switch dev builds to --release and let the gradle config fall back to the debug keystore when key.properties is absent, so release-mode APKs build without requiring prod signing secrets on forks. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Collaborator
|
Already fixed in #969. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Replace
backDrop?[0]withbackDrop?.firstOrNull(frompackage:collection, already imported in this file).ImageData? get firstOrNull { - return primary ?? backDrop?[0]; + return primary ?? backDrop?.firstOrNull; }Why
When
primaryis null ANDbackDropis an empty list (rather than null) — which happens for any Jellyfin item whosebackdropImageTagsis[]—backDrop?[0]indexes an empty list and throws:The getter is named
firstOrNullbut the implementation didn't actually handle the empty-list case.package:collection'sfirstOrNullextension has the correct semantics.Symptom this fixes
In
MediaControlsWrapper.play,playBackItem.images?.firstOrNullis evaluated synchronously. The unhandled RangeError escapes through theawait state.play()chain inVideoPlayerNotifier.loadPlaybackItemand aborts video pipeline init. Audio that was already buffered keeps playing, but the video stream never starts decoding — externally this looks like "audio works but video keeps loading forever."Reproducible on any non-Windows/non-Web build (i.e. Linux desktop, Android, iOS, macOS) playing an item where Jellyfin returns no backdrop images. The most reliable triggers are
.strm-backed Episode items (e.g. content fed through a Usenet/Easynews bridge) — these typically have minimal Jellyfin metadata and no backdrop array — but any Episode/Movie withbackdropImageTags: []and no primary image is affected.Likely related: #57, #159, #215, #429 — all reported the symptom (playback hang on streamed/
.strmcontent) but never landed on the root cause.How to reproduce
backdropImageTags: []and a missing/null primary image. (Or run any Easynews-style.strmbridge.)Unhandled Exception: RangeError (length)in stderr.After this patch: the getter correctly returns null on empty, the synchronous evaluation no longer throws, and playback proceeds normally.
Test plan
package:collectionimport is already present in the file (it is, used byrandomBackDropon the next line)