Skip to content

fix(wallpaper): switching wallpapers is too slow.#1003

Open
zzxyb wants to merge 1 commit into
linuxdeepin:masterfrom
zzxyb:wallpaper
Open

fix(wallpaper): switching wallpapers is too slow.#1003
zzxyb wants to merge 1 commit into
linuxdeepin:masterfrom
zzxyb:wallpaper

Conversation

@zzxyb

@zzxyb zzxyb commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Add synchronization for wallpaper loading and surface commit completion.
Refine the wallpaper disposal logic to prevent memory and video memory leaks, and avoid incorrect video
decoding resource usage that causes video stuttering. Added WallpaperSwitcherItem to encapsulate the desktop wallpaper switching animation.

Log: fix switching wallpapers is too slow
PMS: BUG-363035
Influence: Wallpaper display and updates

Add synchronization for wallpaper loading and surface
commit completion.
Refine the wallpaper disposal logic to prevent memory
and video memory leaks, and avoid incorrect video
decoding resource usage that causes video stuttering.
Added `WallpaperSwitcherItem` to encapsulate the desktop
wallpaper switching animation.

Log: fix switching wallpapers is too slow
PMS: BUG-363035
Influence: Wallpaper display and updates
@zzxyb zzxyb requested a review from zccrs June 17, 2026 09:55
@zzxyb zzxyb added the bug Something isn't working label Jun 17, 2026

@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 @zzxyb, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: zccrs, zzxyb

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

EN: This PR targets slow wallpaper switching by synchronizing “wallpaper file loaded” with compositor-side surface readiness, refining lifecycle/disposal to reduce memory/VRAM leaks and stutter, and introducing a dedicated QML item to drive wallpaper cross-fade transitions.

ZH: 本 PR 通过引入“壁纸文件加载完成”与合成器侧 surface 就绪的同步机制、优化资源释放以减少内存/显存泄漏与卡顿,并新增专用的壁纸切换动画组件来改善切换速度与稳定性。

Changes:

  • EN: Add a “loaded/ready” handshake between wallpaper-factory client and compositor wallpaper surface; ZH: 增加 loaded/ready 同步握手以保证加载与提交完成后再进入切换流程。
  • EN: Rework desktop wallpaper switching from two QML Wallpaper items to a C++ WallpaperSwitcherItem; ZH: 用 C++ WallpaperSwitcherItem 封装桌面壁纸切换动画逻辑,替代旧的双 Wallpaper QML 方案。
  • EN: Improve runtime behavior (async image loading, logging integration); ZH: 增强运行时表现(图片异步加载、日志接入)。

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
wallpaper-factory/wallpaperwindow.h Add loaded state API/signals for load synchronization.
wallpaper-factory/wallpaperwindow.cpp Track per-window loaded flag and manage shell integration lifetime.
wallpaper-factory/treelandwallpapernotifierclient.cpp Mark wallpaper “loaded” on image/video readiness; track source via dynamic property.
wallpaper-factory/qwaylandwallpapersurface.cpp Send protocol ready() only after file loaded (and protocol version supports it).
wallpaper-factory/qwaylandwallpapersurface_p.h Add slot for handling file-loaded notification.
wallpaper-factory/qwaylandwallpapershellintegration.cpp Simplify teardown via destroy().
wallpaper-factory/main.cpp Register DTK journal logging appender.
wallpaper-factory/Image.qml Enable asynchronous image loading.
wallpaper-factory/CMakeLists.txt Add Dtk6::Core dependency for logging.
src/wallpaper/wallpaperswitcheritem.h Introduce WallpaperSwitcherItem QML element API.
src/wallpaper/wallpaperswitcheritem.cpp Implement slot-based wallpaper cross-fade and readiness-gated fade-in.
src/wallpaper/wallpaperitem.h Remove switching-related properties/signals; add updateSurface() API and protected ctor.
src/wallpaper/wallpaperitem.cpp Adjust update scheduling to be readiness-driven; add surface-added handling.
src/seat/helper.h Grant WallpaperSwitcherItem friend access (for manager interactions).
src/modules/wallpaper/wallpapershellinterfacev1.h Add ready signal + wallpaperReady(); adjust destroy notification signal shape.
src/modules/wallpaper/wallpapershellinterfacev1.cpp Track wallpaper readiness and emit ready after initial mapping/commit.
src/core/qml/PrimaryOutput.qml Switch desktop wallpaper QML to use WallpaperSwitcher.
src/CMakeLists.txt Build and export the new wallpaper switcher QML type.

Comment on lines +33 to +50
WallpaperSwitcherItem::WallpaperSwitcherItem(QQuickItem *parent)
: QQuickItem(parent)
{
m_currentSlot = new WallpaperSlot(parentItem());

connect(Helper::instance()->m_wallpaperManager,
&WallpaperManager::updateWallpaper,
this,
&WallpaperSwitcherItem::handleWallpaperUpdate);
connect(Helper::instance()->shellHandler()->wallpaperShell(),
&TreelandWallpaperShellInterfaceV1::wallpaperSurfaceAdded,
this,
&WallpaperSwitcherItem::handleWallpaperUpdate);
connect(Helper::instance()->workspace(),
&Workspace::workspaceAdded,
this,
&WallpaperSwitcherItem::handleWorkspaceAdded);
}
Comment on lines +171 to +177
void WallpaperSwitcherItem::switchToNewSlot(const QString &targetSource)
{
auto *newSlot = new WallpaperSlot(parentItem());
newSlot->setOpacity(0);
newSlot->setOutput(m_output);
newSlot->setWorkspace(m_workspace);

Comment on lines +193 to +195
connect(fadeOut, &QPropertyAnimation::finished, this, &WallpaperSwitcherItem::onAnimationFinished);
QObject::connect(fadeOut, &QPropertyAnimation::finished, fadeOut, &QObject::deleteLater);
fadeOut->start(QAbstractAnimation::DeleteWhenStopped);
Comment on lines +219 to +220
QObject::connect(anim, &QPropertyAnimation::finished, anim, &QObject::deleteLater);
anim->start(QAbstractAnimation::DeleteWhenStopped);
Comment on lines +94 to +99
connect(image,
&QQuickAnimatedImage::statusChanged,
window, [window](QQuickImageBase::Status status){
if (status == QQuickImageBase::Ready)
Q_EMIT window->setLoaded(true);
});
Comment on lines +116 to +120
connect(video,
&MpvVideoItem::fileLoaded,
window,[window]() {
Q_EMIT window->setLoaded(true);
}, Qt::SingleShotConnection);
Comment on lines +164 to +179
void TreelandWallpaperSurfaceInterfaceV1Private::ready(Resource *resource)
{
if (wallpaperReady) {
return;
}

if (q->wSurface()->mapped()) {
wallpaperReady = true;
Q_EMIT q->ready();
} else {
QObject::connect(q->wSurface(), &WSurface::commit, q, [this](quint32 committedState) {
wallpaperReady = true;
Q_EMIT q->ready();
}, Qt::SingleShotConnection);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants