Skip to content

fix(idle): audio-based idle inhibit not working consistently outside fullscreen #120

@bnema

Description

@bnema

Description

When playing a video on YouTube (not in fullscreen), the computer can still idle and lock the screen. The sound-based detection for preventing screen lock doesn't work consistently. It works correctly when in fullscreen mode.

Current Behavior

  1. Play a YouTube video in normal (non-fullscreen) mode
  2. Video has audio playing
  3. After idle timeout, screen locks despite audio playback
  4. In fullscreen mode, idle inhibit works correctly

Expected Behavior

Audio playback should prevent screen lock regardless of whether the video is in fullscreen mode or not.

Technical Context

Relevant Files:

  • internal/infrastructure/idle/portal_inhibitor.go - XDG Desktop Portal idle inhibition
  • internal/infrastructure/webkit/webview.go:621-637 - Audio state detection via notify::is-playing-audio
  • internal/ui/coordinator/content.go:1577-1629 - setupIdleInhibitionHandlers() wiring

Current Implementation:

// Fullscreen handling - works
OnEnterFullscreen: idleInhibitor.Inhibit(ctx, "Fullscreen video playback")
OnLeaveFullscreen: idleInhibitor.Uninhibit(ctx)

// Audio handling - inconsistent
OnAudioStateChanged(playing bool):
    if playing: idleInhibitor.Inhibit(ctx, "Media playback")
    else: idleInhibitor.Uninhibit(ctx)

Potential Issues:

  1. WebKit's is-playing-audio signal may not fire consistently for all media types
  2. The signal might not trigger for embedded players (YouTube uses iframe)
  3. Audio state changes might be missed during page transitions
  4. Refcount issues if audio starts/stops rapidly
  5. D-Bus portal request may not complete before audio state changes

Suggested Investigation

  1. Add logging to OnAudioStateChanged to verify signal is firing
  2. Check if IsPlayingAudio() returns correct state during playback
  3. Verify D-Bus inhibit request completes successfully
  4. Test with different video sites to isolate YouTube-specific vs general issue
  5. Check if iframe isolation affects audio detection
  6. Consider polling-based fallback for audio state

Debug Commands

# Check current inhibit state
gdbus call --session --dest org.freedesktop.portal.Desktop --object-path /org/freedesktop/portal/desktop --method org.freedesktop.DBus.Properties.GetAll org.freedesktop.portal.Inhibit

# Monitor D-Bus signals
dbus-monitor --session "interface='org.freedesktop.portal.Request'"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions