Skip to content

High FPS fluctuations on MacOS with VSync and present_with_transaction #8109

@diquah

Description

@diquah

Description
When trying to make a responsive GUI-heavy application, vsync and responsive resizing (present_with_transaction) are important. But, when both are enabled the FPS fluctuates wildly.

Repro steps

  1. Set present_with_transaction to true
  2. Set present_mode to Fifo

Expected vs observed behavior

Screen.Recording.2025-08-15.at.2.52.17.PM.mp4

Extra materials
Article on fixing this issue with Rust and Metal: https://zed.dev/blog/120fps

Code for setting present_with_transaction:

unsafe {
    let surface = surface.as_hal::<wgpu::hal::metal::Api>();
    if let Some(surface_ref) = surface {
        let surface_ptr: *const wgpu::hal::metal::Surface = &*surface_ref;
        let surface_mut_ptr: *mut wgpu::hal::metal::Surface = surface_ptr as *mut _;
        #[allow(invalid_reference_casting)]
        let surface_mut = &mut *surface_mut_ptr;
        surface_mut.present_with_transaction = true;
    }
}

Surface configuration

let config = wgpu::SurfaceConfiguration {
    usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
    format: surface_format,
    width: size.width,
    height: size.height,
    present_mode: wgpu::PresentMode::Fifo,
    alpha_mode: surface_caps.alpha_modes[0],
    view_formats: vec![],
    desired_maximum_frame_latency: 2,
};

Platform
MacOS 15.6
M1 Max
wgpu 26.0.1
winit 0.30.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: performanceHow fast things gohelp requiredWe need community help to make this happen.platform: macosIssues with integration with macostype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions