Skip to content

fix: disable VSync to fix window height resize jitter - #3508

Open
mhduiy wants to merge 1 commit into
linuxdeepin:masterfrom
mhduiy:agent/pms-bug-bot/e042803dedb0
Open

mhduiy wants to merge 1 commit into
linuxdeepin:masterfrom
mhduiy:agent/pms-bug-bot/e042803dedb0

Conversation

@mhduiy

@mhduiy mhduiy commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Root Cause Analysis

When resizing the DCC window height from the bottom edge, the page content jitters vertically and a blank area appears at the top. The root cause is Qt QML rendering pipeline's VSync (vertical synchronization) combined with the OpenGL/Qt coordinate system difference (OpenGL origin at bottom-left vs Qt origin at top-left). DCC's transparent window + blur effect (color: "transparent" + D.StyledBehindWindowBlur) amplifies the per-frame recomposition load, making the VSync-induced frame delay visibly manifest as vertical content offset.

Key evidence:

  • main.cpp:95 — No QSG_NO_VSYNC environment variable set before QGuiApplication creation
  • Developer (杨武) confirmed export QSG_NO_VSYNC=1; dde-control-center --show eliminates the jitter
  • History record Network configuration to ignore hosts #5 (张洪源): All QML apps have this bottom-edge drag issue due to OpenGL/Qt coordinate difference

Fix

Add qputenv("QSG_NO_VSYNC", "1") before QGuiApplication creation in src/dde-control-center/main.cpp to disable VSync in the Qt QML rendering pipeline, eliminating the frame presentation delay that causes the coordinate offset.

Change Safety Assessment

Risk Level: Low

  • Code Safety: Single new line (qputenv call), no function signature changes, no existing logic modified. Blame history confirms target lines are from initial v25 migration, not a prior bug fix — no regression risk from reverting previous fixes.
  • Business Impact: Affects only DCC's Qt rendering synchronization behavior. No business logic, data flow, or UI layout changes. Users should verify: window height resize no longer causes jitter, all pages display and switch normally.
  • Verification Suggestion: Test window height resizing (bottom edge drag) on high-DPI displays (e.g., 2160x1440 @ 150% scaling); verify no screen tearing during normal page browsing and scrolling.

根因分析

从窗口底部边缘调整 DCC 窗口高度时,页面内容垂直跳动且顶部出现空白区域。根因是 Qt QML 渲染管线的 VSync(垂直同步)与 OpenGL/Qt 坐标系差异(OpenGL 原点在左下角,Qt 原点在左上角)共同作用。DCC 的透明窗口+毛玻璃效果(color: "transparent" + D.StyledBehindWindowBlur)放大了每帧重合成负载,使 VSync 引起的帧延迟表现为可见的内容垂直偏移。

关键证据:

  • main.cpp:95 — QGuiApplication 创建前未设置 QSG_NO_VSYNC 环境变量
  • 开发人员杨武已实测确认 export QSG_NO_VSYNC=1; dde-control-center --show 后跳动消失
  • 历史记录 Network configuration to ignore hosts #5(张洪源):所有 QML 应用底部拖拽均有此问题,系 OpenGL/Qt 坐标差异所致

修复方案

在 src/dde-control-center/main.cpp 的 QGuiApplication 创建前添加 qputenv("QSG_NO_VSYNC", "1"),禁用 Qt QML 渲染管线的 VSync,消除帧呈现延迟导致的坐标偏移。

改动安全评估

风险等级:低风险

  • 代码安全评估:仅新增一行 qputenv 调用,不修改函数签名、不改变现有逻辑。Blame 历史确认目标代码行来自 v25 初始迁移,非历史 bug 修复产物,不存在撤销历史修复的回归风险。
  • 业务影响范围:仅影响 DCC 的 Qt 渲染同步行为,不涉及任何业务逻辑、数据流或 UI 布局变更。建议验证:窗口高度调整不再跳动,各功能页面正常显示和切换。
  • 验证建议:在高 DPI 显示器(如 2160x1440 @ 150% 缩放)上测试窗口高度调整(底部边缘拖拽);验证正常页面浏览和滚动时无明显画面撕裂。

Summary by Sourcery

Bug Fixes:

  • Disable Qt QML VSync to eliminate vertical jitter and blank space when resizing the control-center window height.

Disable Qt QML rendering VSync by setting QSG_NO_VSYNC=1 before
QGuiApplication creation. The transparent window + blur effect in DCC
amplifies VSync-induced frame delay, causing visible vertical content
jitter when resizing window height from the bottom edge.

Log: fix window height resize page jitter
Bug: https://pms.uniontech.com/bug-view-317921.html

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @mhduiy, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 5 hours and 55 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mhduiy

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Sep 14, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR disables Qt QML VSync at process startup, addressing bottom-edge window resize jitter and top blank-area artifacts caused by delayed frame presentation in the transparent, blurred DCC window. Review should focus on confirming the environment variable is set before QGuiApplication initialization and validating resizing, high-DPI rendering, page navigation, scrolling, and possible screen-tearing tradeoffs.

Sequence diagram for disabling QML VSync before application startup

sequenceDiagram
    participant Main as main
    participant Env as QtEnvironment
    participant App as QGuiApplication
    participant QML as QMLRendering
    participant Window as DCCWindow

    Main->>Env: qputenv(QSG_NO_VSYNC, 1)
    Main->>App: QGuiApplication(argc, argv)
    App->>QML: Initialize rendering pipeline
    QML-->>Window: Present frames without VSync delay
    Window-->>Main: Resize without vertical jitter
Loading

File-Level Changes

Change Details Files
Disable Qt Quick VSync before application initialization to prevent resize-related frame presentation offsets.
  • Set the QSG_NO_VSYNC environment variable before creating QGuiApplication.
  • Leave application logic, APIs, and UI layout unchanged.
src/dde-control-center/main.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

AI 代码审查报告

项目: linuxdeepin/dde-control-center
PR: #3508
提交: fix: disable VSync to fix window height resize jitter
分支: agent/pms-bug-bot/e042803dedb0 → master
作者: mhduiy
审查时间: 2026-09-14


总体评价

总分: 97/100 — 优秀
代码审查通过。本次变更通过在 QGuiApplication 创建前禁用 VSync,有效修复窗口高度调整时的内容跳动问题。改动最小化(单行新增),无安全漏洞,代码逻辑正确。


漏洞统计

指标 数量
当前漏洞总数 0
新增漏洞 0
修复漏洞 0
持平漏洞 0

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个


四维度评分

维度 得分 状态 评价
语法逻辑 25/25 ✓ 语法正确,逻辑清晰
代码质量 23/25 ✓ 代码结构清晰,但缺少必要注释
代码性能 19/20 ✓ 性能良好,资源使用合理
代码安全 30/30 ✓ 存在0个安全漏洞

维度1:语法逻辑(25/25 ✓)

语法正确,逻辑清晰

分析

  • qputenv("QSG_NO_VSYNC", "1") 是 Qt 标准函数调用,签名 bool qputenv(const char *varName, const char *value),参数类型和调用语法正确
  • 放置位置正确:在 QGuiApplication *app = new QGuiApplication(argc, argv) 构造前设置环境变量,确保 Qt 渲染管线初始化时读取到该配置
  • 无编译错误,无逻辑缺陷,无内存泄漏风险(qputenv 内部管理内存)
  • 边界条件处理完善:qputenv 返回值未检查是可接受的,设置失败不会导致程序崩溃

变更代码

// src/dde-control-center/main.cpp:95
int main(int argc, char *argv[])
{
    qputenv("QSG_NO_VSYNC", "1");  // 新增:禁用 VSync
    QGuiApplication *app = new QGuiApplication(argc, argv);

维度2:代码质量(23/25 ✓)

代码结构清晰,但缺少必要注释

检查项

检查项 得分 说明
注释完整性 3/5 新增代码行未添加内联注释说明禁用 VSync 的原因,虽然 PR 描述详尽,但代码应具备自文档化能力
代码重复 5/5 无重复代码,单行新增
结构合理性 5/5 放置位置正确(QGuiApplication 创建前),改动最小化
调试信息清理 5/5 无残留调试代码,无敏感信息

改进建议

建议在新增行添加内联注释,说明禁用 VSync 的原因:

int main(int argc, char *argv[])
{
    // 禁用 VSync,修复窗口高度调整时 OpenGL/Qt 坐标系差异导致的内容跳动
    qputenv("QSG_NO_VSYNC", "1");
    QGuiApplication *app = new QGuiApplication(argc, argv);

维度3:代码性能(19/20 ✓)

性能良好,资源使用合理

分析

  • qputenv 为轻量级系统调用,仅在程序启动时执行一次,无性能开销
  • 禁用 VSync 是渲染质量与流畅性的权衡(可能引入画面撕裂 vs 消除跳动),非性能瓶颈
  • 无频繁系统调用、无资源泄漏、无不必要拷贝

轻微建议

全局禁用 VSync 可能影响所有页面的渲染同步行为。建议后续考虑条件化禁用(如仅在特定渲染场景或特定平台下禁用),以减少对正常页面浏览时渲染质量的潜在影响。


维度4:代码安全(30/30 ✓)

存在0个安全漏洞

安全检查

  • qputenv 参数为硬编码常量字符串,无用户输入,无注入风险
  • 无敏感信息泄露,无命令注入,无路径遍历
  • qputenv 是 Qt 安全 API,内部处理内存管理,无缓冲区溢出风险
  • 无权限绕过、无反序列化漏洞

审查结论

本次变更目的明确——通过禁用 Qt QML 渲染管线的 VSync 修复窗口高度调整时的内容跳动问题。代码实现与 commit 目的完全一致:

  1. qputenv("QSG_NO_VSYNC", "1") 正确放置在 QGuiApplication 创建前,确保环境变量生效
  2. 改动最小化(单行新增),不修改现有逻辑,无回归风险
  3. 无安全漏洞,无性能瓶颈

建议:可考虑添加内联注释说明禁用 VSync 的原因,提升代码可维护性。

@deepin-bot

deepin-bot Bot commented Sep 23, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 6.1.109
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #3545

This branch has not been deployed

No deployments
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