diff --git a/src/plugin-qt/wallpapercache/CMakeLists.txt b/src/plugin-qt/wallpapercache/CMakeLists.txt index 96c5b3c1..f966f5b9 100644 --- a/src/plugin-qt/wallpapercache/CMakeLists.txt +++ b/src/plugin-qt/wallpapercache/CMakeLists.txt @@ -65,3 +65,6 @@ install(FILES ${MISC_DIR}/deepin-service-plugin@org.deepin.dde.WallpaperCache.service.d/override.conf DESTINATION lib/systemd/system/deepin-service-plugin@org.deepin.dde.WallpaperCache.service.d/ ) +# Pre-generate blur cache for default wallpaper at boot (avoid first-boot cold-start delay) +install(PROGRAMS ${MISC_DIR}/wallpaper-cache-preheat.sh DESTINATION ${CMAKE_INSTALL_LIBDIR}/deepin-service-manager/) +install(FILES ${MISC_DIR}/dde-wallpaper-cache-preheat.service DESTINATION lib/systemd/system/) diff --git a/src/plugin-qt/wallpapercache/misc/dde-wallpaper-cache-preheat.service b/src/plugin-qt/wallpapercache/misc/dde-wallpaper-cache-preheat.service new file mode 100644 index 00000000..8ade82c3 --- /dev/null +++ b/src/plugin-qt/wallpapercache/misc/dde-wallpaper-cache-preheat.service @@ -0,0 +1,16 @@ +[Unit] +Description=Pre-generate wallpaper blur cache for default wallpaper +Documentation=https://pms.uniontech.com/bug-view-335593.html +After=dbus.service +Before=display-manager.service +ConditionPathExists=/usr/share/backgrounds/default_background.jpg +ConditionPathExists=!/var/cache/dde-wallpaper-cache/blur + +[Service] +Type=oneshot +ExecStart=/usr/lib/deepin-service-manager/wallpaper-cache-preheat.sh +TimeoutStartSec=60 +RemainAfterExit=no + +[Install] +WantedBy=multi-user.target diff --git a/src/plugin-qt/wallpapercache/misc/wallpaper-cache-preheat.sh b/src/plugin-qt/wallpapercache/misc/wallpaper-cache-preheat.sh new file mode 100755 index 00000000..76d66f8e --- /dev/null +++ b/src/plugin-qt/wallpapercache/misc/wallpaper-cache-preheat.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# Pre-generate blur cache for the default wallpaper to avoid D-Bus +# on-demand activation cold-start delay on first boot. +# +# The wallpapercache plugin (org.deepin.dde.ImageEffect1) is loaded +# on-demand by deepin-service-manager. On a freshly installed system +# the blur cache directory is empty, so the first Get() call must +# cold-start the service AND generate the blur image from scratch, +# which can exceed the greeter client's timeout. +# +# This script triggers the service early in boot (before the display +# manager) so that the blur file is cached on disk by the time the +# greeter requests it. Failures are non-fatal — the greeter will +# still fall back to the original wallpaper. + +DEFAULT_WALLPAPER="/usr/share/backgrounds/default_background.jpg" + +[ -f "$DEFAULT_WALLPAPER" ] || exit 0 + +# Trigger D-Bus activation of the wallpapercache plugin and request +# blur generation for the default wallpaper. Use a generous timeout +# (30 s) to accommodate cold-start + image processing on slow hardware. +dbus-send --system --print-reply --reply-timeout=30000 \ + --dest=org.deepin.dde.ImageEffect1 \ + /org/deepin/dde/ImageEffect1 \ + org.deepin.dde.ImageEffect1.Get \ + string:"" string:"$DEFAULT_WALLPAPER" >/dev/null 2>&1 || true + +exit 0