Skip to content

feat: add sleep/wake resilience, wallpaper shuffle controls, and stability fixes#212

Open
ziyadhussain23 wants to merge 1 commit intojeffshee:masterfrom
ziyadhussain23:feature/sleep-resume-and-playback-controls
Open

feat: add sleep/wake resilience, wallpaper shuffle controls, and stability fixes#212
ziyadhussain23 wants to merge 1 commit intojeffshee:masterfrom
ziyadhussain23:feature/sleep-resume-and-playback-controls

Conversation

@ziyadhussain23
Copy link
Copy Markdown

Summary

This PR introduces sleep/wake resilience, wallpaper shuffle & playback controls, DING extension compatibility, and several stability fixes to prevent crashes and UI freezes.

9 files changed — 482 insertions, 70 deletions.


Changes

1. Sleep/Wake Resilience (extension.js)

Problem: After system suspend/resume, the GStreamer renderer pipeline becomes stale, causing the entire GNOME Shell UI to freeze for 10–30 seconds on wake.

Solution:

  • Subscribe to org.freedesktop.login1.ManagerPrepareForSleep D-Bus signal.
  • Before sleep: SIGKILL the renderer process immediately to tear down the stale GStreamer pipeline cleanly.
  • After wake: Relaunch the renderer, wait 5 seconds for it to initialize, then issue a setPlay() D-Bus call to resume playback.
  • Add an _isSuspending flag to prevent autoPause from accidentally re-launching the renderer during the suspend window.
  • Suppress the playbackState mismatch handler during startup and wake recovery to prevent the renderer from being force-paused before it is ready.

2. Wallpaper Shuffle & Playback Controls (renderer.js, dbus.js, panelMenu.js)

  • nextWallpaper / previousWallpaper D-Bus methods — enable cycling through wallpapers from external scripts, D-Bus calls, or the panel menu.
  • Shuffle history tracking in the renderer, so previousWallpaper navigates back through recently played files (up to 50 entries).
  • Smooth fade transition between wallpapers using Clutter opacity animation, with a user-configurable fade-duration GSettings key (default: 500 ms).
  • Panel menu enhancements — added a "Previous Wallpaper" button and a label displaying the current wallpaper filename.

3. DING Extension Compatibility (gnomeShellOverride.js)

Problem: When the DING desktop icons extension (ding@rastersoft.com) is enabled alongside Hanabi, disabling/enabling Hanabi throws replaceData.old_get_window_actors is undefined because both extensions override global.get_window_actors.

Solution:

  • Detect if DING is enabled and skip the get_window_actors override to avoid the conflict.
  • Wrap _updateBackgrounds, _updateWorkspacesViews, and blur-my-shell hooks in _reloadBackgrounds() with try-catch for defensive error handling.

4. Disposed Actor Safety (wallpaper.js)

Problem: Race conditions during extension disable or monitor hotplug can cause operations on already-destroyed LiveWallpaper Clutter actors, leading to crashes.

Solution:

  • Add an _isDestroyed flag set on the destroy signal.
  • Guard _applyWallpaper callback and other async operations against destroyed actors.
  • Cancel pending timeouts on destroy to prevent use-after-free.
  • Wrap get_window_actors(false) in _getRenderer() with try-catch.

5. PlaybackState Mismatch Suppression (playbackState.js)

  • Add a suppressMismatch boolean flag that the extension sets during startup (first 5 seconds) and wake recovery to temporarily bypass the isPlayingChanged force-pause logic.
  • This prevents a race where the mismatch handler detects the renderer as "playing" before autoPause has fully initialized, causing an unwanted immediate pause.

6. Preferences & Schema (prefs.js, gschema.xml)

  • Add fade-duration key to GSettings schema (integer, default 500 ms, range 0–5000).
  • Add "Fade Transition Duration" SpinButton to the Wallpaper section of preferences.

Files Changed

File Change
src/extension.js Sleep/wake handler, delayed autoPause, suppressMismatch, SIGKILL renderer
src/renderer/renderer.js Fade transition, shuffle history, next/previous wallpaper methods
src/gnomeShellOverride.js DING compatibility guard, try-catch wrappers
src/panelMenu.js Previous Wallpaper button, wallpaper filename display
src/dbus.js nextWallpaper / previousWallpaper D-Bus wrappers
src/playbackState.js suppressMismatch flag
src/wallpaper.js _isDestroyed guard, timeout cleanup, try-catch
src/prefs.js Fade duration SpinButton
src/schemas/...gschema.xml fade-duration key

Testing

  • Tested on GNOME 47 (Fedora 41 / GJS 1.82).
  • Verified sleep/wake cycle: no UI freeze, video resumes playback automatically.
  • Verified wallpaper shuffle: next/previous cycling works from panel menu and D-Bus.
  • Verified DING extension compatibility: no errors on enable/disable with DING active.
  • Verified extension disable/enable cycle: no disposed actor crashes.

…ility fixes

This commit introduces several features and robustness improvements
to the Hanabi live wallpaper extension:

## Sleep/Wake Resilience
- Add PrepareForSleep D-Bus listener on org.freedesktop.login1.Manager
  to gracefully handle system suspend and resume cycles.
- SIGKILL the renderer process before suspend to avoid stale GStreamer
  pipelines that cause UI freezes on wake.
- Automatically relaunch the renderer and force playback (setPlay) after
  a configurable delay on resume.
- Introduce an _isSuspending guard to prevent autoPause from
  re-launching the renderer during the suspend window.
- Suppress the playbackState mismatch handler during startup and wake to
  prevent the renderer from being force-paused before it is ready.

## Wallpaper Shuffle & Playback Controls
- Add nextWallpaper and previousWallpaper D-Bus methods in dbus.js and
  renderer.js, enabling external scripts and panel controls to cycle
  through wallpapers.
- Implement shuffle history tracking in the renderer so that
  previousWallpaper navigates back through recently played files.
- Add a smooth fade transition between wallpapers using Clutter opacity
  animation, with a user-configurable fade-duration GSettings key.
- Extend panelMenu.js with Previous Wallpaper button and a label
  showing the current wallpaper filename.

## DING Extension Compatibility
- Guard the get_window_actors override in gnomeShellOverride.js so it is
  skipped when the DING (ding@rastersoft.com) extension is enabled,
  preventing 'replaceData.old_get_window_actors is undefined' errors.
- Wrap _updateBackgrounds, _updateWorkspacesViews, and blur-my-shell
  hooks in _reloadBackgrounds with try-catch for defensive error handling.

## Disposed Actor Safety
- Add an _isDestroyed flag to LiveWallpaper in wallpaper.js, set on the
  destroy signal, to guard against operations on disposed Clutter actors.
- Cancel pending timeouts on destroy to prevent use-after-free crashes.
- Wrap get_window_actors(false) calls in _getRenderer with try-catch.

## Preferences & Schema
- Add fade-duration key to GSettings schema (default: 500 ms).
- Add Fade Transition Duration SpinButton to the preferences UI.

## PlaybackState
- Add suppressMismatch flag to playbackState.js to allow the extension
  to temporarily bypass the isPlayingChanged force-pause logic during
  startup and wake recovery windows.

Files changed:
  src/dbus.js
  src/extension.js
  src/gnomeShellOverride.js
  src/panelMenu.js
  src/playbackState.js
  src/prefs.js
  src/renderer/renderer.js
  src/schemas/io.github.jeffshee.hanabi-extension.gschema.xml
  src/wallpaper.js
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.

1 participant