audio_service mapped and encoded the whole play queue for the platform
on every queue change, on every platform. Only the Android plugin reads
it: the darwin plugin answers setQueue with an empty result, the web
plugin and the desktop SMTC and MPRIS sessions are no-ops. With a
20,000-song Shuffle Library queue that is about 10 MB and 60 ms (host
JIT) of UI isolate work per change, plus a main-thread decode on iOS
and macOS, all of it discarded.
_observeQueue now skips the queue off Android, and on Android keeps
only the newest queue while a setQueue is in flight. That queue goes
out when the in-flight call completes or fails, at the same point the
old loop sent its next buffered change, so Android always ends on the
latest queue and its order against setMediaItem and setState is kept.
An idle change is still sent at once, with the same payload.
Host benchmark, 20,000 songs per queue: iOS, macOS and Windows go from
one 10.1 MB send (about 61 ms) per change to none; six changes during
one Android send go from six sends (60.5 MB, 383 ms) to two (20.2 MB,
128 ms). The patch is recorded in MORNYE_PATCHES.md.
The exporter named a song's web cover copy in coverPath, where the
server ranks it as a real cover file. It now writes the copy to the
webCoverPath field the server tries last and keeps coverPath for local
cover files only.
A web cover copy in a catalog's coverPath outranked real pictures: an
album's cover is its first song with a cover file, and every id tries
cover files before embedded pictures, so an album mixing a song that
embeds its picture (or a later song with a cover file) with a web-only
song served the copy for every song.
Catalog lines now carry copies in their own webCoverPath field. The
server tries them only after the cover files and embedded pictures it
tried before, the song's own copy first and then its album's; an album
falls back to its first song with a copy only when no song has a cover
file or an embeddable format, and an artist to such an album only when
no other has a cover. Ids that had any cover serve exactly what they
served before, and a catalog without the field reads as before.
A failed read of an audio file is no longer remembered as a file
without a picture, for getCoverArt and linkEmbeddedPictures alike; only
a file that was read through counts.
Every default download keeps an https cover address and also embeds its
cover, so round 1 copied the web cover of every download and the
catalog's coverPath then outranked the picture in the file. The owner
approved web covers only for songs with no other cover.
The exporter now reports each song without a local cover file but with a
public https cover (path, path+mtime+size stamp, address) and names a
copy only for a song whose file is known to embed no picture. The store
asks linkEmbeddedPictures about new file versions in batches of 64 on
the Rust worker pool, keeps the answers in pictures.json, keeps the
copies a song may still want, fetches only for songs known to embed
none, and announces a held copy a newly asked file can take.
Also from the review: the host stops the store only after the server
stopped, so an export finishing meanwhile fetches nothing; web cover
fetches take https only, refuse localhost and loopback, link-local and
private literals, check every redirect by hand and end after a minute;
once the store is full it fetches and retries nothing until a prune
frees space; a failed write removes its staged file. Phone covers keep
their fetch unchanged.
The desktop should fetch a web cover only for a song whose file has no
picture of its own. linkEmbeddedPictures answers, for a list of paths,
whether each file embeds a picture getCoverArt would serve (null when it
is not a readable file). It reuses mornye_core's cover extraction and the
server's format table and remembered files without a picture, so a later
getCoverArt does not read them again. Works while the server is stopped.
A desktop download saved without embedded metadata has only an https
cover. The catalog left coverPath empty for it and the server answered
getCoverArt with 404, so the phone showed a placeholder while the
desktop showed the web cover.
LinkWebCovers keeps one copy per address in <app support>/link_web_covers
(<linkCoverUrlId(url)>.<ext>), fetched with the phone covers' fetch,
image check and staged write, now shared from link_web_covers.dart.
Each export lists the copies held and names them as coverPath; songs
with a local cover file and the desktop identity index are unchanged.
Once the server has loaded a catalog, the host removes the copies no
exported song wants and fetches the missing ones in the background,
4 at a time, with a byte cap and a timeout; failures wait 1 minute,
doubling up to 6 hours. New copies schedule an export, whose
catalog.changed makes phones rescan and fetch the cover.
A catalog only names files that exist, so Rust needs no change and an
album never prefers a copy that has not arrived. The listing an export
starts with waits for a queued removal, and removals run only after
setCatalog, so no file the server names is removed.
A Loved or playlist song of a network connection now stores its
network:// cover reference, and three paths handled it poorly:
- A song that resolves to a local file (a later download, or a Library
match) played with the reference as its artwork, which blocked the
embedded cover recovery and fetched over the connection while the
local file played. The reference now applies only to a network
source; a local file shows its own cover as before.
- Go to album passed the reference into album pages and recents, which
load covers over http only, so the page showed a failed cover instead
of the provider's. It now passes http covers only; a store path never
loaded there either.
- The writer compared the shown cover against the default store, while
the player chose it with its runtime's store. The player provider and
the media controls now pass the runtime's store. It is the same
object in production.
Collection songs go out without their network:// cover, so a change
the peer authors for such a row comes back without one. A desktop
playlist reorder restamps every member, and saving a Loved song again
rewrites it; applying either replaced the phone's row and dropped the
reference for good. Before F2 the phone's store path made the same
round trip and came back unchanged.
apply now reads, inside its transaction, the rows that winning Loved,
wishlist and playlist song changes without a cover replace, and keeps
a network:// cover they hold. A cover the peer sends still wins, and
the reference still never leaves the device. Every collection receive
path (the phone's pull, the desktop's POST, the full exchange after a
replaced database) applies through this method.
A network song without a Library record (a WebDAV, SMB or Subsonic
browser song, a Link desktop song) was saved to Loved or a playlist
with the file its player item showed, a cover store file. The store
trims those files, and on iOS their container path changes with an
app update, so the entry lost its cover.
collectionTrackForMedia now keeps the item's artworkRef while the item
shows that cover or none yet: the store fetches it again after a trim,
and collection rows already show a network:// cover through the store
(pendingCover). A cover read from the song's tags (#cover, which no
server answers) or any other artwork is kept as before.
CoverStore.refetches names the references a trim cannot lose.
playableFromTrack turned a network:// cover into a file URI of that
string; it now keeps the reference as the media's coverReference, so
the player shows the stored file and the item never carries network://
as its artUri. Track.fromJson already reads the reference unchanged,
and older rows read and play exactly as before.
A network:// cover names a connection of the device that saved it, so
it means nothing on the peer. Loved, wishlist and playlist entries now
go out without one; the author's own row keeps it. Other covers are
sent unchanged, so existing rows sync exactly as before.
A Loved or playlist entry of a network song will keep its cover as a
network:// reference, which only this device's cover store reads. Such
a track can reach the download queue (a tap on an entry without a
download, Download all), where the queue tiles load the cover over http,
the request payload hands it to the backend as a cover URL to fetch and
embed, and post-processing hooks receive it.
The queue now stores such a track without that cover, so the backend
falls back to the provider's cover. Other tracks are queued unchanged
(the same instance). The quality picker loads its cover with
Image.network, so it now gets only an http cover; a local path showed
the same placeholder there before.
An unexpected runtime error between the open and the image check left
the descriptor open, so a binder thread of the cover provider could leak
it. The descriptor is now closed in a finally block whenever no image
type was found.
The car's queue view loads each queue item's icon URI in its own process,
so a local song's app-private file:// cover showed nothing there, while
its browse entry already shows the cover through the cover provider.
audio_service gains AudioServicePlugin.setQueueArtResolver (recorded in
MORNYE_PATCHES.md). raw2queue applies it to each QueueItem description
only; the item's MediaMetadataCompat, the metadata cache, the playing
item, the notification and the lock screen keep the original artwork.
A null answer, a resolver that throws, or no resolver keeps the
description as it was.
The app's resolver maps a file:// or plain absolute path that names a
cover directly in the provider's folders, read from the path alone with
the same per-folder name rules, to the provider URI its browse entry
gets, so the car's cache sees one URI per cover.
The cover folders also hold files that are not covers: `.source`
sidecars with the user's audio file paths and `.current` pointers next
to the covers, the regenerate marker, and staging files. Only the image
signature check kept them out. Each folder now also names its covers by
their endings (cover store `.image`; Library thumbnails `.jpg`, `.png`
and `.image`; embedded artwork `.jpg`), so those files are refused by
name before anything is opened.
The provider checked one open of the file and served another. It now
opens the resolved file once with O_NOFOLLOW (and O_CLOEXEC from API
27), checks that descriptor with fstat for a regular file and pread for
an image signature, and serves a dup of that same descriptor; getType
reads its type the same way. The signatures are written as byte values,
so the source stays ASCII.
The browser kept the first cover provider lookup for the life of the
process. BrowserCoverProvider.load caught only platform errors, so any
other error stayed in the cached future and made every later children
and search call throw; a lookup that answered null left local covers out
until the process ended.
load now answers null on any error, and the browser keeps only a found
provider: a call without one shows no local covers and the next browse
looks again (concurrent calls still share one lookup). The root tabs no
longer wait for the lookup and the store warm-up, which they do not
need; they start it so the list opened next finds it ready.
_browserArt passed only web covers, as a car cannot open the app's own
files, so Library thumbnails, cover store files and embedded artwork
showed no cover in the car's lists.
Browse items now name a local cover inside one of the cover provider's
folders by its content:// URI, built from the path alone so the same
file always gets the same URI and the car's cache keys stay stable. A
network:// cover maps through CoverStore.indexedFile (index only, no
fetch or file IO), and a song shows the stored cover its playing item
would (CoverStore.songCover). Web covers pass as before; loopback URLs,
temporary files, covers outside the folders and every local cover on
platforms without the provider stay out. The playing item and
audio_service are unchanged.
Android Auto loads browse item artwork from the item's icon URI in its
own process, so it cannot open the app's private cover files and local
covers were left out of every browse list.
CoverContentProvider serves them as content://<applicationId>.covers/
<folder>/<file>. A car cannot hold a permission, so the provider is
exported, and in exchange it only reads: openFile accepts mode "r" only,
insert/update/delete throw, query lists nothing. CoverProviderFiles
resolves a URI to a file only when its path is an allowed folder name
and a plain file name, the canonical file sits directly in the
canonical folder (no "..", encoded "/" or symbolic link out), and it is
a regular file starting with a known image signature.
The allowed folders are the ones browse lists name: the cover store
(files/covers), Library thumbnails (files/library_covers) and embedded
artwork extracted from downloads (cache/embedded_cover_previews). The
covers channel hands Dart the authority and folder paths, registered on
the shared engine so a car-started engine has it too.
The daily check rewrote subsonic_<hash>.image in place when no .current
pointer existed, so decoded sizes and the home-screen widget key kept
showing the old image after the server changed it. A forced refresh went
the other way and moved even an unchanged image to a new path, which
dropped every decoded size and rewrote Library rows for nothing.
The fetched bytes are now compared with the published file: the same
image only updates the modification time and keeps its path, a changed
image always gets a new path behind the .current pointer.
ListeningTrack.fromRow already normalizes and sanitizes every stored
cover, so artist artwork and Rewind album covers use the track's
artwork as it is. ListeningSummary.fromRows has no app caller and is
marked for tests. The On repeat replay check tests PlayableMedia and
the cover store, so it moves to the cover store tests.
The history sync wire format imported cover_store.dart, with
path_provider and the network storage service, for one loopback check.
The check is now isLoopbackHost in cover_art_utils.dart, which both
durableCoverReference and linkSyncRemoteArtwork use. Same results.
Both slides read the row of one day, so a day recorded by an older
build (a loopback or temporary cover, now read as none) showed the
placeholder even when the window's summary had the song's cover from a
later play. That is most of a first yearly Rewind after the update.
They now fall back to the summary's cover of the same song.
Summaries take a song's details from its latest day in the window, so
one short play without a known cover, such as a skip before an
embedded cover was read, hid the cover recorded on earlier days on the
statistics screen, Home and Rewind. The cover now comes from the
latest day that recorded one when the latest day has none; both rows
are read by primary key.
History sync sends artwork as http(s) URLs, and statistics rows from
older builds hold loopback URLs of the author's cover proxy. A first
sync with a new peer copied those into the peer's statistics, where
they name the peer's own loopback server instead. Sent and received
artwork now drops loopback URLs, so peers store none.
The resume card read only the item's artUri, which stays empty for a
network song whose cover the store does not hold, such as the first
launch after an update from a build that kept loopback URLs. It now
falls back to the item's cover reference, as the queue rows do, so
the cover is fetched once and shows.
Android Auto lists kept every cover starting with http. Collection
tracks loved from the player by older builds can hold a loopback URL
of the app's cover proxy, which a car cannot load and which named a
route of an earlier run. The browser now leaves those out like local
files.
A song loved from the player without a Library record stored the
item's artUri as its collection cover, and an album or artist opened
from the player recorded its cover in recents. Older builds put
loopback URLs there; a tag cover the store could not keep still shows
from a temporary file on that play. Both writers now store only
covers that outlast the run, through durableCoverReference.
Listening statistics rows from older builds hold loopback URLs and
temporary files that no longer load, so the statistics screen, Home
and Rewind showed broken covers. Rows are read through one
ListeningTrack.fromRow, which reads those as no artwork, so the
fallback shows until the song plays again.
A play whose cover is not known yet no longer erases the stored cover
of that day, and a write never stores a loopback or temporary cover.
Artist artwork and Rewind album covers dropped network:// references
because normalizeCoverReference rejects them; they now read through
normalizeStoredCoverReference, which keeps them without changing what
other stores accept.
A tag read without a cover dropped the song's stored tag cover. For a
Subsonic song played from the Library that cover is the server's, and a
failed cover request also reads without one (and is remembered for five
minutes), so the playing song and the lock screen lost their cover on a
passing failure. A stored tag cover now stays until the store trims it:
a picture removed from a network file's tags lingers a while, which is
better than losing a cover the server still has. The store's forget
goes with it.
A metadata event whose song left the queue during the read threw, and an
older event's read could still store its cover after a newer one's. Both
now stop before touching the store.
The cover read with a Subsonic song's tags is the server's own cover,
the one the song's network reference names. Keeping it again as a tag
cover made that copy win once the phone had played a desktop song, so a
cover changed on the desktop never reached the phone: the refresh
checks the network reference, and songs with a known tag cover skip it.
Subsonic songs with a network reference now keep only that reference,
which also stores each Link cover once and lets statistics keep a
reference the store can fetch again.
A tag read that finds no cover now drops the song's stored tag cover, so
a picture removed from the tags gives way to the folder cover as it did
before covers were stored. A metadata event updates the queue once: the
tag cover goes into the replaced entries instead of a separate update.
The Home resume item drops a loopback or temporary cover of an earlier
version, as a restored session does.
A network song with both a folder image and a cover in its tags showed
the folder image on every play once it was stored, unlike the Library.
The cover from the tags now wins once read: it is stored under the
song's cover reference, which a later play finds in the store's index,
so the item shows it from the first emission without flashing the
folder image. The folder image shows only while no tag cover is known,
and a late or changed folder cover no longer replaces a tag cover. The
session keeps neither file; statistics keep the reference of the cover
shown.
Covers a server reported changed are no longer fetched at once. A
desktop library job reported every song it touched, and each fetched
its cover, queued or not and stored or not. The store now marks the
cover stale and checks it on its next use, so only the playing song and
the next three fetch. The same mark drops the wait after a failed fetch,
so a Link reconnect retries the covers that failed while the desktop was
away instead of waiting out the store's minute.
A network:// artwork, as listening statistics keep for Home to play,
is the song's cover reference: the item shows its stored file and never
the network:// string, which the lock screen cannot load. Restored
sessions drop loopback and temporary covers of older versions, and the
temporary preview rule matches the preview folder, not a file name. A
tag cover the store could not keep shows on that play only.
The resolver and the remote's metadata subscriber each built the cover
reference of a desktop song. The cover store keys covers by that exact
string, so one helper builds it for both and the forms cannot drift.
An AutoMix transition showed a stored cover, but a cover not stored yet
was only fetched if an earlier load had fetched it ahead, so after a few
mixed songs in a row a network song could stay without one. The
transition now fetches the new song's cover and the next three, as a
gapless start does.
Cover widgets, precaching and palettes saw a network:// cover as a form
without an image. coverFilePath now answers it with the file the cover
store's index names, without file IO, so they show a stored cover as a
local file. A cover widget given a network cover the store does not
hold yet fetches it once through the store, within its fetch limit, and
builds again when it lands. Queue rows whose cover is not stored yet
show it that way.
Playing a folder resolved its cover image to a loopback URL before
playback began and passed it as the songs' artwork, a URL that named the
cover for this run only, even for Subsonic songs whose own cover
differs. The songs already carry the cover as networkArtworkSource,
which the player now shows from the cover store, so the screen passes
only that and starts playback without the extra request.
The desktop and phone remotes resolved each queued song's network cover
through the loopback proxy, a new URL per lookup, for every row of a
queue up to 500 songs long. The items now show the cover store's file,
the same on every update, and carry the reference as
extras['artworkRef'].
Only the playing song and the next three fetch their covers; other rows
fetch theirs once they show. A failed cover is tried again after a
reconnect, as before. When the desktop changes a song's file, its cover
is fetched again at once, and a cover the store replaced shows on the
items with it.
Each play resolved a song's network cover through the loopback proxy,
which hands out a new URL per call. The first item had no cover, every
play showed a different URL, the lock screen and Link Now Playing saw
the cover change, and listening statistics recorded a URL that was dead
after the run.
Items now show the file the cover store holds for the cover from their
first emission, the same file on every play, and carry the reference as
extras['artworkRef']. A cover not stored yet is fetched without holding
up the audio and shows on the song and its queue entries once it lands,
the covers of the next three songs are fetched ahead for skips and
gapless starts, and a cover the store replaced shows at once. A restored
session and the Home resume item read the store's index first.
The tag cover a network metadata read leaves in a temporary file is
copied into the store before the session keeps it. Statistics record
the cover reference, or the artwork only when it lasts. The store's
index is read at startup and trimmed once a launch.
Playback needs a stored network cover while it builds a MediaItem, so
indexedFile answers from the in-memory index without file IO. adopt
copies a cover that reached the device another way, such as the tag
cover a network metadata read leaves in a temporary file, into the store
under a reference derived from the song (songCoverReference), named by
its bytes like a fetched cover. refresh fetches a cover again at once
when its server reports a change, instead of waiting a day for the
recheck.
durableCoverReference keeps only cover strings that outlast the run:
loopback URLs and files in the system temporary directory or the known
temporary cover folders are dropped, so statistics never record them.
The document scan slot test only compared the stem with the function that
computes it. A new test writes a thumbnail through the Rust scan's
cache_cover and expects library_cover_slot to find that file for the same
key, then checks that the newer of two current siblings wins.
The forced-scan test compared marker mtimes 20 ms apart, which can flake
on filesystems that store whole seconds; it now checks that each forced
scan rewrites the marker's contents. The padded ID3 cover test reuses the
shared backend and ID3 helpers.
Clearing library covers marked rows whose cover_path started with Dart's
spelling of the folder. Scans store their own spelling: the canonical
/data/data path on Android 7 to 10, where /data/user/0 is a symlink, and
canonical backslash paths (possibly \\?\) on Windows. There no row was
marked, so local covers stayed broken until a forced rescan.
Rows are now matched by a library_covers path segment with either
separator; every file in that folder was just deleted, so each such row
is broken. The update also retries a busy writer before it begins, so a
running native scan no longer leaves the rows unmarked after the files
are gone.
A source without a modification time always published its preview to
v2_<path hash>_0.jpg. After an in-app cover edit (invalidate, then extract
again) the new cover landed on the same path, so ImageCache kept showing
the old decoded cover in the metadata screen, Library and player.
Untimed previews are now named v2_<path hash>_0_<content hash>.jpg from a
SHA-256 of the extracted bytes: an unchanged cover keeps its path across
memory misses, an edited one gets a new path, and the existing variant
cleanup removes the previous file. Publishing also no longer deletes the
target before the rename, which already replaces it atomically, so a
reader never finds the preview missing.
Clearing library covers in Settings deleted every file while Library rows
kept naming them. Network songs recover, since their scan reads a song
again when its cover file is gone, but local and document songs are
skipped by an unchanged timestamp, so their covers stayed broken until a
full rescan despite "Will re-extract on next scan".
The clear now also lowers the audio metadata scan version of local rows
whose cover was in that folder to the lyrics version. The incremental
snapshot then reports those files as changed once, so any next scan
extracts the covers again under the same names, which also brings back
the covers that playlists and sessions name. Lyrics filters are unchanged
meanwhile.
When a source had no modification time (some document providers), its
embedded cover preview went to a new systemTemp/download_cover_preview_*
folder and was deleted as soon as the 180-entry memory cache evicted it,
even while the player or the saved session still pointed at it.
Such previews now go to the existing embedded_cover_previews folder under
one durable name (v2_<path hash>_0.jpg). They are still extracted again on
each memory miss, since a disk copy cannot be validated without a
timestamp, but evicting the memory entry never deletes a file: only the
disk budget, a refresh that replaces the preview, invalidate and the
manual clear do.
The cover prune after a full scan treated a library_covers file as in use
only when library.cover_path named it. Playlists, favorites, the saved and
dismissed playback sessions, recent items, the download queue, listening
statistics and download history (including Link save offline copies) copy
those paths, so their covers broke after the next full scan.
The prune now also reads every such text column (read-only, in pages,
filtered with instr) and keeps the files they name, rebased onto today's
cover directory so file:// URIs and paths from an older iOS container
match. The names join the private native projection, so Rust still never
reads a live database and a failed read cancels the sweep.
A Subsonic cover kept by a reference also keeps its
subsonic_<hash>.image.current pointer, in Rust and in the Dart fallback;
before, the pointer was always deleted and the next scan fetched and
renamed the cover again.
A forced rescan wrote every thumbnail into a new library_covers/full_scan_*
folder, so all stored cover paths changed at once. It did that to bypass
reuse of possibly wrong cached thumbnails and stale decoded images.
With collision-free names, a forced rescan now writes the .regenerate
marker into library_covers itself: native scans extract every thumbnail
again under its existing name, and the decoded image cache is cleared once
the rescan is indexed. Playlists, sessions and statistics that copied a
cover path keep a valid file.
Scan thumbnails were named by a 32-bit djb2 hash of "path|size|mtime" (or
the document key) and an existing file was reused without checking its
source, so two songs whose keys collided showed one cover. The Android
document scan had its own copy of the same hash.
Thumbnails are now named cover_<first 128 bits of SHA-256 of the key>, in
Rust for every scan and through library_cover_slot for the Kotlin document
scan, so reuse by name is safe. Rows that name older files keep working;
those files are not looked up again and are pruned once unreferenced.
A forced rescan can touch a .regenerate marker in the cover folder:
thumbnails older than it are extracted again under the same name instead
of being reused, and the newer of a .jpg and .png sibling wins.
An unsatisfiable Range on SMB sets content-length 0 only for GET again,
so a HEAD answers as it did before the cover read moved to the shared
opener. A new test rejects 24 covers (404, audio, HTML) over one host's
six pooled connections, which times out if downloadCover stops
discarding a rejected response.
Background rechecks of stale covers and first-time fetches shared one
FIFO queue, so a scrolled grid could queue many rechecks ahead of the
playing song's cover. Waiting fetches a caller awaits now take the next
free turn before any queued recheck, and the turn is taken before the
store folder is created so queue order follows call order.
A recheck that finds changed bytes leaves the old file dated ahead of
the clock; warmUp and trim now rank a file dated more than a day ahead
as the oldest, so a restart picks the new file and a trim drops the
stuck one first. The constructor asserts a positive fetch cap, and the
cap test waits with a bounded poll instead of one event queue pump.
Playback and display will ask the store for whole queues and grids.
- At most four covers are fetched at once (maxFetches); the rest wait
their turn in order, so a burst does not queue past the HTTP pool
and time out into a retry backoff.
- A cover the server does not have (NetworkMediaUnavailable) or whose
bytes are not an image waits an hour before the next fetch instead of
a minute, so a desktop's songs without art are not asked for every
minute while they are shown. Transfer failures keep the one-minute
delay.
- A stored cover dated more than a day ahead of the clock is checked
again, as one more than a day old is.
- trim checks again that no fetch has taken up a name after reading its
details, before deleting it.