Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions shell/plugins/image-picker/ImagePicker.qml
Original file line number Diff line number Diff line change
Expand Up @@ -603,13 +603,15 @@ Item {
Image {
id: image
anchors.fill: parent
// Even an uncached 6K wallpaper decodes at card size, off the
// GUI thread. Departing cards release their images instead of
// retaining every preview visited in a large collection.
// Decode at the expanded card's physical size, off the GUI
// thread. Keep that size during navigation to avoid reloads.
// Departing cards release their images instead of retaining
// every preview visited in a large collection.
// Queue the selected preview first; neighbors must not delay
// the image the user opened the picker to see.
source: (item.selected || root.neighborImagesEnabled) && item.thumbnailPath ? Util.fileUrl(item.thumbnailPath) : ""
sourceSize: Qt.size(root.expandedWidth, root.expandedHeight)
sourceSize.width: Math.ceil(root.expandedWidth * Screen.devicePixelRatio)
sourceSize.height: Math.ceil(root.expandedHeight * Screen.devicePixelRatio)
Comment on lines +613 to +614

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Neighbors decode at full size

At 200% scale, every visible preview decodes at 1536×950, even when a neighboring card is shown only as a narrow slice. On a 3840-pixel-wide display at that scale, the picker can hold about 19 decoded previews—roughly 111 MB of image buffers, four times the previous amount—and queues the larger decodes when neighbors become enabled. This is a non-blocking memory and decode-cost concern; consider limiting how many neighbors decode at full resolution while keeping the selected card sharp.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

fillMode: Image.PreserveAspectCrop
asynchronous: true
cache: false
Expand Down
16 changes: 15 additions & 1 deletion test/shell.d/image-picker-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,24 @@ assert(
)
assert(
/model: visibleImages/.test(imagePickerQml) &&
/sourceSize: Qt\.size\(root\.expandedWidth, root\.expandedHeight\)/.test(imagePickerQml) &&
/asynchronous: true\s*cache: false/.test(imagePickerQml),
'image picker renders its window with bounded asynchronous decoding'
)
const sourceWidth = imagePickerQml.match(/sourceSize\.width: ([^\n]+)/)[1]
const sourceHeight = imagePickerQml.match(/sourceSize\.height: ([^\n]+)/)[1]
const decodeSize = new Function('root', 'Screen', `return [${sourceWidth}, ${sourceHeight}]`)
for (const [scale, expected] of [
[1, [768, 475]],
[1.25, [960, 594]],
[1.5, [1152, 713]],
[2, [1536, 950]]
]) {
assertDeepEqual(
decodeSize({ expandedWidth: 768, expandedHeight: 475 }, { devicePixelRatio: scale }),
expected,
`image picker decodes enough physical pixels at ${scale}x display scale`
)
}
assert(
imagePickerQml.includes('(item.selected || root.neighborImagesEnabled)') &&
/onStatusChanged: if \(item.selected && \(status === Image.Ready \|\| status === Image.Error\)\) root.neighborImagesEnabled = true/.test(imagePickerQml),
Expand Down