Repository navigation
Description
Consolidates #101 (left and top edges). Measured on current dev (5521783).
What happens
- Right or bottom edge: while dragging, the content trails the edge. Windows stretches the old frame or shows an empty strip until the next frame lands.
- Left or top edge: the whole page jumps sideways (or up) by the drag distance on each step, then snaps back. The gap opens at the opposite edge, the one not being dragged.
Machine: Windows 11, Intel UHD 730 + RTX 4070, 239 Hz monitor on the RTX, kit-gallery in release.
kit-gallery drag, right edge |
Resize steps/s | surface.configure |
|---|---|---|
dev before the display-GPU pick (Intel iGPU) |
19 | 34 ms |
current dev (RTX, ae0c949) |
73–84 | median 2.5–2.8 ms, worst 3.5–4.4 ms |
Each step is now cheap, so what's left is when frames are drawn and where Windows places them.
Cause
- Deferred redraw. Inside Windows' size-move loop, winit reports
Resizedbut the redraw waits for the loop's next message, so Windows shows each new size before Rune has drawn it. - Origin moves on left/top drags. Until the app presents a frame at the new size, DWM shows the last frame pinned to the client area's new top-left, so the old frame moves with the edge. Drawing sooner shortens this but can't remove it.
- Rune can't offset the frame, because wgpu owns the composition tree. With
Dx12SwapchainKind::DxgiFromVisual, wgpu-hal creates its ownIDCompositionDevice, target and root visual for the HWND (wgpu-hal30,dx12/dcomp.rs,InnerState::init) and never exposes them.
Requested change
Right and bottom edges (working reference: zAcherttp/rune windows-live-resize, where steps ran at 3.4–6 ms with no visible lag or stretch):
- Extend the size-move subclass (
platform/win32/dpi_drag.rsalready watchesWM_ENTERSIZEMOVE/WM_EXITSIZEMOVE): inside the loop, draw inResizedbefore returning, at frame latency 1 withImmediatepresents. - On DX12, keep one monitor-sized swapchain for the drag and draw into a viewport of it, so steps don't reconfigure. DirectComposition windows can drop the GDI redirection bitmap (
WS_EX_NOREDIRECTIONBITMAP). - Clear a root with no fill to the first opaque element covering the window, so a fast drag's uncovered strip matches the page instead of black.
Left and top edges (researched, not prototyped):
- Rune owns the tree: create the
IDCompositionDevice, a target for the HWND, a root visual and a content visual, and make the surface withwgpu::SurfaceTargetUnsafe::CompositionVisual(content)(wgpu 30, DX12). This step only moves ownership; behaviour, screenshots and transparency stay identical. - In the subclass, read
WM_SIZING's edge (WMSZ_LEFT,WMSZ_TOPand the corners). For each step, offset the content visual by the origin's movement since the last presented frame (SetOffsetX(+dx),SetOffsetY(+dy)) andCommit()before returning, so the old frame stays where it was on screen. When the frame at the new size presents, reset the offsets to 0 andCommit().
Risk to check before step 5: the window move (applied by DWM) and the visual offset (a DirectComposition commit) must land in the same composed frame; one frame apart, the page wobbles instead of jumping. Test with a window that moves its origin and offsets a solid-colour visual in the same step, watched at 240 Hz or captured with PresentMon. If the commit lands late, try IDCompositionDevice::WaitForCommitCompletion, or committing from WM_WINDOWPOSCHANGING before the move is applied.
Scope
- DX12 only. Vulkan keeps the HWND swapchain and today's behaviour.
- The owned tree is also what Mica/Acrylic backdrops and native video visuals need;
research/11-platform-shells.mdplans the sameIDCompositionDevice/ target / visual tree for the Windows shell. - Maximise, Snap and DPI changes can keep the deferred path.
Acceptance
- Dragging any edge or corner at full speed, the page doesn't trail the edge or move on screen; only the uncovered strip at the dragged edge shows, in the page colour.
- Step time stays at or under current
dev(median ~2.6 ms configure) with no added frame of lag. - Transparent windows, overlays and screenshots are unchanged.
I can test any change on this machine (RTX 4070, plus the Intel iGPU via WGPU_ADAPTER_NAME=intel).
Activity
zAcherttp commentedon Nov 6, 2026
Update against current
dev(5521783), same machine. #46 is closed, so this issue is now the request.GPU choice is done:
devpicks the RTX ("the GPU driving the primary display", ae0c949), on DX12. That removed most of the cost in the table above:kit-gallerydrag, right edgesurface.configuredev(Intel iGPU)dev(RTX)Still broken: the content still lags behind the edge during the drag, and Windows stretches the old frame or shows an empty strip. Each step is now cheap; it just isn't drawn before Windows shows the new size, because winit defers the redraw until the size-move loop's next message.
Requested change (items 2 and 3 above, unchanged;
windows-live-resizeis a working reference):WM_ENTERSIZEMOVE/WM_EXITSIZEMOVE; inside the loop, draw inResizedbefore returning, at frame latency 1 withImmediatepresents.SurfaceTargetUnsafe::CompositionVisual), for left-edge drags.On the branch, steps ran at 3.4–6 ms with no visible lag or stretch. I can test any change on this machine.
[-]Windows: smooth live resize, and owning DirectComposition ahead of the Windows shell[/-][+]Windows: live resize lags and stretches on every edge[/+]Hona commentedon Nov 23, 2026
The deferred-redraw and DXGI pacing causes behind this report (
55217838) are fixed on currentdev. Two parts of the request are not ondev: reusing a display-sized swap chain across resize steps (#1065 was closed pending fresh measurements on the new surface code) and offsetting the DirectComposition visual on left/top-edge drags. We have not measured live Windows 11 DWM resize timing on currentdev.Pull requests that addressed this:
ResizedduringWM_ENTERSIZEMOVE..WM_EXITSIZEMOVE(crates/rune/src/platform/win32/dpi_drag.rs,crates/rune/src/window/host/events.rs).crates/rune/src/platform/win32/dcomp_handover.rs).FRAME_LATENCY = 1non-blocking waitable pacing, preserved acrossResizeBuffers.WS_EX_NOREDIRECTIONBITMAPon transparent windows.If resize still lags, stretches, or jumps on current
dev, please reopen with a repro:cargo run --release -p kit-gallery(orcargo run --release -p settings --features frame-profilewithRUNE_GPU_LOG=1andRUNE_FRAME_LOG=resize.jsonl).RUNE_CPU_FIRST=0orWGPU_ADAPTER_NAME=intel).resize.jsonl.Thanks for the detailed measurements and reference branch.
Hona commentedon Nov 24, 2026
Follow-up from a live check on Windows 11: we ran
devatac452a9c2in a live window on a 3440×1440, 165 Hz display (scale 1.0) using an NVIDIA GeForce RTX 5070 Ti on DirectX 12.Captures taken mid-drag during slow edge and corner drags (at intermediate sizes 584×400 on the right edge, 480×503 on the bottom edge, and 583×494 on the corner) showed the content, border, and edge bars staying flush with the frame, with no stretched or stale band.
This only covers one machine, one display, and a DirectX 12 discrete GPU (and slow right, bottom, and corner drags). If resize still lags or stretches on your machine, please reopen with a capture.
zAcherttp commentedon Nov 25, 2026
A follow-up on the remaining live resize wobble on Windows.
The jump on left and top drags comes from DWM showing the window's new size and the swap chain's
frame in different compositions, and no public Windows API ties the two together. I prototyped a
fix that applies only during a drag: frames go through a path DWM waits for at each size step, and
on Windows 11 through the resize synchronization Windows' own UI frameworks use. With it, fast
left-edge drags show no visible flicker or wobble.
Findings, measurements and a proposed design are in #2113. I have a working implementation
and can share it if the approach is wanted.