Repository navigation
Stop an idle window from drawing every refresh - #100
Conversation
Qt's cache buffer makes them later, from a 16 ms timer of its own, and a race in Qt can leave that timer running: an idle window then draws a frame every refresh. The list and the columns make the same rows at once with display margins; the grid keeps its own row past each edge.
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryThe PR disables cache buffers in folder views to avoid repeated drawing while idle. Since the previous review:
No new actionable issues were found. Reviews (3) · Last reviewed commit: "Keep the lists' settings in one view of ..." · Reviewed by Greptile |
|
Reviewed at e8fab78, merged onto current What was run, on a throwaway Omarchy VM under Hyprland (Qt 6.12.0, threaded render loop, 75 Hz):
Second opinion: Codex at medium effort and muse-wonder (via pi, high thinking) both read the diff against Qt's source. Both confirmed the mechanism and found no defect. These five views are the only
Overlaps: none of the other open pull requests fixes this. #121 moves the ancestor column's Waiting on: the maintainer. CI ("Build and test") has not run on this fork's branch and needs a maintainer to approve it. Keeping or dropping the display margins is also the maintainer's call. |
The cache buffer was the cause. The display margins kept making rows, and starting their thumbnails, ahead of a scroll the way the cache used to, at the cost of drawing those rows. The maintainer asked for the fix as small as it can be, so the views keep just cacheBuffer: 0, with the reason stated once. Without the margins a wheel or fast scroll can show a row's glyph for a frame or two before its thumbnail arrives; the rows themselves are always there. The test checks every folder view's cache buffer. An idle window draws no frames offscreen, so the redraw itself cannot be seen in the suite; on a compositor, Folio's panes forced through Qt's race drew a frame every refresh on main and none with this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Codex Medium <noreply@openai.com>
|
The maintainer asked for the display margins to go, and for the rest of this pull request to be as simple as it can be. That change is pushed as 6d07db6, on top of your commit. What changed and why
What scrolling looks like without the margins This ran on a throwaway Omarchy VM under Hyprland, on a folder of 1,800 photos and 200 videos with thumbnails made fresh. For each scroll, every frame counted the rows on screen whose thumbnail had not arrived yet. Three runs each of
So dropping the margins is slightly worse: at wheel and drag speeds a few rows can show their glyph for a frame or two before the thumbnail appears. Checked again at 6d07db6
Second opinion: Codex at medium effort and muse-wonder (via pi, high thinking) reviewed the simplified head and the scroll numbers. They found no defect and agreed that the margins cost only thumbnail preloading, never rows, selection, drag, the rubber band or context menus. Their agreement is not guaranteed to be independent. muse-wonder noticed the test did not need to select anything, because the columns create all three lists up front, so that step is gone. Codex pointed out that the commit message undersold what the margins did, and it now says they also started thumbnails early. Waiting on:
|
The list and the three lists of the columns each repeated the same setup: clipping, no dragging, Folio's scroll bar, and now no cache buffer. FileListView holds it once, with the reason for the buffer, so the next setting every list needs goes in one place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One fix, in one commit with its own test: now and then a Folio window that is doing nothing keeps drawing a frame at every refresh of the screen, with its render thread on about half a core, until it is closed. A race in Qt sets it off, and the cache buffer of Folio's views is what walks into it. The views now make their rows without that buffer. The suite goes from 194 to 197 tests. No library,
dependsoroptdependsentry is added.What you'd notice
Numbers
How often it happens depends on timing, so the counts are small and uneven. Measured on a mini PC, cold starts on a folder of 2,000 videos and pictures:
main, this weekIn each of the four caught on 0.1.1 a probe counted 479 or 480 frames in every 4 seconds on a still, complete window (a 120 Hz screen), for the two minutes it was watched. The one this week used 42.6 s of CPU in the measured window, against about 11 s for its neighbours.
The same folder, thumbnails made anew at each start, page cache dropped, 6 runs a view,
mainand this branch in one session (the build measured has this commit's view settings; review since then named the 320 and tightened the test):mainmainmainmainOn a folder of 100,000 files the two are level in every view: first window 894 to 971 ms against 904 to 959 ms in the grid, memory 235.6 to 236.0 MiB against 229.5 to 240.3 MiB, and the same for the list and the columns.
Holding Down through 300 files in the grid, measured on 0.1.1 with the same change: the time from the key to its frame was 10.3 ms at the median either way, and 13.9 ms at most against 14.9 ms. No frame took longer than one refresh at 60 Hz.
How it works
ListVieworGridViewwith a cache buffer (Qt's default is 320 pixels) fills that buffer later than the rows it shows: each refill starts a 16 ms pause job,bufferPause, inQQuickItemViewPrivate::refill().QQmlAnimationTimer, a queuedstopTimeris skipped while a start is pending. If the pending job is then stopped while it is still inanimationsToStart, it is taken off that list and nothing queues another stop. The animation timer stays registered with no job, the animation driver never stops, and the window is redrawn at every refresh. This is Qt Declarative 6.12.0, and the same code is in Qt's dev branch.cacheBuffer: 0no pause job is ever started, so the views cannot reach that state.displayMarginBeginninganddisplayMarginEndof 320 pixels, whichrefill()fills at once, with the rows shown and with no timer: the rows that exist are the ones that existed before.GridViewmakes a row past each edge by itself, and rows inside a display margin are drawn, not only made: every tile is a layer, and margins there cost 7 MiB on the large folder.Tests
One new case with a row for each view (grid, list, columns), failing for all three without the commit. It opens the real pane on a folder of 60 entries in a short window, moves the view to its end and back, and checks that in the list and the columns rows reach 320 pixels behind the top edge and as far past the bottom one at once, and that in every view no row is added in the 300 ms after: a cache buffer's timer adds its rows in that time. Eleven mutants, each taking one of the new properties from one view or halving the 320, all fail it.
Limits
mainand rows would be made as they scroll in; I kept the rows they had.maindid not show it in this week's 54 starts.