Skip to content

fix: reduce fullscreen-windowed switch stutter on 4K - #812

Closed
mhduiy wants to merge 1 commit into
masterfrom
agent/pms-bug-bot/9fe7b1c0432e
Closed

mhduiy wants to merge 1 commit into
masterfrom
agent/pms-bug-bot/9fe7b1c0432e

Conversation

@mhduiy

@mhduiy mhduiy commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Root Cause Analysis

Launcher mode switching uses two independent ApplicationWindow instances toggled via visible binding. On 4K resolution, the target window re-renders all content from scratch, where StyledBehindWindowBlur real-time blur (Main.qml:220,246) and EffectOut startup animation (Main.qml:319) compound the rendering cost. Additionally, a 100ms artificial delay (launchercontroller.cpp:274, QTimer::singleShot(100, ...)) blocks the switch path. Together these block the main thread ~2s on 4K displays.

Fix Approach

Replace the 100ms fixed delay with QTimer::singleShot(0, ...) (queued to next event loop iteration, equivalent to Qt.callLater()), and change windowStartUpEffect from EffectOut to EffectNone to skip the 4K fullscreen startup animation rendering. The same EffectOut→EffectNone change is applied to the mirror file shell-launcher-applet/package/launcheritem.qml.

Change Safety Assessment

Code Safety

  • Risk Level: Medium
  • The 100ms delay was introduced by BUG-310945 (focus loss fix) and increased from 1ms→100ms by BUG-323633 (visual glitch fix). Reducing to 0ms (queued) preserves the delayed-switch mechanism but may re-trigger BUG-323633's visual glitch — requires runtime verification.
  • EffectOut was introduced for developer-center#10322 fullscreen open/close animation. Changing to EffectNone intentionally removes this animation to eliminate 4K rendering overhead.

Business Impact Scope

Affected module: Launcher mode switching (fullscreen ↔ windowed). Users on 4K displays will experience faster mode switching. Side effect: fullscreen window no longer plays startup animation (window appears/disappears directly instead of animated transition). Potential regression: window flicker on fullscreen→windowed switch (BUG-323633) needs verification.

Verification Suggestion

Test fullscreen↔windowed switching on 4K (verify stutter improvement, target <1s) and 1080p (verify no regression). Specifically check for window flicker or focus loss on fullscreen→windowed transition.

⚠️ Reviewer Notice — BUG-323633 Regression Risk

The 100ms→0ms delay change may re-introduce the visual glitch (window flicker) that BUG-323633 originally fixed. Reviewers must verify on a 4K display that fullscreen→windowed switching does not exhibit focus jitter or window flicker. If the glitch recurs, the debounce mechanism (e.g., restore a short singleShot delay or use an alternative debounce approach) must be added back before merging.


根因分析

启动器模式切换使用两个独立的 ApplicationWindow 实例,通过 visible 绑定互斥显示。在 4K 分辨率下,目标窗口需从零渲染全部内容,StyledBehindWindowBlur 实时模糊(Main.qml:220,246)和 EffectOut 启动特效(Main.qml:319)叠加渲染开销。此外,100ms 人工延迟(launchercontroller.cpp:274,QTimer::singleShot(100, ...))阻塞切换流程。以上因素叠加导致 4K 下主线程阻塞约 2s。

修复方案

将 100ms 固定延迟替换为 QTimer::singleShot(0, ...)(排队到下一事件循环执行,等价于 Qt.callLater()),并将 windowStartUpEffect 从 EffectOut 改为 EffectNone,跳过 4K 全屏启动特效渲染。镜像文件 shell-launcher-applet/package/launcheritem.qml 同步修改 EffectOut→EffectNone。

改动安全评估

代码安全评估

  • 风险等级: 中风险
  • 100ms 延迟由 BUG-310945(焦点丢失修复)引入,后由 BUG-323633(视觉故障修复)从 1ms 增至 100ms。降至 0ms(排队执行)保留了延迟切换机制,但可能复现 BUG-323633 的视觉故障——需运行时验证。
  • EffectOut 由 developer-center#10322 引入用于全屏开合动画。改为 EffectNone 是有意移除该动画以消除 4K 渲染开销。

业务影响范围

受影响模块:启动器模式切换(全屏↔窗口)。4K 屏幕用户将体验到更快的模式切换。副作用:全屏窗口不再播放启动动画(窗口直接出现/消失而非动画过渡)。潜在回归:全屏→窗口切换时可能出现窗口闪烁(BUG-323633),需验证。

验证建议

在 4K 分辨率下测试全屏↔窗口切换(验证卡顿改善,目标 <1s),在 1080p 下测试无回归。重点检查全屏→窗口切换时是否有窗口闪烁或焦点丢失。

⚠️ Reviewer 注意事项 — BUG-323633 回归风险

100ms→0ms 延迟改动可能重新触发 BUG-323633 原本修复的视觉故障(窗口闪烁)。Review 人必须在 4K 环境下验证全屏→窗口切换是否出现焦点抖动或窗口闪烁。若复现,需在合入前补回防抖手段(如恢复短延迟 singleShot 或采用替代防抖方案)。

PMS: BUG-354837

Summary by Sourcery

Improve launcher mode switching responsiveness by eliminating unnecessary delay and fullscreen startup animation overhead.

Bug Fixes:

  • Reduce stutter during fullscreen-to-windowed launcher switching, particularly on 4K displays.

Enhancements:

  • Remove the fullscreen startup animation to reduce rendering overhead during launcher mode transitions.

Tests:

  • Verify fullscreen and windowed switching on 4K and 1080p displays, including focus retention and absence of flicker.

1. Root cause: dual ApplicationWindow visible-toggle re-renders from
   scratch on 4K; 100ms artificial delay in setCurrentFrameToWindowedFrame
   plus EffectOut startup animation compound main-thread blocking ~2s
2. Fix: replace QTimer::singleShot(100,...) with singleShot(0,...) to
   queue on next event loop iteration without fixed delay; change
   windowStartUpEffect from EffectOut to EffectNone to skip 4K fullscreen
   startup animation rendering
3. Impact: fullscreen-windowed mode switch is faster; fullscreen window
   no longer plays startup animation; potential regression of BUG-323633
   visual glitch needs runtime verification

Log: Reduce launcher mode switch stutter on 4K screens

Influence:
1. Test fullscreen-windowed switch on 4K for stutter improvement
2. Test fullscreen-windowed switch on 1080p for no regression
3. Verify no window flicker or focus loss on fullscreen-windowed switch
4. Verify fullscreen window shows/hides correctly without animation

fix: 降低4K屏幕下全屏窗口模式切换卡顿

1. 根因:双 ApplicationWindow 通过 visible 互斥切换在 4K 下需从零渲染,
   100ms 人工延迟叠加 EffectOut 启动特效渲染导致主线程阻塞约 2s
2. 方案:将 QTimer::singleShot(100,...) 改为 singleShot(0,...),
   排队到下一事件循环执行无固定延迟;将 windowStartUpEffect 从
   EffectOut 改为 EffectNone,跳过 4K 全屏启动特效渲染
3. 影响:全屏-窗口模式切换速度提升;全屏窗口不再播放启动动画;
   BUG-323633 视觉故障可能回归,需运行时验证

Log: 降低启动器在4K屏幕下模式切换的卡顿

Influence:
1. 在4K分辨率下测试全屏-窗口模式切换卡顿是否改善
2. 在1080p分辨率下测试全屏-窗口模式切换无回归
3. 验证全屏-窗口切换时无窗口闪烁或焦点丢失
4. 验证全屏窗口正常显示/隐藏(无动画过渡)

PMS: BUG-354837
@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

Reduces fullscreen/windowed switching stutter, especially on 4K displays, by replacing the 100 ms switch delay with queued execution and disabling the fullscreen startup animation in both launcher window implementations. Reviewers should verify that focus loss or window flicker from the shorter delay does not regress, particularly during fullscreen-to-windowed transitions.

Sequence diagram for faster fullscreen-to-windowed switching

sequenceDiagram
    participant LauncherController
    participant EventLoop
    participant Window

    LauncherController->>Window: setVisible(false)
    LauncherController->>EventLoop: QTimer.singleShot(0)
    EventLoop-->>LauncherController: queued callback
    LauncherController->>Window: setCurrentFrame("WindowedFrame")
    LauncherController->>Window: setVisible(true)
Loading

File-Level Changes

Change Details Files
Remove the fixed mode-switch delay while preserving queued execution on the next event-loop turn.
  • Change the windowed-frame transition timer from 100 ms to 0 ms.
  • Retain the existing sequence of hiding the current frame, switching frames, and showing the target frame.
launchercontroller.cpp
Disable fullscreen startup animations to reduce rendering work during mode switches.
  • Replace the fullscreen window startup effect with no effect.
  • Apply the same setting to the mirrored launcher applet window definition.
qml/Main.qml
shell-launcher-applet/package/launcheritem.qml

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

@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.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次变更旨在修复4K显示器上全屏与窗口模式切换时的卡顿问题,通过将QTimer延迟从100ms改为0ms并禁用窗口启动动画效果来减少视觉卡顿。变更范围小、目的明确,代码风格与现有代码库一致,未发现安全漏洞或质量问题。

📋 变更概要

项目 内容
PR #812
标题 fix: reduce fullscreen-windowed switch stutter on 4K
作者 mhduiy
分支 agent/pms-bug-bot/9fe7b1c0432e → master
修改文件 launchercontroller.cpp, qml/Main.qml, shell-launcher-applet/package/launcheritem.qml
分析模式 全量分析

🔍 详细分析

1. 语法逻辑 ✅

评分: 25/25 ✓ "语法正确,逻辑清晰"

变更分析:

  1. launchercontroller.cpp 第274行:QTimer::singleShot(100, ...) → QTimer::singleShot(0, ...),语法正确,QTimer::singleShot(int, QObject*, lambda) 是合法的 Qt API 调用
  2. qml/Main.qml 第319行:DWindow.windowStartUpEffect: PlatformHandle.EffectOut → PlatformHandle.EffectNone,QML 属性赋值语法正确,EffectNone 是有效的枚举值
  3. shell-launcher-applet/package/launcheritem.qml 第230行:同上,语法正确

潜在问题:
✅ 未发现明显问题

建议: 无


2. 代码质量 ✅

评分: 25/25 ✓ "代码结构清晰,注释完整"

变更分析:

  1. launchercontroller.cpp 第270行已有注释说明函数目的:"首次从全屏切换到窗口时候,会出现焦点丢失抖动问题,从而导致启动器窗口不显示,所以采用此方法处理。"
  2. 同文件第157行已存在 QTimer::singleShot(0, ...) 的使用先例,本次变更与现有代码风格一致
  3. 两个 QML 文件的变更一致,分别针对主应用和 shell applet 的全屏窗口,非重复代码
  4. 无残留调试代码

潜在问题:
✅ 未发现明显问题

建议: 无


3. 代码性能 ✅

评分: 20/20 ✓ "性能良好,资源使用合理"

变更分析:

  1. launchercontroller.cpp:将 QTimer::singleShot 延迟从 100ms 改为 0ms,消除了全屏切换到窗口模式时不必要的 100ms 等待。0ms 仍然会在下一个事件循环迭代中执行,确保 Qt 有机会处理 hide 事件,同时避免了 4K 显示器上因延迟导致的视觉卡顿
  2. qml/Main.qml 和 launcheritem.qml:禁用窗口启动动画效果 (EffectOut → EffectNone),减少了 4K 分辨率下动画渲染的开销,直接解决了切换卡顿问题
  3. 变更与 commit message "reduce fullscreen-windowed switch stutter on 4K" 目的完全一致

潜在问题:
✅ 未发现明显问题

建议: 无


4. 代码安全 🔒

评分: 30/30 ✓ "存在0个安全漏洞"

存在0个安全漏洞

安全分析:

  1. 本次变更不涉及用户输入处理,无注入风险
  2. 不涉及文件路径操作、命令执行、网络请求等安全敏感操作
  3. 不涉及密码学相关代码
  4. 不涉及权限控制或认证逻辑
  5. 仅为性能优化相关的参数调整

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

安全漏洞详情:
✅ 未发现安全漏洞

建议: 无


📈 评分汇总

维度 评分 满分 结果
语法逻辑 25 25 ✓ 通过
代码质量 25 25 ✓ 通过
代码性能 20 20 ✓ 通过
代码安全 30 30 ✓ 通过
总分 100 100 ✓ 通过

🔧 OCR 审查结果

项目 结果
审查状态 已完成
审查文件数 1
发现问题数 0
审查结论 No comments generated. Looks good to me.

本报告由 AI 代码审查工具自动生成

@mhduiy

mhduiy commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

没有根本解决问题,这个是性能问题

@mhduiy
mhduiy marked this pull request as draft September 15, 2026 08:07
@mhduiy mhduiy closed this Sep 15, 2026
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