[PR #14244] [MERGED] fix(Session): don't query DB if queue hasn't changed #13900

Closed
opened 2026-02-07 07:21:01 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jellyfin/jellyfin/pull/14244
Author: @Skaytacium
Created: 6/8/2025
Status: Merged
Merged: 6/10/2025
Merged by: @crobibero

Base: masterHead: master


📝 Commits (4)

  • 3fd5abf fix(Session): doesn't query DB if queue hasn't changed
  • 4348470 fix(Session): properly compares queues
  • 9bf3126 Update QueueItem.cs
  • 6c89445 Update QueueItem.cs

📊 Changes

2 files changed (+6 additions, -7 deletions)

View changed files

📝 Emby.Server.Implementations/Session/SessionManager.cs (+1 -1)
📝 MediaBrowser.Model/Session/QueueItem.cs (+5 -6)

📄 Description

Background and additional debugging details are given in the mentioned issue (jellyfin/jellyfin#13628), and jellyfin/jellyfin-mpv-shim#265

Changes
Checks if the session's nowPlayingQueue has changed since the last ProgressUpdate event, and if so, then queries the database for data transfer objects.

Issues
fixes #13628
fixes jellyfin/jellyfin-mpv-shim#265

Note
The last time I used C# was 3 years ago, so I don't know how to exactly get around the following. SequenceEqual uses the equality operator to check each item in an IEnumerable<T>, which compares the references and not the actual values. In this case, the values are more important, not the memory location. Changing MediaBrowser.Model/Session/QueueItem.cs to the following would be ideal:

#nullable disable
#pragma warning disable CS1591

using System;

namespace MediaBrowser.Model.Session
{
    public class QueueItem : IEquatable<QueueItem>
    {
        public Guid Id { get; set; }

        public string PlaylistItemId { get; set; }

        public bool Equals(QueueItem? other) => Id == other.Id && PlaylistItemId == other.PlaylistItemId;
    }
}

But the project's settings do not allow this. If there is a better way to do this, then it would be ideal, because currently the queues remain unequal sometimes even when the value is the same, due to memory location changes probably. That would also make it possible to get rid of the final && updateLastCheckInTime conditional.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/jellyfin/jellyfin/pull/14244 **Author:** [@Skaytacium](https://github.com/Skaytacium) **Created:** 6/8/2025 **Status:** ✅ Merged **Merged:** 6/10/2025 **Merged by:** [@crobibero](https://github.com/crobibero) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (4) - [`3fd5abf`](https://github.com/jellyfin/jellyfin/commit/3fd5abf61f2437ce4f68eb9697b947df8130bc30) fix(Session): doesn't query DB if queue hasn't changed - [`4348470`](https://github.com/jellyfin/jellyfin/commit/4348470e00adec4a9e6747f06c4ce3f50e6b51e1) fix(Session): properly compares queues - [`9bf3126`](https://github.com/jellyfin/jellyfin/commit/9bf31268820d4598b2e3291acd1f8431456c1311) Update QueueItem.cs - [`6c89445`](https://github.com/jellyfin/jellyfin/commit/6c89445b68707c046fa7e68c4d1b14a80c3275bd) Update QueueItem.cs ### 📊 Changes **2 files changed** (+6 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `Emby.Server.Implementations/Session/SessionManager.cs` (+1 -1) 📝 `MediaBrowser.Model/Session/QueueItem.cs` (+5 -6) </details> ### 📄 Description Background and additional debugging details are given in the mentioned issue (jellyfin/jellyfin#13628), and jellyfin/jellyfin-mpv-shim#265 <!-- Ensure your title is short, descriptive, and in the imperative mood (Fix X, Change Y, instead of Fixed X, Changed Y). For a good inspiration of what to write in commit messages and PRs please review https://chris.beams.io/posts/git-commit/ and our documentation. --> **Changes** Checks if the session's `nowPlayingQueue` has changed since the last `ProgressUpdate` event, and if so, then queries the database for data transfer objects. **Issues** fixes #13628 fixes jellyfin/jellyfin-mpv-shim#265 **Note** The last time I used C# was 3 years ago, so I don't know how to exactly get around the following. `SequenceEqual` uses the equality operator to check each item in an `IEnumerable<T>`, which compares the references and not the actual values. In this case, the values are more important, not the memory location. Changing `MediaBrowser.Model/Session/QueueItem.cs` to the following would be ideal: ```c# #nullable disable #pragma warning disable CS1591 using System; namespace MediaBrowser.Model.Session { public class QueueItem : IEquatable<QueueItem> { public Guid Id { get; set; } public string PlaylistItemId { get; set; } public bool Equals(QueueItem? other) => Id == other.Id && PlaylistItemId == other.PlaylistItemId; } } ``` But the project's settings do not allow this. If there is a better way to do this, then it would be ideal, because currently the queues remain unequal sometimes even when the value is the same, due to memory location changes probably. That would also make it possible to get rid of the final `&& updateLastCheckInTime` conditional. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-07 07:21:01 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/jellyfin#13900