Closed Bug 984816 Opened 10 years ago Closed 10 years ago

[RTSP] Play/pause does not work for RTSP streaming

Categories

(Firefox OS Graveyard :: RTSP, defect)

ARM
Gonk (Firefox OS)
defect
Not set
major

Tracking

(Not tracked)

RESOLVED FIXED
2.0 S1 (9may)

People

(Reporter: ethan, Assigned: bechen)

Details

Attachments

(1 file, 1 obsolete file)

Reproduction Steps:
1. Enable the preference "media.rtsp.video.enabled" (disabled by default).
2. Click an RTSP URL.
3. When the video app is playing the RTSP streaming, press pause button.
4. Press play button.

Bug: RTSP streaming is not played after step 4.

Note:
1. Although not 100% sure, we guess this bug happens after bug 973408 was landed.
2. I verified RtspController::Play() was not called in step 4.
Assignee: nobody → vchang
Component: Video/Audio → RTSP
Product: Core → Firefox OS
Version: Trunk → unspecified
The root cause here is similar to the seek issue we found in Bug 947113. The tasks dispatch to mDecodeTaskQueue is pended because function DecodeVideoFrame() is blocked function. 
http://dxr.mozilla.org/mozilla-central/source/content/media/MediaDecoderStateMachine.cpp#603 
http://dxr.mozilla.org/mozilla-central/source/content/media/RtspMediaResource.cpp#214

This issue is easy to reproduce especially when network is slow. Still trying to find the better solution for this.
bechen has a wip patch for this. Reassign to him.
Assignee: vchang → bechen
Attached patch bug-984816.patch (obsolete) — Splinter Review
There are 2 deadlock issues when press pause/play on RTSP streaming.

1. When the streaming is paused, then press play button.

Thread 1 : |MediaDecoderStateMachine::DecodeVideo()| hold a lock then call |EnsureActive();| dispatch a play command to main thread. This thread will be blocked in RtpsMediaResource because there is no more data in it.

Main thread : be blocked |MediaDecoder::PlaybackPositionChanged()| because the lock is held by thread 1, then the play command can not be executed.

solution: release the lock in |EnsureActive|

2. When press pause button.

Thread 1: binder thread hold a lock in OMXCodec then be blocked in RtspMediaResource.

Thread 2: Trying to execute the pause command but it can't get the lock.

solution : reverse the order in RtspOmxReader::SetIdle()
Comment on attachment 8397541 [details] [diff] [review]
bug-984816.patch

Hi Chris:
Please help review this patch. Is it safe to release the monitor in EnsureActive?

Hi Vincent and Ethan:
Please help to try this patch to see if there is still deadlock issues.
Attachment #8397541 - Flags: review?(cpearce)
(In reply to Benjamin Chen [:bechen] from comment #4)
> Hi Vincent and Ethan:
> Please help to try this patch to see if there is still deadlock issues.
I manually tested both RTSP and HTTP streaming with your patch. I performed play/pause for dozens of times and didn't encounter any blocking (deadlock). So far so good. :)
Comment on attachment 8397541 [details] [diff] [review]
bug-984816.patch

Review of attachment 8397541 [details] [diff] [review]:
-----------------------------------------------------------------

Good catch!

::: content/media/MediaDecoderStateMachine.cpp
@@ +1498,5 @@
>      return;
>    }
>    mIsReaderIdle = false;
> +  {
> +    ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());

Please also release the monitor while mReader->SetIdle() is called in SetReaderIdle(), the same bug could happen there too.
Attachment #8397541 - Flags: review?(cpearce) → review+
(In reply to Chris Pearce (:cpearce) from comment #6)
> Comment on attachment 8397541 [details] [diff] [review]
> bug-984816.patch
> 
> Review of attachment 8397541 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> Good catch!
> 
> ::: content/media/MediaDecoderStateMachine.cpp
> @@ +1498,5 @@
> >      return;
> >    }
> >    mIsReaderIdle = false;
> > +  {
> > +    ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
> 
> Please also release the monitor while mReader->SetIdle() is called in
> SetReaderIdle(), the same bug could happen there too.

I don't think it is necessary to release the monitor in SetReaderIdle() because the caller of SetReaderIdle() would not hold the monitor. (Now we don't have an EnsureIdle function like EnsureActive)
Ah yes, very good.
Attachment #8397541 - Attachment is obsolete: true
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/d0080077a537
Status: NEW → RESOLVED
Closed: 10 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → 1.5 S1 (9may)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: