diff --git a/src/import/RomImporter.lua b/src/import/RomImporter.lua index 626bc4c8..96c9bc3c 100644 --- a/src/import/RomImporter.lua +++ b/src/import/RomImporter.lua @@ -8503,8 +8503,12 @@ function RomImporter:_queueFindEnrichment() if not visible then return end local thumbnails, stats = 0, 0 for _, entry in ipairs(visible) do + -- A row already resolved to "failed" (or with no thumbnail at all) must not + -- spend this frame's allowance: _startFindThumb ignores it, so counting it + -- let two dead rows above a card starve it of a download forever. if thumbnails < FIND_ENRICH_PER_FRAME and self:_findThumb(entry) == nil + and not (self._findThumbs and self._findThumbs[entry.id] ~= nil) and not self:_findThumbPending(entry.id) then self:_startFindThumb(entry) thumbnails = thumbnails + 1 diff --git a/tests/engine/launcher_navigation_perf.lua b/tests/engine/launcher_navigation_perf.lua index 5f31cc3f..fb5b3a12 100644 --- a/tests/engine/launcher_navigation_perf.lua +++ b/tests/engine/launcher_navigation_perf.lua @@ -65,6 +65,27 @@ do "update schedules a bounded thumbnail and stats batch for visible rows") end +-- Rows already resolved to "failed" (or with no thumbnail) must not spend the +-- per-frame download allowance, or two of them above a card starve it forever. +do + local started = {} + local imp = setmetatable({ tab = "find", findLoaded = true, + _findThumbs = { dead1 = false, dead2 = false }, + _findVisibleEntries = { + { id = "dead1", thumbnail = "https://example.invalid/1.png" }, + { id = "dead2", thumbnail = "https://example.invalid/2.png" }, + { id = "dead3" }, + { id = "alive", thumbnail = "https://example.invalid/alive.png" }, + } }, RomImporter) + imp._findThumbPending = function() return false end + imp._findStatsCached = function() return {} end + imp._startFindThumb = function(_, entry) started[#started + 1] = entry.id end + imp:_queueFindEnrichment() + eq(#started, 1, "only the row that can load starts a download") + eq(started[1], "alive", + "dead rows above a card do not starve it of its download") +end + do local requests = 0 local imp = setmetatable({}, RomImporter)