WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
151256
[GStreamer] Use RunLoop instead of GMainLoop in AudioFileReaderGStreamer
https://bugs.webkit.org/show_bug.cgi?id=151256
Summary
[GStreamer] Use RunLoop instead of GMainLoop in AudioFileReaderGStreamer
Carlos Garcia Campos
Reported
2015-11-13 03:23:41 PST
We could use the platform abstraction instead of GMainLoop directly.
Attachments
Patch
(22.12 KB, patch)
2015-11-13 03:30 PST
,
Carlos Garcia Campos
no flags
Details
Formatted Diff
Diff
Updated patch
(21.97 KB, patch)
2015-11-16 01:00 PST
,
Carlos Garcia Campos
zan
: review+
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Carlos Garcia Campos
Comment 1
2015-11-13 03:30:37 PST
Created
attachment 265476
[details]
Patch
WebKit Commit Bot
Comment 2
2015-11-13 03:33:14 PST
Attachment 265476
[details]
did not pass style-queue: ERROR: Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:350: More than one command on the same line [whitespace/newline] [4] Total errors found: 1 in 4 files If any of these errors are false positives, please file a bug against check-webkit-style.
Zan Dobersek
Comment 3
2015-11-14 11:48:25 PST
Comment on
attachment 265476
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=265476&action=review
> Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:380 > + if (isMainThread()) { > + RefPtr<AudioBus> returnValue; > + auto threadID = createThread("AudioFileReader", [&returnValue, filePath, mixToMono, sampleRate] { > + returnValue = AudioFileReader(filePath).createBus(sampleRate, mixToMono); > + }); > + waitForThreadCompletion(threadID); > + > + return returnValue; > + }
Would RunLoop::run() not set up a nested main loop in case of running this in the main thread? What about the cases where the bus is created in a non-main WebWorker thread that's also managed via RunLoop, wouldn't that set up the nested loop?
Carlos Garcia Campos
Comment 4
2015-11-15 23:35:25 PST
(In reply to
comment #3
)
> Comment on
attachment 265476
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=265476&action=review
> > > Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:380 > > + if (isMainThread()) { > > + RefPtr<AudioBus> returnValue; > > + auto threadID = createThread("AudioFileReader", [&returnValue, filePath, mixToMono, sampleRate] { > > + returnValue = AudioFileReader(filePath).createBus(sampleRate, mixToMono); > > + }); > > + waitForThreadCompletion(threadID); > > + > > + return returnValue; > > + } > > Would RunLoop::run() not set up a nested main loop in case of running this > in the main thread?
Yes, but with the same main context, we need a different one to avoid deadlocks. Phil wrote the original code, so he should know the details.
> What about the cases where the bus is created in a non-main WebWorker thread > that's also managed via RunLoop, wouldn't that set up the nested loop?
In that case a new RunLoop is created for the current thread. If those threads already a have a RunLoop running maybe we should always use a dedicated thread, though.
Zan Dobersek
Comment 5
2015-11-15 23:45:05 PST
Comment on
attachment 265476
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=265476&action=review
>>> Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:380 >>> + } >> >> Would RunLoop::run() not set up a nested main loop in case of running this in the main thread? >> >> What about the cases where the bus is created in a non-main WebWorker thread that's also managed via RunLoop, wouldn't that set up the nested loop? > > Yes, but with the same main context, we need a different one to avoid deadlocks. Phil wrote the original code, so he should know the details.
My bad, workers don't use RunLoop, they use a custom queue.
Zan Dobersek
Comment 6
2015-11-15 23:48:18 PST
Comment on
attachment 265476
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=265476&action=review
>>>> Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:380 >>>> + } >>> >>> Would RunLoop::run() not set up a nested main loop in case of running this in the main thread? >>> >>> What about the cases where the bus is created in a non-main WebWorker thread that's also managed via RunLoop, wouldn't that set up the nested loop? >> >> Yes, but with the same main context, we need a different one to avoid deadlocks. Phil wrote the original code, so he should know the details. > > My bad, workers don't use RunLoop, they use a custom queue.
On that note, the new code goes on to create a RunLoop object in the worker thread. I'd rather avoid that, and just use a new thread regardless where the AudioBus creation is requested (the main thread or a worker thread).
Carlos Garcia Campos
Comment 7
2015-11-15 23:55:29 PST
(In reply to
comment #6
)
> Comment on
attachment 265476
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=265476&action=review
> > >>>> Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:380 > >>>> + } > >>> > >>> Would RunLoop::run() not set up a nested main loop in case of running this in the main thread? > >>> > >>> What about the cases where the bus is created in a non-main WebWorker thread that's also managed via RunLoop, wouldn't that set up the nested loop? > >> > >> Yes, but with the same main context, we need a different one to avoid deadlocks. Phil wrote the original code, so he should know the details. > > > > My bad, workers don't use RunLoop, they use a custom queue. > > On that note, the new code goes on to create a RunLoop object in the worker > thread. > > I'd rather avoid that, and just use a new thread regardless where the > AudioBus creation is requested (the main thread or a worker thread).
Ok, it's definitely safer and makes the code simpler.
Carlos Garcia Campos
Comment 8
2015-11-16 01:00:19 PST
Created
attachment 265573
[details]
Updated patch Use always a helper thread
WebKit Commit Bot
Comment 9
2015-11-16 01:03:04 PST
Attachment 265573
[details]
did not pass style-queue: ERROR: Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:350: More than one command on the same line [whitespace/newline] [4] Total errors found: 1 in 4 files If any of these errors are false positives, please file a bug against check-webkit-style.
Zan Dobersek
Comment 10
2015-11-16 01:13:19 PST
Comment on
attachment 265573
[details]
Updated patch View in context:
https://bugs.webkit.org/attachment.cgi?id=265573&action=review
> Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:296 > + m_pipeline = gst_pipeline_new(nullptr);
Should the returned pointer be adopted?
> Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:312 > + gst_message_unref(message);
This was leaking before, was it not?
Carlos Garcia Campos
Comment 11
2015-11-16 01:40:49 PST
(In reply to
comment #10
)
> Comment on
attachment 265573
[details]
> Updated patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=265573&action=review
> > > Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:296 > > + m_pipeline = gst_pipeline_new(nullptr); > > Should the returned pointer be adopted?
No, it's a floating ref we should consume.
> > Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:312 > > + gst_message_unref(message); > > This was leaking before, was it not?
No, when using the message signal, gst unrefs the message, when using the sync handler, you must unref it when returning DROP.
Carlos Garcia Campos
Comment 12
2015-11-17 01:57:54 PST
Committed
r192511
: <
http://trac.webkit.org/changeset/192511
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug