Page 1 of 1

Leaks in libvlc via VLCKit for tvOS

Posted: 21 Jul 2017 09:13
by ssbmaccom
With latest version (committed yesterday by Felix) of VLCKit I have seen many crashes of my App on tvOS.
I see the message: debugger ended with memory issue.

So I prepared an Instruments runs searching for leaks I like to share with you. There are a lot of leaks. after 30 seconds running just one stream I have more than 1900 leaks with about 5 MB.

Please review them. You can get the trace file for Instruments at http://www.schmidt-bilkenroth.de/vlcleaks.trace.zip

Regards,

SSB

Re: Leaks in libvlc via VLCKit for tvOS

Posted: 21 Jul 2017 15:37
by ssbmaccom
These are the locations, where the leaked blocks are allocated. This might ease your analyzis, esp. when you can't open the trace file created by Instruments.
First number in original is the frame number - I have replaced this with the number of leaked blocks.

Code: Select all

4 vuplusTV 4.08 MB aligned_alloc /Users/ssb/Projekte/ssb/AppleTV/_VLCKit/VLCKit/libvlc/vlc/compat/aligned_alloc.c:47 1972 vuplusTV 801.12 KB picture_NewFromResource /Users/ssb/Projekte/ssb/AppleTV/_VLCKit/VLCKit/libvlc/vlc/src/misc/picture.c:218 2 vuplusTV 2.53 KB vout_display_opengl_New /Users/ssb/Projekte/ssb/AppleTV/_VLCKit/VLCKit/libvlc/vlc/modules/video_output/opengl/vout_helper.c:639 6 vuplusTV 320 Bytes DecodeBlock /Users/ssb/Projekte/ssb/AppleTV/_VLCKit/VLCKit/libvlc/vlc/modules/codec/videotoolbox.m:1076 2 vuplusTV 96 Bytes generic_init /Users/ssb/Projekte/ssb/AppleTV/_VLCKit/VLCKit/libvlc/vlc/modules/video_output/opengl/converters.c:1105 1 vuplusTV 16 Bytes Open /Users/ssb/Projekte/ssb/AppleTV/_VLCKit/VLCKit/libvlc/vlc/modules/video_output/ios.m:181 2 vuplusTV 32 Bytes ToLower /Users/ssb/Projekte/ssb/AppleTV/_VLCKit/VLCKit/libvlc/vlc/modules/text_renderer/freetype/platform_fonts.c:445
The last one could potentially be fixed with this patch:

Code: Select all

diff --git a/modules/text_renderer/freetype/fonts/darwin.c b/modules/text_renderer/freetype/fonts/darwin.c index a3ea832954..b460afe72f 100644 --- a/modules/text_renderer/freetype/fonts/darwin.c +++ b/modules/text_renderer/freetype/fonts/darwin.c @@ -195,6 +195,7 @@ end: CFRelease(coreTextFontDescriptorsArray); CFRelease(familyName); + free(psz_lc); return p_family; }
I will investigate the others as well...

Re: Leaks in libvlc via VLCKit for tvOS

Posted: 24 Jul 2017 16:13
by Jean-Baptiste Kempf
Fixed, for this one.

Re: Leaks in libvlc via VLCKit for tvOS

Posted: 26 Jul 2017 20:54
by ssbmaccom
I checked after last update by Felix, but now there is a deadlock when stopping playback. Log stops with a message like „closing module ios“ or similar. The debug message inside ios.c vout module is not reached.

i check again with a fresh sandbox (git speed requires patience) and if this is not showing the deadlock, I will comment here.

Re: Leaks in libvlc via VLCKit for tvOS

Posted: 10 Aug 2017 13:00
by ssbmaccom
After circumventing the deadlock I was also able to switch back to use the shared libvlc instance inside VLCKit, as the new version has the pass-through property. Well I need to check it, but yes... this allows me not to pass options when creating the mediaplayer instance.
Now also many leaks have disappeared, but some are still left. It is not eating up too many bytes, but these are still leaks:

The objects that leaked were created here (Instruments is giving this info):
  • Malloc 32 Bytes 2 < multiple > 64 Bytes vuplusTV DecodeBlock
    at DecodeBlock /Users/ssb/Projekte/ssb/AppleTV/_VLCKit/VLCKit/libvlc/vlc/modules/codec/videotoolbox.m:1083
  • Malloc 16 Bytes 3 < multiple > 48 Bytes vuplusTV Open
    at Open /Users/ssb/Projekte/ssb/AppleTV/_VLCKit/VLCKit/libvlc/vlc/modules/video_output/ios.m:183
  • Malloc 32 Bytes 2 < multiple > 64 Bytes vuplusTV DecodeBlock
    at DecodeBlock /Users/ssb/Projekte/ssb/AppleTV/_VLCKit/VLCKit/libvlc/vlc/modules/codec/videotoolbox.m:1083
  • CFDictionary 2 < multiple > 128 Bytes vuplusTV DecodeBlock
    at DecodeBlock /Users/ssb/Projekte/ssb/AppleTV/_VLCKit/VLCKit/libvlc/vlc/modules/codec/videotoolbox.m:1069
  • CFData 2 < multiple > 320 Bytes vuplusTV DecodeBlock
    at DecodeBlock /Users/ssb/Projekte/ssb/AppleTV/_VLCKit/VLCKit/libvlc/vlc/modules/codec/videotoolbox.m:1076
When interested I can share the trace file saved from Instruments.