Skip to content

Download and install OpenH264 GMP plugin when installing Firefox#58285

Open
Pehrsons wants to merge 2 commits intoweb-platform-tests:masterfrom
Pehrsons:firefox-openh264
Open

Download and install OpenH264 GMP plugin when installing Firefox#58285
Pehrsons wants to merge 2 commits intoweb-platform-tests:masterfrom
Pehrsons:firefox-openh264

Conversation

@Pehrsons
Copy link
Contributor

@Pehrsons Pehrsons commented Mar 5, 2026

This patch adds a step to download the public OpenH264 GMP plugin from the Cisco CDN during Firefox installation . The correct version is parsed from openh264.json, which is downloaded for the corresponding revision from the Firefox github. The plugin is extracted into the correct folder structure "gmp-gmpopenh264/{version}" inside "browsers/{channel}".

In Firefox.setup_kwargs, the presence of this folder is detected and used to set the environment variable MOZ_GMP_PATH down the line.

This makes OpenH264 available to WebRTC tests, allowing those reliant on H264 to pass.

Pehrsons added 2 commits March 5, 2026 13:09
This patch adds a step to download the public OpenH264 GMP plugin from
the Cisco CDN during Firefox installation . The correct version is parsed
from openh264.json, which is downloaded for the corresponding revision from the
Firefox github. The plugin is extracted into the correct folder structure
"gmp-gmpopenh264/{version}" inside "browsers/{channel}".

In Firefox.setup_kwargs, the presence of this folder is detected and
used to set the environment variable MOZ_GMP_PATH down the line.

This makes OpenH264 available to WebRTC tests, allowing those reliant on H264 to
pass.
Like for webdriver this patch adds a path to prompt to allow downloading
the OpenH264 plugin for Firefox if not already installed.
Copy link
Contributor

@jgraham jgraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So basically I think this looks fine, but I was initially a bit confused about the use of the FirefoxPrefs class to do something unrelated to prefs. Could we clean it up with something like the following:

diff --git a/tools/wpt/browser.py b/tools/wpt/browser.py
index 7fae46a5e88..4f7b5576156 100644
--- a/tools/wpt/browser.py
+++ b/tools/wpt/browser.py
@@ -12,7 +12,7 @@ import tempfile
 from abc import ABCMeta, abstractmethod
 from datetime import datetime, timedelta, timezone
 from shutil import which
-from typing import Any, Dict, List, Optional, Tuple
+from typing import Any, Dict, List, Optional, Tuple, Mapping
 from urllib.parse import urlsplit, quote
 
 import html5lib
@@ -201,27 +201,12 @@ class Browser(metaclass=ABCMeta):
         return NotImplemented
 
 
-class FirefoxPrefs:
+class FirefoxVcsResources:
     def __init__(self, logger):
         self.logger = logger
 
     def install_prefs(self, binary: Optional[str], dest: Optional[str] = None, channel: Optional[str] = None) -> str:
-        if binary and not binary.endswith(".apk"):
-            version, channel_, rev = self.get_version_and_channel(binary)
-            if channel is not None and channel != channel_:
-                # Beta doesn't always seem to have the b in the version string, so allow the
-                # manually supplied value to override the one from the binary
-                self.logger.warning("Supplied channel doesn't match binary, using supplied channel")
-            elif channel is None:
-                channel = channel_
-        else:
-            rev = None
-            version = None
-
-        if channel is None:
-            self.logger.warning("No browser channel passed to install_prefs, taking prefs from main branch")
-            channel = "nightly"
-
+        version, channel, rev = self.get_version_and_channel(binary, channel)
         if dest is None:
             dest = os.curdir
 
@@ -250,6 +235,24 @@ class FirefoxPrefs:
 
         return dest
 
+    def get_openh264_data(self, binary: Optional[str], channel: Optional[str]) -> Optional[Mapping[str, Any]]:
+        version, channel, rev = self.get_version_and_channel(binary, channel)
+        ref = self.get_git_ref(version, channel, rev)
+        self.logger.info("Downloading openh264.json from git ref %s" % ref)
+        try:
+            openh264_json: Mapping[str, Any] = json.loads(
+                get_file_github(
+                    "mozilla-firefox/firefox",
+                    ref,
+                    "toolkit/content/gmp-sources/openh264.json",
+                )
+            )
+        except Exception as e:
+            self.logger.warning("Failed to download openh264.json: %s" % e)
+            return None
+
+        return openh264_json
+
     def get_profile_github(self, version: Optional[str], channel: str, dest: str, rev: Optional[str]) -> None:
         """Read the testing/profiles data from firefox source on GitHub"""
 
@@ -284,7 +287,26 @@ class FirefoxPrefs:
             with open(dest_path, "wb") as f:
                 f.write(data)
 
-    def get_version_and_channel(self, binary: str) -> Tuple[Optional[str], str, Optional[str]]:
+    def get_version_and_channel(self, binary: Optional[str], channel: Optional[str]) -> tuple[Optional[str], str, Optional[str]]:
+        if binary and not binary.endswith(".apk"):
+            version, channel_, rev = self.get_binary_version_and_channel(binary)
+            if channel is not None and channel != channel_:
+                # Beta doesn't always seem to have the b in the version string, so allow the
+                # manually supplied value to override the one from the binary
+                self.logger.warning("Supplied channel doesn't match binary, using supplied channel")
+            elif channel is None:
+                channel = channel_
+        else:
+            rev = None
+            version = None
+
+        if channel is None:
+            self.logger.warning("Unable to resolve browser channel, using nightly")
+            channel = "nightly"
+
+        return version, channel, rev
+
+    def get_binary_version_and_channel(self, binary: str) -> Tuple[Optional[str], str, Optional[str]]:
         application_ini_path = os.path.join(os.path.dirname(binary), "application.ini")
         if os.path.exists(application_ini_path):
             try:
@@ -396,7 +418,10 @@ class FirefoxPrefs:
         return max(tags)[1]
 
 
-class FirefoxAndroidPrefs(FirefoxPrefs):
+class FirefoxAndroidVcsResources(FirefoxVcsResources):
+    def get_openh264_data(self, binary: Optional[str], channel: Optional[str]) -> Optional[Mapping[str, Any]]:
+        raise NotImplementedError
+
     def get_git_ref(self, version: Optional[str], channel: str, rev: Optional[str]) -> str:
         if rev is not None:
             return rev
@@ -555,23 +580,9 @@ class Firefox(Browser):
             )
             return None
 
-        prefs = FirefoxPrefs(self.logger)
-        version, channel_, rev = (
-            prefs.get_version_and_channel(binary) if binary else (None, channel, None)
-        )
-        ref = prefs.get_git_ref(version, channel_ if channel is None else channel, rev)
+        openh264_json = FirefoxVcsResources(self.logger).get_openh264_data(binary, channel)
 
-        self.logger.info("Downloading openh264.json from git ref %s" % ref)
-        try:
-            openh264_json = json.loads(
-                get_file_github(
-                    "mozilla-firefox/firefox",
-                    ref,
-                    "toolkit/content/gmp-sources/openh264.json",
-                )
-            )
-        except Exception as e:
-            self.logger.warning("Failed to download openh264.json: %s" % e)
+        if openh264_json is None:
             return None
 
         version = openh264_json["vendors"]["gmp-gmpopenh264"]["version"]
@@ -623,7 +634,7 @@ class Firefox(Browser):
         return openh264_dir
 
     def install_prefs(self, binary, dest=None, channel=None):
-        return FirefoxPrefs(self.logger).install_prefs(binary, dest, channel)
+        return FirefoxVcsResources(self.logger).install_prefs(binary, dest, channel)
 
     def find_binary_path(self, path=None, channel="nightly"):
         """Looks for the firefox binary in the virtual environment"""
@@ -810,7 +821,7 @@ class FirefoxAndroid(Browser):
         return self.download(dest, channel)
 
     def install_prefs(self, binary, dest=None, channel=None):
-        return FirefoxAndroidPrefs(self.logger).install_prefs(binary, dest, channel)
+        return FirefoxAndroidVcsResources(self.logger).install_prefs(binary, dest, channel)
 
     def find_binary(self, venv_path=None, channel=None):
         return self.apk_path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants