Skip to content

Bug 1999999 - Implement per-tab MediaControlKeyManager - #1

Open
razzeee wants to merge 1 commit into
mainfrom
mpris-per-tab
Open

Bug 1999999 - Implement per-tab MediaControlKeyManager#1
razzeee wants to merge 1 commit into
mainfrom
mpris-per-tab

Conversation

@razzeee

@razzeee razzeee commented Oct 25, 2025

Copy link
Copy Markdown
Owner

No description provided.

@razzeee
razzeee force-pushed the mpris-per-tab branch 8 times, most recently from 168c5bb to 4911c90 Compare October 26, 2025 20:14
@razzeee
razzeee requested a review from Copilot November 1, 2025 00:35

Copilot AI 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.

Pull Request Overview

This pull request implements per-tab MPRIS (Media Player Remote Interfacing Specification) support for Firefox on GTK/Linux. Instead of having a single global media control service, each browser tab with media content gets its own MPRIS instance with unique service names and track paths.

  • Refactored MediaControlKeyManager to be tab-specific with instance and tab IDs
  • Modified MPRISServiceHandler to create unique DBus connections per tab
  • Replaced global media control key manager with per-tab managers stored in a map
  • Updated media control routing to direct actions to specific tab controllers

Reviewed Changes

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

Show a summary per file
File Description
widget/gtk/MediaKeysEventSourceFactory.cpp Updated factory function signature to accept instanceId and tabId parameters
widget/gtk/MPRISServiceHandler.h Added member variables for instance/tab tracking and removed service name setting method
widget/gtk/MPRISServiceHandler.cpp Replaced shared bus connection with per-instance connections and simplified service identity generation
widget/MediaKeysEventSourceFactory.h Added conditional compilation for GTK-specific factory signature with IDs
dom/media/mediacontrol/MediaControlService.h Replaced global key manager with per-tab manager map and made notification methods no-ops
dom/media/mediacontrol/MediaControlService.cpp Implemented per-tab manager lifecycle in register/unregister and GetControllerByTabId lookup
dom/media/mediacontrol/MediaControlKeyManager.h Added tab/instance ID members and GetTabController method
dom/media/mediacontrol/MediaControlKeyManager.cpp Updated constructor and routing logic to dispatch actions directly to tab controllers

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread dom/media/mediacontrol/MediaControlService.cpp
Comment thread dom/media/mediacontrol/MediaControlKeyManager.cpp Outdated
Comment thread dom/media/mediacontrol/MediaControlKeyManager.cpp Outdated
Comment thread widget/gtk/MPRISServiceHandler.cpp Outdated
Comment thread dom/media/mediacontrol/MediaControlService.cpp
Comment thread dom/media/mediacontrol/MediaControlService.cpp Outdated
Comment thread dom/media/mediacontrol/MediaControlService.h Outdated
@razzeee
razzeee requested a review from Copilot November 1, 2025 01:21

Copilot AI 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.

Pull Request Overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread widget/gtk/MPRISServiceHandler.cpp
Comment thread dom/media/mediacontrol/MediaControlService.cpp
Comment thread dom/media/mediacontrol/MediaControlKeyManager.cpp Outdated
Comment thread dom/media/mediacontrol/MediaControlKeyManager.cpp Outdated
@razzeee
razzeee requested a review from Copilot November 1, 2025 01:45

Copilot AI 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.

Pull Request Overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (3)

widget/gtk/MPRISServiceHandler.cpp:281

  • The OnNameAcquired method assigns the GDBusConnection pointer without incrementing its reference count. This is inconsistent with the SetConnection method which properly manages reference counting. Either use SetConnection here or add g_object_ref to maintain consistent ownership semantics.
void MPRISServiceHandler::OnNameAcquired(GDBusConnection* aConnection,
                                         const gchar* aName) {
  LOGMPRIS("OnNameAcquired: %s", aName);
  mConnection = aConnection;
}

widget/gtk/MPRISServiceHandler.cpp:1

  • The function name should be std::fmin for C++, but the correct function for double types is std::min in C++. std::fmin is the C math library function. Use std::min from instead for better C++ compatibility and type safety.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-

widget/gtk/MPRISServiceHandler.cpp:1

  • The function name should be std::fmin for C++, but the correct function for double types is std::min in C++. std::fmin is the C math library function. Use std::min from instead for better C++ compatibility and type safety.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread dom/media/mediacontrol/MediaControlService.cpp Outdated
Comment thread widget/gtk/MPRISServiceHandler.cpp
@razzeee
razzeee requested a review from Copilot November 1, 2025 02:09

Copilot AI 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.

Pull Request Overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

widget/gtk/MPRISServiceHandler.cpp:280

  • The OnNameAcquired method assigns aConnection to mConnection without incrementing its reference count. This is inconsistent with SetConnection which properly manages reference counting with g_object_ref. Since OnNameAcquired is called by GLib's bus ownership mechanism and the connection lifetime is managed externally, this could lead to use-after-free issues. Consider using SetConnection(aConnection) instead of direct assignment, or add g_object_ref(aConnection) before the assignment.
  mConnection = aConnection;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread dom/media/mediacontrol/MediaControlKeyManager.cpp
Comment thread dom/media/mediacontrol/MediaControlKeyManager.cpp
@razzeee
razzeee force-pushed the mpris-per-tab branch 5 times, most recently from 9cab43a to 1b4424e Compare November 10, 2025 20:08
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.

2 participants