Repository navigation
Description
Follow-up to #47.
Summary
During a live resize on Windows, Rune's page wobbles: on a fast drag, content anchored to the edge
that stays still jumps by a step and comes back, most visibly on left and top drags. The cause is
that a DirectComposition swap chain's frame and the window's new size reach the screen in different
compositions, and no public Windows API ties them together.
I prototyped and measured a fix. During a drag only, each frame is drawn off-screen into a texture
shared between D3D12 and D3D11, and reaches the window in step with the resize, either through a
copy-model D3D11 swap chain or, where available, through the resize synchronization Windows' own UI
frameworks use. With the second, fast left-edge drags show no visible flicker or wobble. Outside a
drag nothing changes.
I have a working implementation (about 1,200 lines, Windows only) and can share it as a patch or a
branch if the approach is wanted. This issue records the findings and a proposed design.
Environment: Windows 11, RTX 4070, wgpu DX12, 239 Hz display, the settings example.
Root cause
While the user drags a window edge, Windows applies each new size in its size-move loop
(WM_WINDOWPOSCHANGING, WM_NCCALCSIZE, WM_SIZE, WM_PAINT) and DWM shows it at its next
composition. A frame presented through the window's DirectComposition flip-model swap chain lands on
its own schedule, often one composition before or after the new size. When the size change also
moves the window's corner (left and top edges), a frame shown at the wrong size is shown at the
wrong position.
Electron reached the same conclusion in 2025 ("Windows provides no way for us to synchronize those
operations"), and Firefox (bugs 1617517, 1494522) and Chromium show the same artifacts.
What was measured
- Every composed frame captured at 240 fps with Desktop Duplication, scored per frame: whether a
control anchored to the still edge stays at the same screen position. - A per-step timer from Windows announcing a size (
WM_WINDOWPOSCHANGING) to the paint that shows
it. - Sizes applied per second during scripted drags.
- Hand tests on the panel itself, since some artifacts never appear in a capture (see below).
Approaches that didn't work
| Approach | Result |
|---|---|
A drawable larger than the window during the drag, Immediate presents |
Halved step-to-frame latency; the frame still isn't synced with the size |
| Offsetting the DirectComposition root by each step's corner move | Worse on fast drags: the offset lands a refresh before the move (still edge steady on 12% of moving frames, against 55–61% on dev) |
Drawing the new size in WM_WINDOWPOSCHANGING |
The frame lands a refresh early instead of late (22% steady) |
Waiting for a composition (DwmFlush) before each step |
Halves the step rate and doubles the error |
What works
Drawing through the window's redirection surface. DWM waits for a redirected window to paint
at its new size before showing it. Rune's CPU renderer already works this way, and holds the still
edge at 0 px on every captured frame of fast drags. A GPU frame copied back and drawn with BitBlt
in WM_PAINT does too (100% of moving frames steady, against 55–61% on dev). This is also the
approach Raph Levien recommends and Flutter's Windows embedder takes.
DWM only waits about one refresh, though. With a CPU readback, a step took a median 4.5–4.9 ms and
69–85% of steps ran past a 239 Hz refresh; a late step is shown unsynced, which on a left drag looks
like an occasional one-refresh jump.
Keeping the copy on the GPU. D3D12 only creates flip-model swap chains, which bypass the
redirection surface. During a drag, the D3D12 frame is drawn into a texture shared with a D3D11
device on the same adapter (a shared fence orders the two on the GPU), and a D3D11 copy-model swap
chain (DXGI_SWAP_EFFECT_DISCARD) presents it into the redirection surface. No readback and no CPU
wait. Fewer steps run late, but a fast left drag still flickers occasionally.
Windows' resize synchronization. UWP and WinUI keep content in step with a resize through a
handshake that isn't in the public API: user32 ordinals 2615 (EnableResizeLayoutSynchronization)
and 2614 (GetResizeDCompositionSynchronizationObject), the step's layout reported done through
ordinal 2538, and IDCompositionDesktopDevicePartner6::SynchronizedCommit (Windows 11 22H2 and
later). Magpie and EpicGames/raddebugger#1033 use it on plain Win32 windows. With it, each step's
frame is copied from the same shared texture into a DirectComposition surface on a topmost layer and
committed with that step's synchronization object, and DWM holds the step until the commit arrives.
On fast left-edge drags there's no visible flicker.
Results
Scripted A/B, two alternating rounds per path, dragging each edge out and back at a 0.3 s and a
0.08 s pace:
| Path | Step median | Steps past a refresh | Sizes/s (left, right) | Fast left drag, by eye |
|---|---|---|---|---|
dev (DirectComposition swap chain) |
— | — | — | wobbles |
| GPU frame read back, GDI paint | 4.5–4.9 ms | 69–85% | — | steady, occasional jump |
| D3D11 copy-model swap chain | 3.1–3.8 ms | about 6% | 238–247 | steady, occasional flicker |
| Resize synchronization | 2.3–2.7 ms | 0.2% | 149–237 | steady, no visible flicker |
With resize synchronization, Windows applies fewer sizes per second on horizontal drags, because it
holds each step until its frame is committed. The edge follows the cursor in slightly larger
increments, but every step shown is complete.
Pitfalls worth knowing
- The copy must happen inside the
WM_PAINTWindows sends for the step (BeginPaint/EndPaint);
drawing inWM_SIZEis slower and isn't waited for. - Windows keeps the old client pixels aligned to the client area's top-left corner, so a left or top
drag can briefly show them shifted by the step. ReturningWVR_VALIDRECTSfromWM_NCCALCSIZE
with rectangles that keep them in place on screen (orSWP_NOCOPYBITS) fixes it. - Any
WM_ERASEBKGNDbetween steps is composed as a flash, so erasing is suppressed during a drag. - Presenting to the hidden D3D12 swap chain during a drag still reaches a hardware overlay plane
and flickers on the panel. Captures never show this, because capturing makes DWM compose every
plane; it has to be checked by eye. Drag frames are therefore drawn off-screen with no present. - After the drag, one frame is presented through the normal swap chain, and Rune's composition tree
is restored only once the GPU has finished it.
Proposed design
- Only between
WM_ENTERSIZEMOVEandWM_EXITSIZEMOVE: take Rune's DirectComposition tree off
and draw each frame off-screen into a D3D12 texture shared with D3D11. - Where resize synchronization is available, commit each frame with its step's synchronization
object. Every step's object is either used or released as soon as Windows has handled the step,
so the window can never wait for a timeout. - Otherwise fall back to the D3D11 copy-model swap chain, and failing that to a CPU readback drawn
inWM_PAINT. - After the drag, present through the normal swap chain and restore the tree.
The drag's phases (idle, starting, drawing, leaving) are one explicit state machine, and nothing
changes for translucent windows or windows without a Rune-owned composition tree.
Open question
Resize synchronization is undocumented: its interface layout differs between Windows builds, and a
missed completion would stall the window. Should it be on by default on Windows 11 22H2 and later,
behind a build check with the D3D11 swap chain as the fallback, or opt-in behind a flag?
References
- Raph Levien, "A smooth resize test" (2019)
- Electron, "Tech talk: window resize behavior" (2025)
- Flutter Windows embedder,
flutter_windows_view.cc - Firefox bugs 1617517 and 1494522
- How to remove the flickering of WinUI3 Window on resizing microsoft/microsoft-ui-xaml#5148
- Magpie,
SmoothResizeHelper.cpp; Resize sync EpicGames/raddebugger#1033
Activity
opencodejr commentedon Nov 25, 2026
Thanks for the thorough write-up and the A/B numbers. This is a clear follow-up to the left/top-edge part of #47 that never landed (offsetting the DirectComposition visual), so I'm tracking it as a feature request.
Where current
devstands, for anyone picking this up:crates/rune/src/platform/win32/dpi_drag.rsonly tracks whether a window is insideWM_ENTERSIZEMOVE..WM_EXITSIZEMOVE. It's the natural home for the drag phases, whichAGENTS.mdwants as one explicitenum Stateplusstepfunction (rune::machine), as your design already does.crates/rune/src/platform/win32/frame.rsalready handlesWM_NCCALCSIZEfor the custom frame, so theWVR_VALIDRECTSchange needs to fit alongside that.crates/rune/src/platform/win32/dcomp_handover.rsowns the DirectComposition tree (Windows: a window's first frame is drawn on the CPU and shown before its GPU exists; the GPU takes over when it's ready #689), which the drag path would take off and restore.SynchronizedCommitcode in the repo yet.On your open question: whether the undocumented resize synchronization is on by default (behind a Windows build check, with the D3D11 copy-model swap chain as the fallback) or opt-in is a call for the maintainers. Keeping the fallback chain as you describe it would make either choice workable.
If you share the branch, it will be easier to review in pieces. The repo keeps Rust files under about 800 lines, and changes that affect app output need a
changelog/unreleased/entry.opencodejr commentedon Nov 25, 2026
I haven't opened a pull request for this. The change needs Windows-only interop with undocumented APIs (
user32ordinals 2614/2615/2538,IDCompositionDesktopDevicePartner6::SynchronizedCommit), and the only real check is by eye on a Windows 11 machine, because captures hide the overlay-plane flicker. I can't build or run that here, and your measured implementation is a better starting point than a rewrite I couldn't verify.If you'd like to share your branch, review would go easier if it came in pieces:
crates/rune/src/platform/win32/dpi_drag.rs(oneenum Stateplusstep, perAGENTS.md) with the shared D3D12/D3D11 texture and the copy-model swap chain fallback.WVR_VALIDRECTSand erase-suppression handling, which sits beside the existingWM_NCCALCSIZEcode incrates/rune/src/platform/win32/frame.rs.The repo keeps Rust files under about 800 non-test lines and asks for a
changelog/unreleased/entry for changes that affect app output.Hona commentedon Nov 25, 2026
Thanks for the detailed measurements and analysis.
We have decided to build the first path in-house using public Microsoft-documented APIs only, off by default at first. We will not build the second path because it relies on private, undocumented Windows interfaces, and we will not offset the DirectComposition visual.
One correction to the earlier comments here: as
README.mdnotes, Rune does not take outside code or pull requests, so you do not need to share a branch. Your eyes on real hardware would be very helpful, though — we cannot watch a live drag on a Windows display right now, so once the opt-in lands ondevwe will follow up here with how to turn it on and ask you to try it on your machine.Hona commentedon Nov 25, 2026
The opt-in drag-only resize path has landed on
devin #2133 (14e80f90d), built in-house with public Microsoft-documented APIs only, and off by default. As noted earlier, we are not building the undocumented synchronization path and Rune does not take outside code (README.md).How to try it
No rebuild of Rune is needed — set
RUNE_RESIZE_SYNC=1in the environment when launching an example or app, for example in PowerShell:When
RUNE_RESIZE_SYNCis unset or0, Windows apps stay on the normal DirectComposition flip-model path with zero D3D11 devices, shared textures, or second swap chains created. Transparent windows, overlays,WGPU_DX12_PRESENTATION_SYSTEM=hwnd, and CPU-first/handover/rebinding windows always keep the normal path.What to test
examples/settingsandexamples/kit-gallery, checking for wobble, entry/exit flash, and any flicker or MPO overlay artefacts.What has and has not been checked
Idle/Entering/Dragging/Leaving) and its exclusions and abort exits,WVR_VALIDRECTSrect math, zero drag GPU allocations whenRUNE_RESIZE_SYNCis off, and real-adapter D3D12-to-D3D11 shared-texture and shared-fence transfer with bit-exact pixel parity and zero leaked textures on exit.Please report what you see here (with a capture if you can) — whether this becomes the default will be decided after a live Windows 11 check.
zAcherttp commentedon Nov 25, 2026
Thanks for building it. I tried
RUNE_RESIZE_SYNC=1ondevat73a7e2a0(which includes #2133), in release builds ofsettingsandkit-gallery, on the same machine as before: Windows 11, RTX 4070, DX12, 239 Hz display.Fast left- and top-edge drags (growing and shrinking)
settings: the path is active and the wobble is gone. The page stays put on roughly 95% of steps, but a fast left-edge drag still flickers now and then: a frame where the page shows a step out of place. It matches what I measured with my own copy-model D3D11 prototype, where about 20–29% of steps ran past one refresh, and DWM shows a late step unsynced.kit-gallery: dragging feels like roughly 20–25 fps. The occasional flicker is harder to spot at that rate, but I expect it's the same as insettings. The slowness isn't from the new path: scripted drags step at 26–29 sizes/s withRUNE_RESIZE_SYNCon and off alike, against about 155 insettings. Aframe-profilebuild withRUNE_FRAME_LOG(path off, 106 drag frames) shows where the time goes; it's all CPU, in building the view:The sub-stages add up to more than the build because they also count builds made while handling input between frames. Every drag frame rebuilds the whole tree (
whole: "new size, colour or swap chain",why: ["relayout", "instant"]) of about 11,900 nodes, and commit takes the largest share.settingshas about 90 nodes and builds in under 0.1 ms.Also, with
RUNE_RESIZE_SYNC=1the frame log records almost nothing during a drag (6–8 lines for a whole run, against 106 with it off), so frames drawn through the new path don't seem to reachRUNE_FRAME_LOG.No flash when a drag starts or ends.
Other cases
kit-gallery: same as thekit-galleryresult above.About captures: the occasional flicker shows up in a screen capture played back in slow motion. I can record one of a fast left-edge drag and attach it if that helps.
A note on the private resize sync, for the record: Microsoft hasn't documented it or announced plans to (microsoft/microsoft-ui-xaml#5148 has been open for years). In practice it's Windows 11 only:
IDCompositionDesktopDevicePartner6matches 22H2 and later, the interface differs on 21H2, and on Windows 10 it doesn't hand out sync objects. Anywhere it's missing, a prototype that checks the interface's IID falls back to the documented copy-model path that #2133 ships, so that path is the right base either way.Unrelated, from
kit-gallery's stderr:duplicate sibling key "model-scrim" under "kit-root"(and the same for"model-content").Hona commentedon Nov 25, 2026
The
kit-galleryresize slowdown andmodel-scrim/model-contentstderr warnings you spotted are fixed ondevin #2308 (071fa97ca):kit-gallery's default index mounted all 183 stories at once (~11,910 nodes), and Rune'sCommitKind::Relayoutfast path bailed out to a full view rebuild whenever anyanchored_fitoverlay (including a stray unconditionally open context menu inindex),aspect_fit, orpixel_aspectnode was mounted. Two combobox stories also shared the"model"key and state inindex, producing the duplicatemodel-scrimandmodel-contentsibling keys.dev:CommitKind::Relayoutnow restores clampedanchored_fitandaspect_fitstyles before re-fitting and stays on relayout whenpixel_aspectis unchanged;kit-gallery's index now usesvirtual_rows(~314 mounted nodes, dropping headless CPU cost from ~32.6–34.9 ms to ~0.40–0.45 ms median per resize step) and unique per-story overlay keys.dev(071fa97ca) and repeat the same drag-resize onkit-gallery(both closed and with an overlay open).Hona commentedon Nov 25, 2026
Thanks for testing
RUNE_RESIZE_SYNC=1on live hardware and for the detailed numbers — that is the first live confirmation that the wobble is gone with no entry/exit flash and clean Escape, title-bar move, rapid-drag, and video behavior.What landed on
devin #2309 (e68fb5910)RUNE_FRAME_LOG(along withSurfaceMeter,FrameReports,FrameClock, interaction timing,Trace, damage bookkeeping, andRest), recording per-stage timings (acquire,build,upload,encode,submit,present,total) on every drag step.CopySubresourceRegion, movedResizeBuffersahead ofBeginPaint, and added non-blockingPollduring drags to reclaim wgpu command allocators. Off-screen--profile perfD3D12-to-D3D11 step transfer dropped from 426 µs median (120 texture allocations per 120 steps) to 28 µs median (2 allocations), though off-screen numbers leave outIDXGISwapChain1::ResizeBuffers,BeginPaint/Present(0, 0)/EndPaint, and DWM's composition latch.configso the normal swap chain reconfigures cleanly, and software (WARP) adapters and non-8-bit (HDR) formats stay on the normal path.Note on the occasional late step (~5% at 239 Hz): per Microsoft Learn (
DXGI_SWAP_EFFECT,DXGI_SCALING), copy-modelDXGI_SWAP_EFFECT_DISCARDrequiresDXGI_SCALING_STRETCH(only flip-model supportsDXGI_SCALING_NONE), so the HWND swap chain still resizes per size step and a step that straddles a 4.2 ms refresh boundary can still land unsynced — we do not expect the documented copy-model path to eliminate every late frame at 239 Hz.Decision on the default & what would help next
The path stays opt-in for now until more machines have been tested, and a public per-window
ResizeSyncswitch is coming next so apps can ship it without an environment variable; the undocumentedIDCompositionDesktopDevicePartner6/user32ordinal path is declined for good. Before flipping the default on Windows, reports on Intel iGPU, AMD GPU, hybrid GPU laptops (where Microsoft notes bitblt presents cost an extra cross-adapter copy), Windows 10 (22H2), mixed refresh-rate / mixed-DPI multi-monitor, HDR enabled, and dragging with an in-window playing video layer would all count — if you or anyone else following this thread has one of those setups, a report here would help.How to capture the drag frame log
In PowerShell on
devate68fb5910or later:If you have a moment to share the resulting
drag-sync-settings.jsonlfrom a fast left-edge drag — and the slow-motion capture you offered — it will show us exactly where any remaining late steps spend their time.Hona commentedon Nov 25, 2026
The public per-window switch has landed on
devin #2319 (6d566c196), leaving the default unchanged (ResizeSync::Autoresolves to off today, so apps that do not opt in stay on DirectComposition flip-model presentation with zero drag GPU allocations):The same builder is available per window on
WindowSpec::resize_sync, andexamples/settingsnow accepts--resize-sync(cargo run --release -p settings -- --resize-sync).RUNE_RESIZE_SYNCoverrides every window without a rebuild:1/true/yes/onforcesOn,0/false/no/offforcesOff(an unconditional kill switch even overResizeSync::On), andautoselectsAuto.Keeping this issue open until more machines have been tested before flipping
ResizeSync::Autoto on by default. Reports on any of the following setups (from you or anyone else following this thread) would count toward that decision:zAcherttp commentedon Nov 26, 2026
Retested on
devat66006728(includes #2308, #2309 and #2319), release builds with--features rune/frame-profileandRUNE_RESIZE_SYNC=1, same machine: Windows 11, RTX 4070, DX12, 239 Hz.settings, fast left-edge dragsClearly better than last time. What's left is a very faint ghost: for a refresh, the right-anchored controls show a second copy about one step to the right of where they belong. It looks much smoother than before.
The same late step in a screen capture of every composition (240 Hz): one refresh where the page sits closer to the window's right edge, then snaps back. Slowed to about 1/10 speed, and as a before / late step / after strip:
From
drag-sync-settings.jsonl(6 drags, 4,185 drag frames,whole: "drag resize sync"):22 frames (0.5%) went over one 239 Hz refresh, and 6 of those are the first frame of a drag: the first frame of every drag has a 5–8 ms
present(6–10 ms total). The very first drag after launch also took 21.9 ms inacquire, 36.8 ms total.kit-galleryMuch faster after #2308, and it now drags smoothly. From its frame log (5,941 drag frames): total median 3.08 ms, p90 4.14 ms, with 9% of drag frames over a refresh. The first frame of each drag shows the same slow
present(3.5–8.5 ms).One new, reproducible issue: the first drag after opening a dialog or a combobox flickers the whole window once. Later drags are smooth until you open a different component:
For a dialog, both opening it and closing it reset this, so the next drag flickers again. Neither stderr nor the frame log shows anything unusual on that drag: no fallback message, and its frame times look like any other first drag frame. So it seems to be what's drawn rather than when. One thing that might be worth checking: drag frames are drawn into a texture larger than the window, so a pass that only runs the first time after an overlay mounts (a cache refill, a layer or blur target) and doesn't clamp its viewport to the window would draw wrong content across the whole frame once.
fix(win32): wait for first drag Present before detaching DComp and cl…
Hona commentedon Nov 27, 2026
Thank you @zAcherttp for the clear reproduction, captures, and frame logs! A fix for the first-drag whole-window flicker after opening/closing a dialog or combobox has landed on
devin #2646 (6594ff297).What was causing it
Present(0, 0)beforedetach_dcomp: On drag exit (Leaving), Rune waits for the normal D3D12 flip-model frame to finish on the GPU before re-attaching DirectComposition (attach_root). On drag entry (BeginDrag), however,run_drag_frameimmediately calleddetach_dcomp()(SetRoot(None)+Commit+WaitForCommitCompletion) right after the asynchronous D3D11DXGI_SWAP_EFFECT_DISCARDPresent(0, 0)returned on the CPU—before the GPU finished rendering, copying, and blitting the first drag frame into the HWND's DWM redirection surface. Whenever normal DirectComposition frames between drags changed the screen (opening or closing a dialog/scrim, or opening a different component), detaching DirectComposition early briefly exposed the stale redirection bitmap from the previous drag or startup for one refresh, flickering the whole window once while subsequent drags were smooth because the redirection bitmap already matched.WM_ERASEBKGNDsuppression before the first dragBeginPaint(rolled back on failure), disarmed any stray retained partial damage before encoding into the capacited drag target, and clamped the default scissor alongside the viewport whenActivePass::splitre-opens a root pass on an oversized target texture.What was and was not verified
BeginDragordering (set_valid_rects_active(true)->present_sharedwith a live D3D11 post-present fence wait ->detach_dcomp), non-blocking steady-state drag steps, failure rollback, and bit-exact capacited-target pixel parity across stray armed damage, isolated dialog layers,El::cache, andEl::backdrop_blurpass splits (cargo test -p rune --lib resize_sync,render::backdrop,render::damaged).Leaving #2113 open — when you have a chance, could you pull
dev(6594ff297or later) and retest the samekit-gallerydialog/combobox open-and-close drag sequence on your RTX 4070 / 239 Hz setup?zAcherttp commentedon Nov 28, 2026
Retested on
devat0aa38951(includes #2646) withRUNE_RESIZE_SYNC=1, same machine as before (Windows 11, RTX 4070, DX12, 239 Hz). The first-drag flicker inkit-galleryis still there.What the flicker frame shows: the window's last frame from the previous drag. Open the basic dialog, drag, close it, open the localized combobox and drag: the flicker frame shows the basic dialog. On the next component it shows the combobox from the drag before, and so on. So for one refresh, DWM shows the redirection surface's old contents instead of the new first drag frame.
Why waiting on the post-present fence isn't enough: the D3D11 copy waits correctly for the D3D12 render, so the new frame is the one copied. But a copy-model
Present(0, 0)reaches the redirection surface through DWM, outside the D3D11 queue, so the post-present fence signal doesn't prove the blit has landed or been composed.detach_dcompcan still commit first.I tried three changes locally in
run_drag_frame(resize_sync/frame.rs), each behind an environment variable, comparing the same build side by side:DwmFlush()right beforedetach_root()on the first drag frameDWM_TIMING_INFO::cFramefromDwmGetCompositionTimingInfo) at the first drag present, keep the tree on, and detach on the first drag frame where the count has advanced by at least 2The working version, roughly:
The cost is that the first step or two of each drag still show the DirectComposition tree, as on the normal path, before the drag path takes over. I couldn't see it by eye. If the count can't be read, this version never detaches during that drag, so the drag stays on the normal path instead of flickering.
A second, smaller issue: animations freeze while a drag is held. With
RUNE_RESIZE_SYNC=1, holding an edge still stops the spinner and loader in the motion/focus dialog, and moving the edge scrubs them forward. During Windows' modal size-move loop, Rune only draws when a size step arrives, and its animation wake-ups don't run. The modal loop still dispatchesWM_TIMER, so I tried a timer in thedpi_dragsubclass, and the animations kept running while the drag was held, with no flicker coming back (tested together with the change above):WM_TIMERis coarse (roughly 64 Hz by default), and this version invalidates even when nothing is animating, so a real version should only ask for frames while something animates.Hona commentedon Nov 28, 2026
Thank you @zAcherttp for isolating that down to the exact redirection-surface frame from the previous drag and confirming the two-composition DWM timing gate — that was a huge catch.
Landed in #2753 (
b1878e630ondev):DcompPhase::Priming):BeginDragnow presents the first drag frame (with pre-paintWM_ERASEBKGNDsuppression and the post-present D3D11 fence wait), recordsDWM_TIMING_INFO::cFrameviaDwmGetCompositionTimingInfo(NULL, ...), and keeps the DirectComposition root attached untilcFramehas advanced by at least 2 desktop compositions. Once detached, steady-state drag frames skip DWM timing queries. IfcFrameresets (e.g. a display mode switch or DWM restart) it re-baselines for two more frames; if DWM timing is unavailable, the drag cleanly rolls back to normal DirectComposition resize instead of leaving DComp stuck attached over a frozen surface.dpi_dragnow arms an 8 msWM_TIMERonly on state edges while insideWM_ENTERSIZEMOVE..WM_EXITSIZEMOVEand either priming (so even a single resize step followed by a paused hold still finishes detaching after two DWM frames) or actively animating (outcome.animating). Once DComp is detached and nothing is animating—or onWM_EXITSIZEMOVE/ fallback / destroy—the timer is killed immediately so static drags do zero idle invalidation.Verified locally:
cargo check -p rune --libandcargo test -p rune --lib resize_sync(22 passed, including pure state-machine tests for 0/1/2 DWM frame gating, counter reset, unavailable DWM count fallback, and an off-screen multi-drag GPU/seam regression test verifying Drag 2 never detaches while the redirection surface still holds Drag 1's pixels).Not run locally: live interactive Windows 11 border-drag testing on a 239 Hz RTX 4070 display. Keeping #2113 open for your retest on
b1878e630!emmachase commentedon Nov 29, 2026
I tried this on
devat95ec635ef(so with #2646 and #2753) usingRUNE_RESIZE_SYNC=1. It's a different machine from the reports above: Windows 11 25H2, RTX 4090, a 4K 240 Hz display at 200% and a 1080p 60 Hz one at 100%. I used my own app rather thansettings(standard title bar, debug build with Rune atopt-level = 3).It's a huge improvement over sync off, but it's still a bit glitchy. Two things are left, and I can see both by eye:
To put numbers on it, I scripted drags with real mouse input and captured every composed frame, counting the frames where the content isn't where the window frame says it should be:
With sync on, 5 or 6 of the bad frames in each run are the start of the drag and the rest are isolated ones in the middle. 1% doesn't sound like much, but a one-frame jump of the whole page is easy to notice.
I don't think this path can get all the way to zero, since it will always be racing DWM's deadline, which matches what you said above about late steps. So here's another idea that avoids the race altogether.
Idea: draw the drag in an overlay window
While a border is being dragged, cloak the real window (
DWMWA_CLOAK) and draw its whole picture into a separate transparent, click-through window that covers the desktop and never moves or resizes. Because the overlay never changes size, there's nothing for a frame to be out of sync with. Each present is the complete window at one size. If a frame is late, the window just trails the pointer a little more instead of showing a mismatched frame. When the drag ends, the real window is uncloaked and the overlay hidden.It could be a third value next to the existing ones, something like:
I have this working in a local build of Rune, and that's the third column in the table: 0 bad frames on the same drags with the same app.
The catch is that the overlay has to draw everything DWM normally draws around the window: the border, rounded corners and shadow, plus the title bar if the window uses the standard one. The border and corners can be taken from a capture of the window when the drag starts, but the shadow and title bar have to be recreated to match, and none of that look is documented, so a Windows update could change it. Windows using Rune's own title bar are the easy case.
Other downsides:
NonRudeHWNDwindow property (so the shell doesn't treat the overlay as a full-screen window) and the theme class the caption buttons come from. I realize that might rule it out given the documented-APIs-only decision.bowenxuuu commentedon Nov 29, 2026
@Hona Hello,
After enabling
rune::ResizeSync::On, window resize dragging is noticeably smoother than before. My setup is Windows 11 26H2, NVIDIA GeForce RTX 5060 Laptop GPU with the DX12 backend.However, memory usage increases by roughly 12 MiB after a drag finishes, and this memory is never freed until the window is closed. From PR #2319, I understand this memory is allocated by the D3D11 device.
It would be ideal if we could release this memory at an appropriate time. Typical users usually resize the window shortly after launching the app and rarely resize it frequently afterward, so keeping this memory permanently allocated is wasteful.
Here is my proposal: keep the existing logic while the user is actively dragging to resize the window with the mouse held down. Once the drag completes (when the mouse button is released), release the memory associated with the D3D11 device.
fix(win32): release ResizeSync D3D11 DragDevice after drag finishes (#…
Hona commentedon Nov 29, 2026
Thank you @bowenxuuu for reporting the post-drag ~12 MiB retention — that is now fixed on
devin #2817 (a32e89e77).What changed
DragDevicewhen returning to steady-state: The copy-model D3D11 swap chain, shared render-target ring, shared fences, and lazily created D3D11DragDeviceare now owned together for the active drag only. AfterWM_EXITSIZEMOVE, Rune keeps them alive throughState::Leavinguntil the post-drag D3D12 flip-model frame finishes and DirectComposition re-attaches (AttachDcomp), then drops the entire bundle cleanly soState::Idleretains zero drag GPU objects.DragDevicereleases child objects in strict order, runsID3D11DeviceContext::ClearState()+Flush()+IDXGIDevice3::Trim(), and Rune polls wgpu so dropped shared D3D12 textures are reclaimed immediately instead of waiting for a future frame while idle.DragDeviceon the first resize step (pure title-bar moves still allocate zero GPU objects).Verification
cargo check -p rune --lib,wasm32checks,scripts/file-size.sh,d3d11_interoptests (2 passed), andresize_syncunit + off-screen GPU tests withtest-gpu-counters(29 passed, proving lazy acquisition, zero retainedDragDevice/ shared wgpu textures on idle, and clean recreation + bit-exact rendering on a second drag).Keeping #2113 open — when you have a chance, please pull
dev(a32e89e77or later) and let us know if your post-drag memory returns to baseline cleanly.bowenxuuu commentedon Nov 29, 2026
@Hona
I ran two sets of tests on dev(
a32e89e77), with the results below:With
ResizeSync::On: ~4 MB memory increase after finishing window resize drag.Without
ResizeSync::On: ~1 MB memory increase after finishing window resize drag.This is a notable improvement over the previous version, which retained roughly 12 MB of unreleased memory after drag operations. The root cause is still unknown. Even without
ResizeSync::On, a 1 MB memory delta remains after resizing, implying other confounding factors that introduce measurement noise.zAcherttp commentedon Nov 30, 2026
Retested on
devat3592b1e3(includes #2753 and #2817) withRUNE_RESIZE_SYNC=1, same machine as before (Windows 11, RTX 4070, DX12, 239 Hz).kit-galleryno longer shows the previous drag's frame, including the motion/focus dialog opened right after the basic dialog.settings: a small jump at the start of every fast drag, and occasional one-frame jumps during longer drags.One gap in the drag timer: pressing a border and holding still before moving still freezes animations, because the timer only arms once the first size step starts the drag path. Holding the title bar freezes them too, and so does the same press-and-hold with
RUNE_RESIZE_SYNC=0, so that part predates resize sync. I've filed it separately as #2908.An idea for the drag-start jump (untested): the jump is the two-composition wait happening after the first size step, while the DirectComposition tree is still attached. Windows says a size drag is starting before any size changes:
WM_SYSCOMMANDwithSC_SIZE(wParam & 0xFFF0), thenWM_ENTERSIZEMOVEat the press. If the first copy-model frame were presented at the current size there, and the two-composition wait ran during the press, the tree could already be detached by the first size step, so no step would be shown unsynced.SC_SIZEalso tells a resize from a move (SC_MOVE), so title-bar moves would still allocate nothing.feat(gui): resize drags drawn in Rune's overlay on Windows
feat(gui): resize drags drawn in Rune's overlay on Windows
feat(gui): resize drags drawn in Rune's overlay on Windows
feat(gui): resize drags drawn in Rune's overlay on Windows
feat(gui): resize drags drawn in Rune's overlay on Windows