Skip to content

Desktop: Add an 'Enable V-Sync' preference on Mac#3887

Merged
Keavon merged 4 commits intomasterfrom
desktop-mac-vsync-option
Mar 11, 2026
Merged

Desktop: Add an 'Enable V-Sync' preference on Mac#3887
Keavon merged 4 commits intomasterfrom
desktop-mac-vsync-option

Conversation

@timon-schelling
Copy link
Member

@timon-schelling timon-schelling commented Mar 11, 2026

This gives users the option to choose between higher latency (a problem currently on Mac, specifically) or tearing, instead of forcing tearing as a latency reduction measure like we've done so far.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily focuses on enhancing the macOS desktop application experience by introducing a user-configurable VSync preference. It involves integrating this new setting into the application's core logic, updating the rendering pipeline to apply the chosen synchronization mode, and providing a user interface element for control. Additionally, it includes minor code improvements and a correction in the pixel preview rendering logic.

Highlights

  • macOS VSync Preference: Introduced a new preference to enable or disable VSync (Vertical Synchronization) specifically for macOS desktop applications. This allows users to control screen tearing versus input latency.
  • Rendering Pipeline Integration: Modified the WGPU rendering setup to respect the new VSync preference, applying wgpu::PresentMode::Immediate when VSync is disabled on macOS.
  • Preferences UI and Management: Added a VSync checkbox to the preferences dialog, visible only on macOS, and updated the preferences message handling and storage to manage this new setting.
  • Minor Refactorings: Performed small code refactorings in menu handling and widget processing, improving code style and clarity.
  • Pixel Preview Calculation Fix: Adjusted the viewport_zoom calculation in the pixel preview node to correctly incorporate the physical_scale.
Changelog
  • desktop/src/app.rs
    • Imported Preferences message type for wrapper communication.
    • Added a preferences field to the App struct, conditionally compiled for macOS.
    • Modified the App::new constructor to accept Preferences.
    • Passed the preferences object during App initialization.
    • Implemented macOS-specific VSync logic to determine the present_mode for RenderState.
  • desktop/src/lib.rs
    • Read user preferences earlier in the application startup process.
    • Used the pre-read preferences for the disable_ui_acceleration check.
    • Passed the prefs object to the App constructor.
    • Adjusted the restart logic for Unix-like systems by moving a tracing::error call.
  • desktop/src/render/state.rs
    • Imported PresentMode from the wgpu crate.
    • Updated the RenderState::new function signature to accept an optional PresentMode.
    • Configured the WGPU surface's present_mode using the provided option, defaulting to the first available mode if none is specified.
  • desktop/src/window/mac/menu.rs
    • Refactored menu item mapping to use direct function references instead of closures for menu_item_kind_to_dyn.
  • desktop/wrapper/src/utils.rs
    • Changed into_iter() to iter() when processing widgets in the menu bar.
    • Passed children directly to convert_menu_bar_entry_children_to_menu_items instead of a reference.
  • editor/src/messages/dialog/preferences_dialog/preferences_dialog_message_handler.rs
    • Added a new VSync checkbox to the preferences dialog, which is only displayed on macOS.
    • Included tooltip descriptions for the VSync checkbox.
  • editor/src/messages/preferences/preferences_message.rs
    • Added a VSync message variant to PreferencesMessage, conditionally compiled for macOS.
  • editor/src/messages/preferences/preferences_message_handler.rs
    • Added a vsync boolean field to PreferencesMessageHandler, conditionally compiled for macOS.
    • Updated the needs_restart method to include vsync comparison for macOS.
    • Initialized the vsync preference to false in the Default implementation.
    • Implemented handling for the PreferencesMessage::VSync message to update the vsync preference.
  • node-graph/nodes/gstd/src/pixel_preview.rs
    • Modified the viewport_zoom calculation to include physical_scale.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a VSync preference for the desktop application on macOS. The preference is exposed in the preferences dialog and controls the wgpu::PresentMode to enable or disable VSync. The implementation correctly threads the preference from the editor UI down to the rendering state.

I've found one minor issue with the use of a lint attribute, for which I've left a specific comment. The rest of the changes, including some unrelated refactorings and a bug fix in pixel_preview.rs, look good.

Comment on lines +49 to +50
#[cfg_attr(not(target_os = "macos"), expect(unused))]
preferences: Preferences,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The expect(unused) attribute is likely not what you intend here. The #[expect] attribute is a Clippy attribute used to assert that a lint is triggered for the annotated code, and it will emit a clippy::needless_expect warning if the lint isn't triggered.

While it does suppress the original unused lint, the idiomatic way to suppress warnings for code that is intentionally unused on certain platforms is with #[allow]. Using #[allow(dead_code)] is more specific and clearly communicates the intent without the extra noise of expect.

Suggested change
#[cfg_attr(not(target_os = "macos"), expect(unused))]
preferences: Preferences,
#[cfg_attr(not(target_os = "macos"), allow(dead_code))]
preferences: Preferences,

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 9 files

@Keavon Keavon changed the title Desktop: Mac add vsync preference Desktop: Mac add v-sync preference Mar 11, 2026
@Keavon Keavon force-pushed the desktop-mac-vsync-option branch from 75a7a01 to 318fa0f Compare March 11, 2026 21:26
@Keavon Keavon changed the title Desktop: Mac add v-sync preference Desktop: Add an 'Enable V-Sync' preference on Mac Mar 11, 2026
@Keavon Keavon enabled auto-merge March 11, 2026 21:29
@Keavon Keavon added this pull request to the merge queue Mar 11, 2026
Merged via the queue into master with commit a18b7ff Mar 11, 2026
6 checks passed
@Keavon Keavon deleted the desktop-mac-vsync-option branch March 11, 2026 21:37
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.

2 participants