Skip to content

[GLib] Don't initialize GStreamer in the Network process for file loads - #77412

Open
TingPing wants to merge 1 commit into
WebKit:mainfrom
TingPing:pgriffis/network-process-no-gstreamer
Open

TingPing wants to merge 1 commit into
WebKit:mainfrom
TingPing:pgriffis/network-process-no-gstreamer

Conversation

@TingPing

@TingPing TingPing commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

01ee1df

[GLib] Don't initialize GStreamer in the Network process for file loads
https://bugs.webkit.org/show_bug.cgi?id=327967

Reviewed by NOBODY (OOPS!).

For file:// loads, NetworkDataTaskSoup::didGetFileInfo() chooses between the
MIME type from the file's extension and the one GIO sniffed from its content
with MIMETypeRegistry::canShowMIMEType(). For audio, video and application
types that asks the media engines, which initializes GStreamer and reads its
registry in the Network process: about 4 MB of memory and 10 ms of CPU for
loading a file of an unknown type.

Keep audio and video types from the extension as they are, and check other
types without the media engines, with the new
MIMETypeRegistry::canShowNonMediaMIMEType(). The extension's type is kept
rather than the sniffed one because GIO sniffs Ogg files as subtypes such as
audio/x-opus+ogg and video/x-theora+ogg, which GStreamer doesn't register.

The Network process now release-asserts that it never initializes GStreamer.

* Source/WebCore/platform/MIMETypeRegistry.cpp:
(WebCore::MIMETypeRegistry::canShowMIMEType):
(WebCore::MIMETypeRegistry::canShowNonMediaMIMEType):
* Source/WebCore/platform/MIMETypeRegistry.h:
* Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp:
(WebCore::ensureGStreamerInitializedNonWebProcess):
* Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp:
(WebKit::NetworkDataTaskSoup::didGetFileInfo):

01ee1df

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ✅ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ⏳ 🧪 api-mac-debug
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk3-gcc
✅ 🛠 ios-safer-cpp ✅ 🧪 mac-AS-debug-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ⏳ 🧪 mac-intel-wk2 ✅ 🧪 api-gtk
✅ 🧪 vision-wk2 ✅ 🛠 mac-safer-cpp ✅ 🛠 playstation
✅ 🛠 tv ✅ 🧪 mac-site-isolation
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

https://bugs.webkit.org/show_bug.cgi?id=327967

Reviewed by NOBODY (OOPS!).

For file:// loads, NetworkDataTaskSoup::didGetFileInfo() chooses between the
MIME type from the file's extension and the one GIO sniffed from its content
with MIMETypeRegistry::canShowMIMEType(). For audio, video and application
types that asks the media engines, which initializes GStreamer and reads its
registry in the Network process: about 4 MB of memory and 10 ms of CPU for
loading a file of an unknown type.

Keep audio and video types from the extension as they are, and check other
types without the media engines, with the new
MIMETypeRegistry::canShowNonMediaMIMEType(). The extension's type is kept
rather than the sniffed one because GIO sniffs Ogg files as subtypes such as
audio/x-opus+ogg and video/x-theora+ogg, which GStreamer doesn't register.

The Network process now release-asserts that it never initializes GStreamer.

* Source/WebCore/platform/MIMETypeRegistry.cpp:
(WebCore::MIMETypeRegistry::canShowMIMEType):
(WebCore::MIMETypeRegistry::canShowNonMediaMIMEType):
* Source/WebCore/platform/MIMETypeRegistry.h:
* Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp:
(WebCore::ensureGStreamerInitializedNonWebProcess):
* Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp:
(WebKit::NetworkDataTaskSoup::didGetFileInfo):
@TingPing TingPing self-assigned this Oct 17, 2026
@TingPing TingPing added the WebKitGTK Bugs related to the Gtk API layer. label Oct 17, 2026
@TingPing
TingPing marked this pull request as ready for review October 17, 2026 22:18
@TingPing
TingPing requested review from a team and philn as code owners October 17, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WebKitGTK Bugs related to the Gtk API layer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants