This project has moved and is read-only. For the latest updates, please go here.

Navigating away while video plays leaves tasks waiting for activation in TsMediaManager

Feb 2, 2015 at 8:43 PM
Edited Feb 3, 2015 at 5:44 PM
Hi there!

Just an interesting one I'm struggling to actually sort out.

Latest commit: ce1de859ee7ac7bb1d21ac6256b18c6dcfce5f58

If you navigate away (OnNavigateFrom -> Cleanup) (as an example use the nasa tv app, start the video and hit the ? button - you will see in the console the infinite loop of the following after the usual TaskCancelledException list)
TsMediaManager.CloseCleanupAsync() waiting for tasks
TsMediaManager.CloseCleanupAsync() finished tasks
It appears that on navigating away, task 2 and 4 respectively cannot complete. (TsMediaManager.cs ln. 325 & ln.331 respectively) and remain in a WaitingForActivation status.

Any help possibly on this? I've been trying to get around your codebase but it is quite substantial and a lot try and decern.

Thanks so much!
Feb 4, 2015 at 3:36 PM
The actual problem is that something is still running and the task it is waiting on is (IIRC) a TaskCompletionSource that isn't set until everything else has shut down. The reason for the timeout loop is to make it easier to put a breakpoint that will hit when something has gone wrong with a stream shutting down.

The complexity in the code is a result of things evolving from playing never ending streams to ones that support seeks without any systematic way of stopping and starting playback. A number of things in the processing pipeline do their own thing and when they are told to stop often try to tell things both upstream and downstream to stop, leading to numerous races and other complications, leading to code to handle said races, and, well, you are wading through the result (my apologies).

I haven't tested with the NASA TV app, but I'll take a look to see if I can get things to wedge. You are testing on WP8 with NasaTv.WP8, right?
Feb 4, 2015 at 3:44 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Feb 4, 2015 at 9:10 PM
No please, no need to apologize - the amount of work and effort and dedication in this library is insane.

It is indeed with NasaTv.WP8, simply start the stream and hit the ? button and watch the console output.

Thanks for your time, Henric!
Feb 4, 2015 at 9:53 PM
You're welcome.

But, well, anyway... the start/stop code is still a mess.

I'll try to figure out why it's getting wedged since I can reproduce the problem here. In the meantime, I suspect that if you copy the code related to OnNavigatedFrom() and OnNavigatedTo() from HlsView.WP8's MainPage.xaml.cs things will work better.