Skip to content

fix(win32): feed drag-resize frames to RUNE_FRAME_LOG, use capacited texture ring, and harden fallback - #2309

Merged
Hona merged 1 commit into
devfrom
fix/2113-drag-resize-frame-log-and-latency
Nov 25, 2026
Merged

Hona merged 1 commit into
devfrom
fix/2113-drag-resize-frame-log-and-latency

Conversation

@Hona

@Hona Hona commented Nov 25, 2026

Copy link
Copy Markdown
Member

Refs #2113

Follow-up to #2133 after the first live Windows 11 test of RUNE_RESIZE_SYNC=1. Leaves the opt-in off by default with no public API changes.

1. Presented-frame consumers fed by the drag path (crates/rune/src/window/win32/resize_sync/frame.rs)

Consumer Before (#2133) After
RUNE_FRAME_LOG / FrameProfile (frame::live_log) Missed (6–8 non-drag lines only) Stamped & flushed every drag frame (whole: "drag resize sync")
SurfaceMeter presented() only redraw(), presented(), set_pacing()
FrameReports (App::on_frame_encoded) Missed set_refresh(), stamp(), drawn()
FrameClock::presented_core Missed Fed after present
RuntimeCore::interaction_presented (hitch/jank) Missed Fed after present
Trace (frame_timed_core -> writer thread, #2297) Missed Fed after present
App::on_frame_drawn (inspect_frame) Fed Fed
PaintKeep debug check & loop_checked loop_checked not drained Drained via FrameProfile::take_loop_check
Damage bookkeeping Damage::reset only Renderer::damage_drawn() + Damage::reset()
Rest, frame_presented, gpu_events::presented, haptics::flush_live, warm_effects, pre_present_notify Missed Fed

2. Eliminating per-step shared-texture reallocations (gpu.rs, present.rs, render/pass.rs)

  • Replaced the single exact-sized SharedDragTarget (reallocated via CreateCommittedResource + CreateSharedHandle + OpenSharedResource1 on every pixel size change) with a capacited 2-slot DragTargetRing (256 px growth steps with headroom, exact size kept only for custom compositors) rendered via sub-rectangle viewport/scissor (render/pass.rs::apply_subrect_viewport) and copied via CopySubresourceRegion.
  • Moved DxgiDragSwapChain::ensure_size (ResizeBuffers) ahead of BeginPaint/EndPaint, and added a non-blocking PollType::Poll after each drag present so wgpu reclaims finished command allocators during long drags.
  • Off-screen paired alternating --profile perf measurement (5 pairs × 120 resize steps, 640×480 ↔ 1112×596, BGRA8, real DX12+D3D11 adapter):
Path (n = 600 steps) Shared textures / 120 steps p50 p95 p99 max
Baseline (#2133 exact per-step alloc) 120 426 µs 584 µs 814 µs 1,302 µs
Candidate (capacited 2-slot ring + CopySubresourceRegion) 2 28 µs 68 µs 90 µs 440 µs
  • What off-screen measurement leaves out: IDXGISwapChain1::ResizeBuffers on the DXGI_SWAP_EFFECT_DISCARD HWND swap chain (required per size step because Microsoft Learn documents DXGI_SCALING_NONE as flip-model only), BeginPaint/Present(0, 0)/EndPaint into a live HWND redirection surface, and DWM's vblank composition deadline (occasional late steps at high refresh rates remain an inherent limit of the documented copy-model path).

3. Fallback & eligibility hardening (machine.rs, resize_sync.rs)

  • Fixed (State::Dragging, Event::DragFailed) in machine.rs: transitions to State::Idle with AttachDcomp + ReleaseDragResources instead of falling through to a no-op and leaving DirectComposition detached.
  • Fixed l.config rollback on failed drag steps (commit_or_rollback_config): tracks surface_size_before_drag so a fallback to Win::resize_surface never sees stale dimensions and skips ResizeBuffers on the normal D3D12 swap chain.
  • Excluded software/WARP adapters (DeviceType::Cpu) and non-8-bit (HDR) surface formats in resize_sync_eligibility.
  • With RUNE_RESIZE_SYNC unset or 0, zero D3D11 devices, shared textures, or second swap chains are created.

@Hona
Hona merged commit e68fb59 into dev Nov 25, 2026
1 check passed
@Hona
Hona deleted the fix/2113-drag-resize-frame-log-and-latency branch November 25, 2026 14:11
Hona added a commit that referenced this pull request Nov 25, 2026
…une and procwatch (#2370)

A feature-set warning sweep across Linux, macOS, Windows, and wasm32 found
eight dead-code warnings under optional and non-default feature sets:

- `crates/rune/src/open_path.rs:203` (`file_uri_from_bytes`, added in #1947):
  used on Unix only under `feature = "dbus"` (FileManager1) and tests; gate
  with `feature = "dbus"` alongside `test`.
- `crates/rune/src/platform/preferences.rs:77` (`DEFAULT_DOUBLE_CLICK_SECS`,
  added in #1923/#2128): used on Linux only under `feature = "dbus"` and tests;
  gate with `all(target_os = "linux", feature = "dbus")` alongside `test`.
- `crates/rune/src/window/titlebar/linux.rs:82` (`Sides::ALL`, added in #2244):
  used only in `linux_tests.rs`; gate with `#[cfg(test)]`.
- `crates/rune/src/frame/live_log.rs:33` (`CAPTURED` / `capture_frames`, added
  in #2309): used only in `window/win32/resize_sync/tests.rs` under
  `frame-profile`; gate with `#[cfg(all(test, target_os = "windows"))]`.
- `crates/procwatch/src/alloc/sites.rs:222,271,413,418` (`report`, `unsampled`,
  `os::modules`, `os::nt_heaps`, added in #744): `alloc-sites` sampling and
  dumper are Windows-only; gate the implementation behind `#[cfg(windows)]`
  with clean `#[cfg(not(windows))]` no-op stubs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant