Loading multiple MediaElement results in slow video or not played at all when video memory usage is close to video card memory - by Koji

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


2
0
Sign in
to vote
ID 411429 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 2/5/2009 2:14:25 AM
Access Restriction Public

Description

I'm building an application that switches between several video files as condition changes. To make the switch smooth and the video starts smoothly, MediaElement's are not closed on switched out; I just Pause() and unload so that I can load it again when I need.

Doing this increases "Video Memory Usage" in Perforator. When "Video Memory Usage" gets close to specific amount, MediaElement either:
* Stops playing videos
* Plays audio okay, but video plays slow, like 1 FPS or less.

I tried this on two PCs.

1. DELL OptiPlex 745, 4GB RAM, Windows XP, NVIDIA GeForce 7600GS 256MB
2. DELL Precision T3400, 8GB RAM, Server 2008 x64, NVIDIA GeForce 9800GT 512MB

Problem starts appearing around over 200MB for GeForce 7600GS (256MB), and around over 470MB for 9800GT (512MB). I'm guessing this relates to the video memory amount of the video card. I can't be sure though.
Sign in to post a comment.
Posted by Koji on 2/17/2009 at 8:08 PM
Maybe should I report this bug to WPF, not to Visual Studio? Let me know if I should re-post.
Posted by Koji on 2/17/2009 at 8:05 PM
I don't understand that. I'm talking about video memory, not main memory. I have tons of main memory available (8GB). What you are talking about -- keep references or running GC -- is all about main memory, not about video memory.

Did you really play around with the sample code with GPUs that has its own video memory (not a shared memory type like Intel chipset graphics)?
You have to uncheck videos (means settings its MediaState to Close) to keep playing video smoothly.

Once WPF (or MediaElement or MIL, whichever's bug I don't know) gets into this state, it won't play any video even if I set its MediaState to Close, or release the reference and let the GC collect it.

Note that to investigate this issue further, I have purchased yet another graphics card with 1GB video memory. The problem occurs when video memory usage is around 280MB. Maybe there's more complicated things that affects the limit.

But as long as you pause and play another video, this problem occurs. The only workaround I have found so far is to Close before WPF gets into this state. And once WPF got into this state, the only solution is to exit the process and restart.

I can't find any words to describe the behavior other than a bug.
Posted by Microsoft on 2/16/2009 at 3:39 PM
Since a reference to the media element is kept around in order to be able to re-parent it, Garbage Collector cannot get rid of it and free up the memory. Thus this behavior is by design and not a bug.
Posted by Koji on 2/8/2009 at 2:24 AM
hmm...I tried to reactivate this bug without luck. Edit doesn't allow me to change Status to Active. Don't know why.
Posted by Koji on 2/8/2009 at 2:22 AM
Ah, thank you for your comment but I'm afraid to say that you misunderstood the issue.

1. It happens on non-HD video as well. It's just that HD video are easier to fill the video memory.
2. The issue occurs only when video memory is full. The HD video I mentioned can be played flawlessly on the test machines when video memory is not full.

I understand WPF could require some amount of video memory and may cause problems if not enough memoery is available.

The problem here is, MediaElement is not playing (paused) and it's even not loaded (removed from visual tree), but it doesn't release the memory and thus in the end, it eats up all the video memory available.

Even at that point, WPF doesn't release the memory and start acting strange.

What I think problematic is this behavior. I think MediaElement should release the video memory when it's unloaded. It can delay the release since the MediaElement may be loaded and played again, but at least WPF should be smart enough to release unused video memory under low video memory condition.
Posted by Microsoft on 2/6/2009 at 3:41 PM
HD videos are very resource consumptive, and therefore machine configuration has to realistically match your expectations. It might be possible to do this on a a very high-end machine with more than enough video memory to accomodate all of these videos, but on a standard desktop machine this is not realistic.
Posted by Microsoft on 2/6/2009 at 1:37 AM
Thanks for your feedback. We are escalating this bug to the product unit who works on that specific feature area. The team will review this issue and make a decision on whether they will fix it or not for the next release.

Thank you,
Visual Studio Product Team