MediaSession artwork only uses the first item in the artwork array#30598
Conversation
|
EWS run on previous version of this PR (hash 51d7516) Details |
There was a problem hiding this comment.
| for (auto element : stringView.split(' ')) { | |
| for (auto element : StringView(sizes).split(' ')) { |
There was a problem hiding this comment.
Also do we handle the case of multiple spaces like 192x192 320x320?
There was a problem hiding this comment.
Also do we handle the case of multiple spaces like
192x192 320x320?
Hmm I didn't think of that. If spaces are correct then we take the biggest of the series
There was a problem hiding this comment.
| Vector<std::optional<uint32_t>> numbers; | |
| Vector<std::optional<uint32_t>, 2> numbers; |
There was a problem hiding this comment.
removed that code altogether
There was a problem hiding this comment.
We can probably use findIgnoringASCIICase("x"_s) to remove this string allocation.
There was a problem hiding this comment.
I prefer the old version of checking whether image is null upfront.
The current version is ok I think for that case, but somehow convoluted.
There was a problem hiding this comment.
I prefer the old version of checking whether image is null upfront. The current version is ok I think for that case, but somehow convoluted.
we don't want to exit early when it's null anymore, we want to try the other artwork
There was a problem hiding this comment.
Sure, wouldn't the following just work:
if (!image) {
tryNextArtworkImage(index + 1);
return;
}
m_artworkImageSrc = artworkImageSrc;
setArtworkImage(image);
metadataUpdated();
// Maybe we should also free m_artworkLoader, need to check how this loader is implemented.
There was a problem hiding this comment.
| if (!iterate || index + 1 < m_metadata.artwork.size()) | |
| if (!iterate || ++index < m_metadata.artwork.size()) |
There was a problem hiding this comment.
this would require to make the entire lambda mutable
There was a problem hiding this comment.
| IntSize newSize = { int(*numbers[0]), int(*numbers[1]) }; | |
| IntSize newSize { int(*numbers[0]), int(*numbers[1]) }; |
There was a problem hiding this comment.
Would it be simpler to have a Vector of image srcs, sorted by the image score.
Then, start with the first image src (the one with the best score) and only iterate if there is no image?
There was a problem hiding this comment.
If we can sort the src, then we only retrieve one image. There's no need to keep sorted vector anymore.
Otherwise we can't sort until we have downloaded all the images.
There was a problem hiding this comment.
yeah, it ended up being nicer that way. and it simplifies the logic as we don't need to distinguish the case where we do need to iterate for those we don't
51d7516 to
b068ce2
Compare
|
EWS run on previous version of this PR (hash b068ce2) Details |
There was a problem hiding this comment.
Theoretically, it would be possible for m_idealSize and m_minimumSize to be the same.
Given they are static, we should probably rename them as s_...
Or maybe make this method a free function and have const variables for ideal/minimum sizes.
There was a problem hiding this comment.
I added a static_assert
There was a problem hiding this comment.
| m_sortedSrc.clear(); | |
| m_sortedSrces.clear(); |
There was a problem hiding this comment.
Sure, wouldn't the following just work:
if (!image) {
tryNextArtworkImage(index + 1);
return;
}
m_artworkImageSrc = artworkImageSrc;
setArtworkImage(image);
metadataUpdated();
// Maybe we should also free m_artworkLoader, need to check how this loader is implemented.
There was a problem hiding this comment.
| float imageScore = size.isEmpty() ? -1.0 : imageDimensionsScore(size.width(), size.height()); | |
| float imageScore = imageDimensionsScore(size.width(), size.height()); |
There was a problem hiding this comment.
| tryNextArtworkImage(index + 1); | |
| tryNextArtworkImage(index); |
There was a problem hiding this comment.
I would tend to do the following:
| void MediaMetadata::tryNextArtworkImage(uint32_t index) | |
| void MediaMetadata::tryNextArtworkImage(Vector<Pair>&&, uint32_t index = 0) |
And have the lambda capture the Vector.
Also m_sortedSrcand m_artworkLoader are useless once we finished loading. If it was captured in the lambda, it would be freed automatically by freeing m_artworkLoader
There was a problem hiding this comment.
| static constexpr int m_minimumSize = 128; | |
| static constexpr int s_minimumSize = 128; |
There was a problem hiding this comment.
| static constexpr int m_idealSize = 512; | |
| static constexpr int s_idealSize = 512; |
There was a problem hiding this comment.
Would it be possible to directly create m_sortedSrc without creating this sizes vector?
Let's not forget to add some edge cases like |
youennf
left a comment
There was a problem hiding this comment.
LGTM.
Some further improvements added in comments.
b068ce2 to
515c507
Compare
|
EWS run on current version of this PR (hash 515c507) Details |
515c507 to
bbeb5ef
Compare
https://bugs.webkit.org/show_bug.cgi?id=276351 rdar://81160539 Reviewed by Youenn Fablet. If `sizes` metadata artwork attribute is provided we will use them to determine the "best" image to select. We do so by giving each resolution a score between 0 and 1. We aim to download an image that is 512x512 with an aspect ratio of 1. If the `sizes` attribute contains invalid content or if not provided, we will iterate through all the available images and download them. We will then either select the one with the highest score, or the first one found with a resolution greater than 512 pixels. Test will be added once https://bugs.webkit.org/show_bug.cgi?id=276133 lands as it adds some internal APIs to check which URL was selected with Now Playing. For now, manually tested. * Source/WebCore/Modules/mediasession/MediaMetadata.cpp: (WebCore::MediaMetadata::imageDimensionsScore const): (WebCore::MediaMetadata::refreshArtworkImage): (WebCore::MediaMetadata::tryNextArtworkImage): * Source/WebCore/Modules/mediasession/MediaMetadata.h: Canonical link: https://commits.webkit.org/280804@main
bbeb5ef to
cbbcae6
Compare
|
Committed 280804@main (cbbcae6): https://commits.webkit.org/280804@main Reviewed commits have been landed. Closing PR #30598 and removing active labels. |
🛠 🧪 jsc
cbbcae6
515c507
🧪 api-ios🛠 tv🛠 watch