Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OverlayContainer: release render resources on cleanup #2363

Merged
merged 1 commit into from
Mar 4, 2013

Conversation

FernetMenta
Copy link
Contributor

If subtitles are loaded from a separate file, it seems that they are ref counted elsewhere. Render resources are not cleared until the video is stopped. The Pi runs out of GPU memory after an hour of playback.
Credits to @popcornmix for tracking this down.

@popcornmix
Copy link
Member

This is the effect of the bug where subtitles become rectangles after GPU texture memory is full:
http://forum.xbmc.org/showthread.php?tid=155465

I've tested this patch on the Pi and textures are now freed, and it fixes the linked to problem.

@elupus
Copy link
Contributor

elupus commented Mar 3, 2013

Why are they elsewhere? , this indicate a leak.

@FernetMenta
Copy link
Contributor Author

I have not figured out yet. I think subs are loaded from a file and kept in a collection in that place. Submitting them to OverlayContainer just increases the ref count.
Maybe a better fix would be to submit a real copy to OverlayContainer?

@elupus
Copy link
Contributor

elupus commented Mar 3, 2013

Oh right you are. There is a collection of all subs in there. Heh, odd this
hasn't been more of an issue on other systems.

Ok to merge.

@FernetMenta
Copy link
Contributor Author

@elupus I just noticed that this change is not thread safe. pOverlay->m_overlay might be accessed by the render thread while video thread calls SAFE_RELEASE on it.

With regard on buffering it's not a good idea to release hw resources in that place. The object may still be referenced by OverlayRenderer.

How do you think about getting a copy from CDVDSubtitleParserCollection::Parse ?

@elupus
Copy link
Contributor

elupus commented Mar 3, 2013

We don't really release the resource though, only the reference.

But yea that is a issue.

Will ponder a bit.

@FernetMenta
Copy link
Contributor Author

here is an alternative fix: FernetMenta@abb9a8c

@elupus
Copy link
Contributor

elupus commented Mar 3, 2013

nah.. that looks messy. What types of subs are having this issue btw? All
the ones that keep refs in decoder are text based, those don't even use the
overlay renderer.

So I'm back to thinking this is some other problem at play here.

On Sun, Mar 3, 2013 at 5:39 PM, Rainer Hochecker
notifications@github.comwrote:

here is an alternative fix: FernetMenta/xbmc@5d9f786FernetMenta@5d9f786


Reply to this email directly or view it on GitHubhttps://github.com//pull/2363#issuecomment-14349798
.

@elupus
Copy link
Contributor

elupus commented Mar 3, 2013

Also that proposal breaks the whole idea to not re-upload static overlays
each frame.

On Sun, Mar 3, 2013 at 7:16 PM, Joakim Plate elupus@ecce.se wrote:

nah.. that looks messy. What types of subs are having this issue btw? All
the ones that keep refs in decoder are text based, those don't even use the
overlay renderer.

So I'm back to thinking this is some other problem at play here.

On Sun, Mar 3, 2013 at 5:39 PM, Rainer Hochecker <notifications@github.com

wrote:

here is an alternative fix: FernetMenta/xbmc@5d9f786FernetMenta@5d9f786


Reply to this email directly or view it on GitHubhttps://github.com//pull/2363#issuecomment-14349798
.

@popcornmix
Copy link
Member

The problem is observed with ass subs in seperate file. E.g.
http://alex131089.info/OpenElec/2x01%20-%20Anthropology%20101.ass

@FernetMenta
Copy link
Contributor Author

Also that proposal breaks the whole idea to not re-upload static overlays each frame.

you lost me here. As far as I understand the code, OverlayRenderer uploads the overlay and sets hw resources to m_overlay. Player would submit the same overlay again and OverlayRenderer increases reference. It would not re-upload overlays as long OverlayRenderer has referenced. Once OR releases its last reference it clears hw resources.

Note that subtitles which are parsed from the input stream are fine, only those provided by a separate file show this issue.

@elupus
Copy link
Contributor

elupus commented Mar 3, 2013

Yes. but if overlay renderer releases a resource, which is still about to get added to next frame, it will be lost and re-uploaded when dvdplayer finally manages to add it to render.

But as i said, normal text subs won't trigger this. So it must be ass based subs only then? Then there is a bug in that code. It keeps no buffer, so it must be leaking.

@elupus
Copy link
Contributor

elupus commented Mar 3, 2013

I like the option of copying the overlay object in CDVDSubtitleParserText::Parse(). It's easy, it's just two simple types that need copy constructors.

@elupus
Copy link
Contributor

elupus commented Mar 3, 2013

Actually the copy should be in CDVDSubtitleLineCollection::Get

@FernetMenta
Copy link
Contributor Author

I was looking into CDVDSubtitleLineCollection::Get and struggled with the ref count which is provate. Need to make it protected. What do you think is the better approach:

switch case in method get and call copy constructor explicitly

add a pure virtual method "Clone" to CDVDOverlay

what other type apart from ssa needs special handling?

@elupus
Copy link
Contributor

elupus commented Mar 3, 2013

@elupus
Copy link
Contributor

elupus commented Mar 3, 2013

I like the virtual Clone method. Feel free to move my code into a clone method.

@FernetMenta
Copy link
Contributor Author

updated the pr with your code + clone method

@elupus
Copy link
Contributor

elupus commented Mar 4, 2013

Looks good. Can be merged as long as some minor testing has been done.

@popcornmix
Copy link
Member

Minor testing of updated patch is looking fine on Pi.
I can confirm that textures are being freed from GPU. Subtitles appear when expected. No obvious problems.

elupus added a commit that referenced this pull request Mar 4, 2013
dvdplayer: make sure subtitle file parsers clone overlays

Since the subtitle parser will keep copies of the overlay structures
even after they have been used, hw gpu resources was never released.
So instead clone them as they leave parser, to have hw resources be
released when not used anymore.
@elupus elupus merged commit a769ded into xbmc:master Mar 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants