Skip to content

Commit

Permalink
[GStreamer][WebCodecs][Debug] ASSERTs in video encoder
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=264935

Reviewed by Xabier Rodriguez-Calvar.

Pass owned strings to WorkQueue callbacks and make a copy of the codecName string in the internal
encoders, as attempts to fix flaky crashes that I am unable to reproduce here.

* Source/WebCore/platform/audio/gstreamer/AudioEncoderGStreamer.cpp:
(WebCore::GStreamerAudioEncoder::create):
* Source/WebCore/platform/graphics/gstreamer/VideoEncoderGStreamer.cpp:
(WebCore::GStreamerVideoEncoder::create):

Canonical link: https://commits.webkit.org/270883@main
  • Loading branch information
philn committed Nov 17, 2023
1 parent 98da47e commit 0bb4da6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class GStreamerInternalAudioEncoder : public ThreadSafeRefCountedAndCanMakeThrea
private:
GStreamerInternalAudioEncoder(const String& codecName, AudioEncoder::DescriptionCallback&&, AudioEncoder::OutputCallback&&, AudioEncoder::PostTaskCallback&&, GRefPtr<GstElement>&&);

const String m_codecName;
String m_codecName;
AudioEncoder::DescriptionCallback m_descriptionCallback;
AudioEncoder::OutputCallback m_outputCallback;
AudioEncoder::PostTaskCallback m_postTaskCallback;
Expand All @@ -88,8 +88,9 @@ void GStreamerAudioEncoder::create(const String& codecName, const AudioEncoder::
if (codecName.startsWith("pcm-"_s)) {
auto components = codecName.split('-');
if (components.size() != 2) {
postTaskCallback([callback = WTFMove(callback), codecName]() mutable {
callback(makeUnexpected(makeString("Invalid LPCM codec string: "_s, codecName)));
auto errorMessage = makeString("Invalid LPCM codec string: "_s, codecName);
postTaskCallback([callback = WTFMove(callback), errorMessage = WTFMove(errorMessage)]() mutable {
callback(makeUnexpected(WTFMove(errorMessage)));
});
return;
}
Expand All @@ -98,8 +99,9 @@ void GStreamerAudioEncoder::create(const String& codecName, const AudioEncoder::
auto& scanner = GStreamerRegistryScanner::singleton();
auto lookupResult = scanner.isCodecSupported(GStreamerRegistryScanner::Configuration::Encoding, codecName);
if (!lookupResult) {
postTaskCallback([callback = WTFMove(callback), codecName]() mutable {
callback(makeUnexpected(makeString("No GStreamer encoder found for codec ", codecName)));
auto errorMessage = makeString("No GStreamer encoder found for codec "_s, codecName);
postTaskCallback([callback = WTFMove(callback), errorMessage = WTFMove(errorMessage)]() mutable {
callback(makeUnexpected(WTFMove(errorMessage)));
});
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class GStreamerInternalVideoEncoder : public ThreadSafeRefCountedAndCanMakeThrea
private:
GStreamerInternalVideoEncoder(const String& codecName, VideoEncoder::DescriptionCallback&&, VideoEncoder::OutputCallback&&, VideoEncoder::PostTaskCallback&&);

const String m_codecName;
String m_codecName;
VideoEncoder::DescriptionCallback m_descriptionCallback;
VideoEncoder::OutputCallback m_outputCallback;
VideoEncoder::PostTaskCallback m_postTaskCallback;
Expand All @@ -90,8 +90,9 @@ void GStreamerVideoEncoder::create(const String& codecName, const VideoEncoder::
registerWebKitGStreamerVideoEncoder();
auto& scanner = GStreamerRegistryScanner::singleton();
if (!scanner.isCodecSupported(GStreamerRegistryScanner::Configuration::Encoding, codecName)) {
postTaskCallback([callback = WTFMove(callback), codecName]() mutable {
callback(makeUnexpected(makeString("No GStreamer encoder found for codec "_s, codecName)));
auto errorMessage = makeString("No GStreamer encoder found for codec "_s, codecName);
postTaskCallback([callback = WTFMove(callback), errorMessage = WTFMove(errorMessage)]() mutable {
callback(makeUnexpected(WTFMove(errorMessage)));
});
return;
}
Expand Down

0 comments on commit 0bb4da6

Please sign in to comment.