Closed Bug 1212723 Opened 9 years ago Closed 9 years ago

It seems racy to share mBufferedState among WebMReaders

Categories

(Core :: Audio/Video: Playback, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla44
Tracking Status
firefox44 --- fixed

People

(Reporter: jwwang, Assigned: jwwang)

References

Details

Attachments

(2 files)

https://hg.mozilla.org/mozilla-central/file/a45d680f073f/dom/media/webm/WebMReader.cpp#l205

It is possible for multiple WebMReaders to reference to the same WebMBufferedState object. The comment says it should be accessed on the main thread only. However, it is actually on the task queue thread. The usage seems racy and wrong.
Flags: needinfo?(jyavenard)
we no longer use WebMReader.

We also no longer access WebMReader on any thread other than the decoder's task queue.
How could multiple WebMReaders shared the WebMBufferedState ? I can't see how that could ever be possible.

It could have been accessed on multiple thread (though via a monitor) with the GetBuffered being on the main thread, but that's no long the case.

So at worse, it's an obsolete comment (and we should remove the monitor there), it will benefit the new WebMDemuxer / MediaFormatReader

I'm fairly sure that I had submitted a patch to do just that a little while ago...
Flags: needinfo?(jyavenard)
It is still possible to use WebMReader by setting "media.format-reader.webm" to false until we completely remove WebMReader.cpp/h.
https://hg.mozilla.org/mozilla-central/file/a45d680f073f/dom/media/webm/WebMReader.cpp#l205

WebMBufferedState is shared when a non-null aCloneDonor passed to WebMReader::Init(). this->mBufferedState and aCloneDonor->mBufferedState will reference the same object.
sure the code is there to do so, but when is it ever used in that fashion?
https://hg.mozilla.org/mozilla-central/file/a45d680f073f/dom/html/HTMLMediaElement.cpp#l2780

It is used when we are cloning a decoder which happens when 2 media element have the same URI for the 'src' attribute. The decoders will try to share resources when possible. (See MediaResource::CloneData and WebMReader::Init()) for examples.)
Depends on: 1213726
https://hg.mozilla.org/mozilla-central/file/b68eab795f9d/dom/media/webm/WebMReader.cpp#l806

After fixing bug 1213726, we still have WebMReader::NotifyDataArrivedInternal() calls mBufferedState->NotifyDataArrived. Since WebMBufferedState::NotifyDataArrived() is not protected by a monitor, it will be a data race when multiple WebMReaders share a WebMBufferedState.

Since WebMReader is gonna be deprecated, I think it won't hurt much to disable the sharing in WebMReader::Init(). It also allows me to do more code cleanup.
Bug 1212723. Part 2 - remove unused argument aCloneDonor from MediaDecoderReader::Init(). r=jya.
Attachment #8672886 - Flags: review?(jyavenard)
Assignee: nobody → jwwang
Blocks: 1214065
Comment on attachment 8672885 [details]
MozReview Request: Bug 1212723. Part 1 - don't share mBufferedState per bug 1212723 comment 6. r=jya.

https://reviewboard.mozilla.org/r/21813/#review19585
Attachment #8672885 - Flags: review?(jyavenard) → review+
Comment on attachment 8672886 [details]
MozReview Request: Bug 1212723. Part 2 - remove unused argument aCloneDonor from MediaDecoderReader::Init(). r=jya.

https://reviewboard.mozilla.org/r/21815/#review19587

starting to wonder what would happen if we shared the src across multiple media element ; do we have only a single MediaResource shared between decoderreader ?
Attachment #8672886 - Flags: review?(jyavenard) → review+
No, it is the underlying MediaCache that is shared.
See: https://hg.mozilla.org/mozilla-central/file/11ff0ccb7d59/dom/media/MediaCache.h#l458
In fact, we share only when ChannelMediaResource is used. When it comes to MediaSource, local files or RTSP, there is no way to share.
Thanks for the review!
Priority: -- → P2
https://hg.mozilla.org/mozilla-central/rev/3ae763ddaac8
https://hg.mozilla.org/mozilla-central/rev/7e968320d35b
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: